Skip to content

Commit

Permalink
Added workflow flag for get launchplan (flyteorg#287)
Browse files Browse the repository at this point in the history
* Added workflow flag for get launchplan

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* Using filter for workflow flag

Signed-off-by: Prafulla Mahindrakar <[email protected]>
  • Loading branch information
pmahindrakar-oss authored and robert-ulbrich-mercedes-benz committed Jul 2, 2024
1 parent 93b0cb9 commit ac5a093
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 443 deletions.
1 change: 1 addition & 0 deletions flytectl/cmd/config/subcommand/launchplan/config_flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions flytectl/cmd/config/subcommand/launchplan/config_flags_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ type Config struct {
Version string `json:"version" pflag:",version of the launchplan to be fetched."`
Latest bool `json:"latest" pflag:", flag to indicate to fetch the latest version, version flag will be ignored in this case"`
Filter filters.Filters `json:"filter" pflag:","`
Workflow string `json:"workflow" pflag:",name of the workflow for which the launchplans need to be fetched."`
}
14 changes: 14 additions & 0 deletions flytectl/cmd/get/launch_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package get

import (
"context"
"fmt"

"github.com/flyteorg/flytectl/cmd/config"
"github.com/flyteorg/flytectl/cmd/config/subcommand/launchplan"
Expand Down Expand Up @@ -40,6 +41,12 @@ Retrieve a particular version of the launch plan by name within the project and
flytectl get launchplan -p flytesnacks -d development core.basic.lp.go_greet --version v2
Retrieve all launch plans for a given workflow name:
::
flytectl get launchplan -p flytesnacks -d development --workflow core.flyte_basics.lp.go_greet
Retrieve all the launch plans with filters:
::
Expand Down Expand Up @@ -170,6 +177,13 @@ func getLaunchPlanFunc(ctx context.Context, args []string, cmdCtx cmdCore.Comman
return nil
}

if len(launchplan.DefaultConfig.Workflow) > 0 {
if len(launchplan.DefaultConfig.Filter.FieldSelector) > 0 {
return fmt.Errorf("fieldSelector cannot be specified with workflow flag")
}
launchplan.DefaultConfig.Filter.FieldSelector = fmt.Sprintf("workflow.name=%s", launchplan.DefaultConfig.Workflow)
}

launchPlans, err := cmdCtx.AdminFetcherExt().FetchAllVerOfLP(ctx, "", config.GetConfig().Project, config.GetConfig().Domain, launchplan.DefaultConfig.Filter)
if err != nil {
return err
Expand Down
Loading

0 comments on commit ac5a093

Please sign in to comment.