Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Rename --archive to --deactivate in update launchplan cmd
Browse files Browse the repository at this point in the history
Signed-off-by: asoundarya96 <sumisoundarya96@gmail.com>
  • Loading branch information
asoundarya96 committed Dec 20, 2023
1 parent 0b49071 commit 5752574
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 21 deletions.
1 change: 1 addition & 0 deletions clierrors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package clierrors

var (
ErrInvalidStateUpdate = "invalid state passed. Specify either activate or archive\n"
ErrInvalidBothStateUpdate = "invalid state passed. Specify either activate or deactivate\n"

ErrProjectNotPassed = "project id wasn't passed\n" // #nosec
ErrProjectIDBothPassed = "both project and id are passed\n"
Expand Down
2 changes: 1 addition & 1 deletion cmd/config/subcommand/launchplan/updateconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ var (

// Config
type UpdateConfig struct {
Archive bool `json:"archive" pflag:",disable the launch plan schedule (if it has an active schedule associated with it)."`
Activate bool `json:"activate" pflag:",activate launchplan."`
Deactivate bool `json:"deactivate" pflag:",disable the launch plan schedule (if it has an active schedule associated with it)."`
DryRun bool `json:"dryRun" pflag:",execute command without making any modifications."`
Force bool `json:"force" pflag:",do not ask for an acknowledgement during updates."`
Version string `json:"version" pflag:",version of the launchplan to be fetched."`
Expand Down
2 changes: 1 addition & 1 deletion cmd/config/subcommand/launchplan/updateconfig_flags.go
100755 → 100644

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

8 changes: 4 additions & 4 deletions cmd/config/subcommand/launchplan/updateconfig_flags_test.go

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

12 changes: 6 additions & 6 deletions cmd/update/launch_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ Activates a ` + "`launch plan <https://docs.flyte.org/projects/cookbook/en/lates
flytectl update launchplan -p flytesnacks -d development core.control_flow.merge_sort.merge_sort --version v1 --activate
Archives ` + "`(deactivates) <https://docs.flyte.org/projects/cookbook/en/latest/auto/core/scheduled_workflows/lp_schedules.html#deactivating-a-schedule>`__" + ` a launch plan which deschedules any scheduled job associated with it:
Deactivates a ` + "`launch plan <https://docs.flyte.org/projects/cookbook/en/latest/auto/core/scheduled_workflows/lp_schedules.html#deactivating-a-schedule>`__" + ` which deschedules any scheduled job associated with it:
::
flytectl update launchplan -p flytesnacks -d development core.control_flow.merge_sort.merge_sort --version v1 --archive
flytectl update launchplan -p flytesnacks -d development core.control_flow.merge_sort.merge_sort --version v1 --deactivate
Usage
`
Expand All @@ -44,15 +44,15 @@ func updateLPFunc(ctx context.Context, args []string, cmdCtx cmdCore.CommandCont
}

activate := launchplan.UConfig.Activate
archive := launchplan.UConfig.Archive
if activate == archive && archive {
return fmt.Errorf(clierrors.ErrInvalidStateUpdate)
deactivate := launchplan.UConfig.Deactivate
if activate == deactivate && deactivate {
return fmt.Errorf(clierrors.ErrInvalidBothStateUpdate)
}

var newState admin.LaunchPlanState
if activate {
newState = admin.LaunchPlanState_ACTIVE
} else if archive {
} else if deactivate {
newState = admin.LaunchPlanState_INACTIVE
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/update/launch_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func TestLaunchPlanCanBeActivated(t *testing.T) {
})
}

func TestLaunchPlanCanBeArchived(t *testing.T) {
func TestLaunchPlanCanBeDeactivated(t *testing.T) {
testLaunchPlanUpdate(
/* setup */ func(s *testutils.TestStruct, config *launchplan.UpdateConfig, launchplan *admin.LaunchPlan) {
launchplan.Closure.State = admin.LaunchPlanState_ACTIVE
config.Archive = true
config.Deactivate = true
config.Force = true
},
/* assert */ func(s *testutils.TestStruct, err error) {
Expand All @@ -53,14 +53,14 @@ func TestLaunchPlanCanBeArchived(t *testing.T) {
})
}

func TestLaunchPlanCannotBeActivatedAndArchivedAtTheSameTime(t *testing.T) {
func TestLaunchPlanCannotBeActivatedAndDeactivatedAtTheSameTime(t *testing.T) {
testLaunchPlanUpdate(
/* setup */ func(s *testutils.TestStruct, config *launchplan.UpdateConfig, launchplan *admin.LaunchPlan) {
config.Activate = true
config.Archive = true
config.Deactivate = true
},
/* assert */ func(s *testutils.TestStruct, err error) {
assert.ErrorContains(t, err, "Specify either activate or archive")
assert.ErrorContains(t, err, "Specify either activate or deactivate")
s.MockAdminClient.AssertNotCalled(t, "UpdateLaunchPlan", mock.Anything, mock.Anything)
})
}
Expand Down
9 changes: 5 additions & 4 deletions docs/source/gen/flytectl_update_launchplan.rst

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

0 comments on commit 5752574

Please sign in to comment.