From 0fac9cc2d4b33eeada5eb48c676284a73a8fb022 Mon Sep 17 00:00:00 2001 From: Leonardo Luz Almeida Date: Fri, 1 Dec 2023 15:07:14 -0500 Subject: [PATCH] remove featureflag package Signed-off-by: Leonardo Luz Almeida --- util/featureflag/featureflag.go | 44 ----------------------- util/featureflag/featureflag_test.go | 53 ---------------------------- 2 files changed, 97 deletions(-) delete mode 100644 util/featureflag/featureflag.go delete mode 100644 util/featureflag/featureflag_test.go diff --git a/util/featureflag/featureflag.go b/util/featureflag/featureflag.go deleted file mode 100644 index 1957de055a571..0000000000000 --- a/util/featureflag/featureflag.go +++ /dev/null @@ -1,44 +0,0 @@ -package featureflag - -type featureFlags struct { - ExampleFeature *featureFlag -} - -// New will instantiate a new featureFlags object with all default values. -// Every new feature flag must be initialized in this function or the test -// will fail. -func New() featureFlags { - return featureFlags{ - ExampleFeature: &featureFlag{ - description: "this is just an example of how a feature flag must be created", - enabled: false, - }, - } -} - -type featureFlag struct { - description string - enabled bool -} - -func (ff *featureFlag) IsEnabled() bool { - if ff == nil { - return false - } - return ff.enabled -} - -func (ff *featureFlag) Enable() { - ff.enabled = true -} - -func (ff *featureFlag) Disable() { - ff.enabled = false -} - -func (ff *featureFlag) Description() string { - if ff == nil { - return "" - } - return ff.description -} diff --git a/util/featureflag/featureflag_test.go b/util/featureflag/featureflag_test.go deleted file mode 100644 index cdf4ffddfb566..0000000000000 --- a/util/featureflag/featureflag_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package featureflag_test - -import ( - "fmt" - "reflect" - "testing" - - "github.com/argoproj/argo-cd/v2/util/featureflag" - "github.com/stretchr/testify/assert" -) - -type FeatureFlager interface { - IsEnabled() bool - Enable() - Disable() - Description() string -} - -func TestFeatureFlags(t *testing.T) { - - t.Run("will validate a simple usage", func(t *testing.T) { - // Given - ff := featureflag.New() - - // Then - assert.False(t, ff.ExampleFeature.IsEnabled(), "ExampleFeature flags should always be disabled") - assert.NotEmpty(t, ff.ExampleFeature.Description(), "All feature flags must provide a description") - ff.ExampleFeature.Enable() - assert.True(t, ff.ExampleFeature.IsEnabled(), "ExampleFeature should be enabled") - }) - t.Run("will validate that all feature flags are properly initialized", func(t *testing.T) { - // Given - ff := featureflag.New() - value := reflect.ValueOf(ff) - types := value.Type() - fields := make(map[string]interface{}, value.NumField()) - - // When - for i := 0; i < value.NumField(); i++ { - if value.Field(i).CanInterface() { - fields[types.Field(i).Name] = value.Field(i).Interface() - } - } - - // Then - for k, v := range fields { - assert.NotNil(t, v, fmt.Sprintf("%s feature flag needs to be initialized in the New function", k)) - if ff, ok := v.(FeatureFlager); ok { - assert.NotEmpty(t, ff.Description(), fmt.Sprintf("%s feature flag needs to define its description", k)) - } - } - }) -}