Skip to content

Commit

Permalink
Add feature flag for unify controller CLI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mitalipaygude committed Nov 28, 2023
1 parent 0dc751b commit 28a35e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const (
CloudStackKubeVipDisabledEnvVar = "CLOUDSTACK_KUBE_VIP_DISABLED"
CheckpointEnabledEnvVar = "CHECKPOINT_ENABLED"
UseNewWorkflowsEnvVar = "USE_NEW_WORKFLOWS"
UseControllerForCli = "USE_CONTROLLER_FOR__CLI"
)

func FeedGates(featureGates []string) {
Expand Down Expand Up @@ -45,3 +46,11 @@ func UseNewWorkflows() Feature {
IsActive: globalFeatures.isActiveForEnvVar(UseNewWorkflowsEnvVar),
}
}

// UseControllerViaCLIWorkflow is used for the controller behind the CLI workflow.
func UseControllerViaCLIWorkflow() Feature {
return Feature{
Name: "Use new workflow logic for cluster operations leveraging controller via CLI",
IsActive: globalFeatures.isActiveForEnvVar(UseControllerForCli),
}
}
16 changes: 16 additions & 0 deletions pkg/features/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,19 @@ func TestIsActiveWithFeatureGatesTrue(t *testing.T) {

g.Expect(IsActive(fakeFeatureWithGate())).To(BeTrue())
}

func TestUseControllerForCliFalse(t *testing.T) {
g := NewWithT(t)
setupContext(t)

t.Setenv(UseControllerForCli, "false")
g.Expect(UseControllerViaCLIWorkflow().IsActive()).To(BeFalse())
}

func TestUseControllerForCliTrue(t *testing.T) {
g := NewWithT(t)
setupContext(t)

t.Setenv(UseControllerForCli, "true")
g.Expect(UseControllerViaCLIWorkflow().IsActive()).To(BeTrue())
}

0 comments on commit 28a35e5

Please sign in to comment.