From 59789daeda81ab2931a9fcd57d7b3f235180618d Mon Sep 17 00:00:00 2001 From: Mitali Paygude Date: Tue, 28 Nov 2023 15:01:43 -0800 Subject: [PATCH] Add feature flag for unify controller CLI workflow (#7104) * [PR BOT] Generate release testdata files (#6702) * Add feature flag for unify controller CLI workflow --------- Co-authored-by: EKS Distro PR Bot <75336432+eks-distro-pr-bot@users.noreply.github.com> --- pkg/features/features.go | 9 +++++++++ pkg/features/features_test.go | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/pkg/features/features.go b/pkg/features/features.go index 479ad7cf8b8f..dd0c7f9b6844 100644 --- a/pkg/features/features.go +++ b/pkg/features/features.go @@ -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) { @@ -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), + } +} diff --git a/pkg/features/features_test.go b/pkg/features/features_test.go index 6229980d8050..be9e8d8f421f 100644 --- a/pkg/features/features_test.go +++ b/pkg/features/features_test.go @@ -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()) +}