diff --git a/.gitignore b/.gitignore index cfd1841c7..6b323cd6b 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ testbin/* *.swo *~ +go.work +go.work.sum diff --git a/Makefile b/Makefile index 6f2145991..e1a4a6f61 100644 --- a/Makefile +++ b/Makefile @@ -200,7 +200,7 @@ CRDOC ?= $(LOCALBIN)/crdoc KUSTOMIZE_VERSION ?= v4.5.7 # renovate: datasource=github-releases depName=kubernetes-sigs/controller-tools CONTROLLER_TOOLS_VERSION ?= v0.10.0 -CRDOC_VERSION ?= v0.6.2 +CRDOC_VERSION ?= v0.7.0 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" .PHONY: kustomize diff --git a/apis/core/v1alpha1/featureflagconfiguration_types.go b/apis/core/v1alpha1/featureflagconfiguration_types.go index 75189e20b..ea9438f4c 100644 --- a/apis/core/v1alpha1/featureflagconfiguration_types.go +++ b/apis/core/v1alpha1/featureflagconfiguration_types.go @@ -129,11 +129,7 @@ func (ff *FeatureFlagConfiguration) GenerateConfigMap(name string, namespace str OwnerReferences: references, }, Data: map[string]string{ -<<<<<<< HEAD common.FeatureFlagConfigurationConfigMapKey(namespace, name): ff.Spec.FeatureFlagSpec, -======= - utils.FeatureFlagConfigMapKey(namespace, name): ff.Spec.FeatureFlagSpec, ->>>>>>> feat: use v1beta1 in operator logic }, } } diff --git a/apis/core/v1alpha1/featureflagconfiguration_types_test.go b/apis/core/v1alpha1/featureflagconfiguration_types_test.go index 23dac2ce6..c5cb1a9a9 100644 --- a/apis/core/v1alpha1/featureflagconfiguration_types_test.go +++ b/apis/core/v1alpha1/featureflagconfiguration_types_test.go @@ -2,12 +2,11 @@ package v1alpha1 import ( "github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common" - "testing" - "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "testing" ) func Test_FeatureFlagConfiguration(t *testing.T) { diff --git a/apis/core/v1alpha1/flagsourceconfiguration_types.go b/apis/core/v1alpha1/flagsourceconfiguration_types.go index a949cce4b..b8809edd6 100644 --- a/apis/core/v1alpha1/flagsourceconfiguration_types.go +++ b/apis/core/v1alpha1/flagsourceconfiguration_types.go @@ -18,11 +18,11 @@ package v1alpha1 import ( "fmt" - "github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common" "os" "strconv" "strings" + "github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -49,7 +49,7 @@ const ( defaultEvaluator string = "json" defaultImage string = "ghcr.io/open-feature/flagd" // renovate: datasource=github-tags depName=open-feature/flagd/flagd - defaultTag string = "v0.6.3" + defaultTag string = "v0.7.0" defaultLogFormat string = "json" defaultProbesEnabled bool = true SyncProviderKubernetes SyncProviderType = "kubernetes" diff --git a/apis/core/v1alpha1/flagsourceconfiguration_types_test.go b/apis/core/v1alpha1/flagsourceconfiguration_types_test.go index ff7fb8639..57ddbeebb 100644 --- a/apis/core/v1alpha1/flagsourceconfiguration_types_test.go +++ b/apis/core/v1alpha1/flagsourceconfiguration_types_test.go @@ -1,9 +1,9 @@ package v1alpha1 import ( - "github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common" "testing" + "github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" ) diff --git a/apis/core/v1beta1/common.go b/apis/core/v1beta1/common.go deleted file mode 100644 index c67656d3c..000000000 --- a/apis/core/v1beta1/common.go +++ /dev/null @@ -1,11 +0,0 @@ -package v1beta1 - -type SyncProviderType string - -const ( - SyncProviderKubernetes SyncProviderType = "kubernetes" - SyncProviderFilepath SyncProviderType = "file" - SyncProviderHttp SyncProviderType = "http" - SyncProviderGrpc SyncProviderType = "grpc" - SyncProviderFlagdProxy SyncProviderType = "flagd-proxy" -) diff --git a/apis/core/v1beta1/common/common.go b/apis/core/v1beta1/common/common.go new file mode 100644 index 000000000..2f2e2d872 --- /dev/null +++ b/apis/core/v1beta1/common/common.go @@ -0,0 +1,57 @@ +package common + +import "fmt" + +type SyncProviderType string + +const ( + SyncProviderKubernetes SyncProviderType = "kubernetes" + SyncProviderFilepath SyncProviderType = "file" + SyncProviderHttp SyncProviderType = "http" + SyncProviderGrpc SyncProviderType = "grpc" + SyncProviderFlagdProxy SyncProviderType = "flagd-proxy" +) + +func (s SyncProviderType) IsKubernetes() bool { + return s == SyncProviderKubernetes +} + +func (s SyncProviderType) IsHttp() bool { + return s == SyncProviderHttp +} + +func (s SyncProviderType) IsFilepath() bool { + return s == SyncProviderFilepath +} + +func (s SyncProviderType) IsGrpc() bool { + return s == SyncProviderGrpc +} + +func (s SyncProviderType) IsFlagdProxy() bool { + return s == SyncProviderFlagdProxy +} + +func TrueVal() *bool { + b := true + return &b +} + +func FalseVal() *bool { + b := false + return &b +} + +func EnvVarKey(prefix string, suffix string) string { + return fmt.Sprintf("%s_%s", prefix, suffix) +} + +// unique string used to create unique volume mount and file name +func FeatureFlagConfigurationId(namespace, name string) string { + return fmt.Sprintf("%s_%s", namespace, name) +} + +// unique key (and filename) for configMap data +func FeatureFlagConfigMapKey(namespace, name string) string { + return fmt.Sprintf("%s.flagd.json", FeatureFlagConfigurationId(namespace, name)) +} diff --git a/apis/core/v1beta1/common/common_test.go b/apis/core/v1beta1/common/common_test.go new file mode 100644 index 000000000..b9095f83c --- /dev/null +++ b/apis/core/v1beta1/common/common_test.go @@ -0,0 +1,28 @@ +package common + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func Test_FeatureFlagSource_SyncProvider(t *testing.T) { + k := SyncProviderKubernetes + f := SyncProviderFilepath + h := SyncProviderHttp + g := SyncProviderGrpc + + require.True(t, k.IsKubernetes()) + require.True(t, f.IsFilepath()) + require.True(t, h.IsHttp()) + require.True(t, g.IsGrpc()) + + require.False(t, f.IsKubernetes()) + require.False(t, h.IsFilepath()) + require.False(t, k.IsGrpc()) + require.False(t, g.IsHttp()) +} + +func Test_FLagSourceConfiguration_envVarKey(t *testing.T) { + require.Equal(t, "pre_suf", EnvVarKey("pre", "suf")) +} diff --git a/apis/core/v1beta1/featureflag_types.go b/apis/core/v1beta1/featureflag_types.go index 522ca3d04..bc76d881d 100644 --- a/apis/core/v1beta1/featureflag_types.go +++ b/apis/core/v1beta1/featureflag_types.go @@ -19,7 +19,7 @@ package v1beta1 import ( "encoding/json" - "github.com/open-feature/open-feature-operator/common/utils" + "github.com/open-feature/open-feature-operator/apis/core/v1beta1/common" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -93,7 +93,7 @@ func (ff *FeatureFlag) GetReference() metav1.OwnerReference { Kind: ff.Kind, Name: ff.Name, UID: ff.UID, - Controller: utils.TrueVal(), + Controller: common.TrueVal(), } } @@ -112,7 +112,7 @@ func (ff *FeatureFlag) GenerateConfigMap(name string, namespace string, referenc OwnerReferences: references, }, Data: map[string]string{ - utils.FeatureFlagConfigMapKey(namespace, name): string(b), + common.FeatureFlagConfigMapKey(namespace, name): string(b), }, }, nil } diff --git a/apis/core/v1beta1/featureflag_types_test.go b/apis/core/v1beta1/featureflag_types_test.go index fb7af9a37..d5bcc6514 100644 --- a/apis/core/v1beta1/featureflag_types_test.go +++ b/apis/core/v1beta1/featureflag_types_test.go @@ -3,7 +3,7 @@ package v1beta1 import ( "testing" - "github.com/open-feature/open-feature-operator/common/utils" + "github.com/open-feature/open-feature-operator/apis/core/v1beta1/common" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -21,7 +21,7 @@ func Test_FeatureFlag(t *testing.T) { Kind: "kind", Name: "ffconf1", UID: types.UID("5"), - Controller: utils.TrueVal(), + Controller: common.TrueVal(), }, }, }, @@ -37,7 +37,7 @@ func Test_FeatureFlag(t *testing.T) { Kind: ff.Kind, Name: ff.Name, UID: ff.UID, - Controller: utils.TrueVal(), + Controller: common.TrueVal(), }, ff.GetReference()) name := "cmname" @@ -48,7 +48,7 @@ func Test_FeatureFlag(t *testing.T) { Kind: "kind", Name: "ffconf1", UID: types.UID("5"), - Controller: utils.TrueVal(), + Controller: common.TrueVal(), }, } diff --git a/apis/core/v1beta1/featureflagsource_types.go b/apis/core/v1beta1/featureflagsource_types.go index 93494ee54..ecbca0ab8 100644 --- a/apis/core/v1beta1/featureflagsource_types.go +++ b/apis/core/v1beta1/featureflagsource_types.go @@ -22,7 +22,7 @@ import ( "strconv" "strings" - "github.com/open-feature/open-feature-operator/common/utils" + "github.com/open-feature/open-feature-operator/apis/core/v1beta1/common" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -47,7 +47,7 @@ const ( defaultEvaluator string = "json" defaultImage string = "ghcr.io/open-feature/flagd" // renovate: datasource=github-tags depName=open-feature/flagd/flagd - defaultTag string = "v0.6.3" + defaultTag string = "v0.7.0" defaultLogFormat string = "json" defaultProbesEnabled bool = true ) @@ -93,7 +93,7 @@ type FeatureFlagSourceSpec struct { // DefaultSyncProvider defines the default sync provider // +optional - DefaultSyncProvider SyncProviderType `json:"defaultSyncProvider"` + DefaultSyncProvider common.SyncProviderType `json:"defaultSyncProvider"` // LogFormat allows for the sidecar log format to be overridden, defaults to 'json' // +optional @@ -131,7 +131,7 @@ type Source struct { // Provider type - kubernetes, http(s), grpc(s) or filepath // +optional - Provider SyncProviderType `json:"provider"` + Provider common.SyncProviderType `json:"provider"` // HttpSyncBearerToken is a bearer token. Used by http(s) sync provider only // +optional @@ -185,26 +185,6 @@ func init() { SchemeBuilder.Register(&FeatureFlagSource{}, &FeatureFlagSourceList{}) } -func (s SyncProviderType) IsKubernetes() bool { - return s == SyncProviderKubernetes -} - -func (s SyncProviderType) IsHttp() bool { - return s == SyncProviderHttp -} - -func (s SyncProviderType) IsFilepath() bool { - return s == SyncProviderFilepath -} - -func (s SyncProviderType) IsGrpc() bool { - return s == SyncProviderGrpc -} - -func (s SyncProviderType) IsFlagdProxy() bool { - return s == SyncProviderFlagdProxy -} - //nolint:gocyclo func NewFeatureFlagSourceSpec() (*FeatureFlagSourceSpec, error) { fsc := &FeatureFlagSourceSpec{ @@ -217,11 +197,11 @@ func NewFeatureFlagSourceSpec() (*FeatureFlagSourceSpec, error) { Sources: []Source{}, EnvVars: []corev1.EnvVar{}, SyncProviderArgs: []string{}, - DefaultSyncProvider: SyncProviderKubernetes, + DefaultSyncProvider: common.SyncProviderKubernetes, EnvVarPrefix: defaultSidecarEnvVarPrefix, LogFormat: defaultLogFormat, RolloutOnChange: nil, - DebugLogging: utils.FalseVal(), + DebugLogging: common.FalseVal(), OtelCollectorUri: "", } @@ -229,7 +209,7 @@ func NewFeatureFlagSourceSpec() (*FeatureFlagSourceSpec, error) { probes := defaultProbesEnabled fsc.ProbesEnabled = &probes - if metricsPort := os.Getenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarMetricPortEnvVar)); metricsPort != "" { + if metricsPort := os.Getenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarMetricPortEnvVar)); metricsPort != "" { metricsPortI, err := strconv.Atoi(metricsPort) if err != nil { return fsc, fmt.Errorf("unable to parse metrics port value %s to int32: %w", metricsPort, err) @@ -237,7 +217,7 @@ func NewFeatureFlagSourceSpec() (*FeatureFlagSourceSpec, error) { fsc.MetricsPort = int32(metricsPortI) } - if port := os.Getenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarPortEnvVar)); port != "" { + if port := os.Getenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarPortEnvVar)); port != "" { portI, err := strconv.Atoi(port) if err != nil { return fsc, fmt.Errorf("unable to parse sidecar port value %s to int32: %w", port, err) @@ -245,31 +225,31 @@ func NewFeatureFlagSourceSpec() (*FeatureFlagSourceSpec, error) { fsc.Port = int32(portI) } - if socketPath := os.Getenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarSocketPathEnvVar)); socketPath != "" { + if socketPath := os.Getenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarSocketPathEnvVar)); socketPath != "" { fsc.SocketPath = socketPath } - if evaluator := os.Getenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarEvaluatorEnvVar)); evaluator != "" { + if evaluator := os.Getenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarEvaluatorEnvVar)); evaluator != "" { fsc.Evaluator = evaluator } - if image := os.Getenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarImageEnvVar)); image != "" { + if image := os.Getenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarImageEnvVar)); image != "" { fsc.Image = image } - if tag := os.Getenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarVersionEnvVar)); tag != "" { + if tag := os.Getenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarVersionEnvVar)); tag != "" { fsc.Tag = tag } - if syncProviderArgs := os.Getenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarProviderArgsEnvVar)); syncProviderArgs != "" { + if syncProviderArgs := os.Getenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarProviderArgsEnvVar)); syncProviderArgs != "" { fsc.SyncProviderArgs = strings.Split(syncProviderArgs, ",") // todo: add documentation for this } - if syncProvider := os.Getenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarDefaultSyncProviderEnvVar)); syncProvider != "" { - fsc.DefaultSyncProvider = SyncProviderType(syncProvider) + if syncProvider := os.Getenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarDefaultSyncProviderEnvVar)); syncProvider != "" { + fsc.DefaultSyncProvider = common.SyncProviderType(syncProvider) } - if logFormat := os.Getenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarLogFormatEnvVar)); logFormat != "" { + if logFormat := os.Getenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarLogFormatEnvVar)); logFormat != "" { fsc.LogFormat = logFormat } @@ -277,7 +257,7 @@ func NewFeatureFlagSourceSpec() (*FeatureFlagSourceSpec, error) { fsc.EnvVarPrefix = envVarPrefix } - if probesEnabled := os.Getenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarProbesEnabledVar)); probesEnabled != "" { + if probesEnabled := os.Getenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarProbesEnabledVar)); probesEnabled != "" { b, err := strconv.ParseBool(probesEnabled) if err != nil { return fsc, fmt.Errorf("unable to parse sidecar probes enabled %s to boolean: %w", probesEnabled, err) @@ -348,49 +328,45 @@ func (fc *FeatureFlagSourceSpec) ToEnvVars() []corev1.EnvVar { for _, envVar := range fc.EnvVars { envs = append(envs, corev1.EnvVar{ - Name: envVarKey(fc.EnvVarPrefix, envVar.Name), + Name: common.EnvVarKey(fc.EnvVarPrefix, envVar.Name), Value: envVar.Value, }) } if fc.MetricsPort != DefaultMetricPort { envs = append(envs, corev1.EnvVar{ - Name: envVarKey(fc.EnvVarPrefix, SidecarMetricPortEnvVar), + Name: common.EnvVarKey(fc.EnvVarPrefix, SidecarMetricPortEnvVar), Value: fmt.Sprintf("%d", fc.MetricsPort), }) } if fc.Port != defaultPort { envs = append(envs, corev1.EnvVar{ - Name: envVarKey(fc.EnvVarPrefix, SidecarPortEnvVar), + Name: common.EnvVarKey(fc.EnvVarPrefix, SidecarPortEnvVar), Value: fmt.Sprintf("%d", fc.Port), }) } if fc.Evaluator != defaultEvaluator { envs = append(envs, corev1.EnvVar{ - Name: envVarKey(fc.EnvVarPrefix, SidecarEvaluatorEnvVar), + Name: common.EnvVarKey(fc.EnvVarPrefix, SidecarEvaluatorEnvVar), Value: fc.Evaluator, }) } if fc.SocketPath != defaultSocketPath { envs = append(envs, corev1.EnvVar{ - Name: envVarKey(fc.EnvVarPrefix, SidecarSocketPathEnvVar), + Name: common.EnvVarKey(fc.EnvVarPrefix, SidecarSocketPathEnvVar), Value: fc.SocketPath, }) } if fc.LogFormat != defaultLogFormat { envs = append(envs, corev1.EnvVar{ - Name: envVarKey(fc.EnvVarPrefix, SidecarLogFormatEnvVar), + Name: common.EnvVarKey(fc.EnvVarPrefix, SidecarLogFormatEnvVar), Value: fc.LogFormat, }) } return envs } - -func envVarKey(prefix string, suffix string) string { - return fmt.Sprintf("%s_%s", prefix, suffix) -} diff --git a/apis/core/v1beta1/featureflagsource_types_test.go b/apis/core/v1beta1/featureflagsource_types_test.go index dfb2decef..0a62c366b 100644 --- a/apis/core/v1beta1/featureflagsource_types_test.go +++ b/apis/core/v1beta1/featureflagsource_types_test.go @@ -3,86 +3,11 @@ package v1beta1 import ( "testing" - "github.com/open-feature/open-feature-operator/common/utils" + "github.com/open-feature/open-feature-operator/apis/core/v1beta1/common" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" ) -func Test_FeatureFlagSource_SyncProvider(t *testing.T) { - k := SyncProviderKubernetes - f := SyncProviderFilepath - h := SyncProviderHttp - g := SyncProviderGrpc - - require.True(t, k.IsKubernetes()) - require.True(t, f.IsFilepath()) - require.True(t, h.IsHttp()) - require.True(t, g.IsGrpc()) - - require.False(t, f.IsKubernetes()) - require.False(t, h.IsFilepath()) - require.False(t, k.IsGrpc()) - require.False(t, g.IsHttp()) -} - -func Test_FLagSourceConfiguration_envVarKey(t *testing.T) { - require.Equal(t, "pre_suf", envVarKey("pre", "suf")) -} - -func Test_FLagSourceConfiguration_ToEnvVars(t *testing.T) { - ff := FeatureFlagSource{ - Spec: FeatureFlagSourceSpec{ - EnvVars: []v1.EnvVar{ - { - Name: "env1", - Value: "val1", - }, - { - Name: "env2", - Value: "val2", - }, - }, - EnvVarPrefix: "PRE", - MetricsPort: 22, - Port: 33, - Evaluator: "evaluator", - SocketPath: "socket-path", - LogFormat: "log", - }, - } - expected := []v1.EnvVar{ - { - Name: "PRE_env1", - Value: "val1", - }, - { - Name: "PRE_env2", - Value: "val2", - }, - { - Name: "PRE_METRICS_PORT", - Value: "22", - }, - { - Name: "PRE_PORT", - Value: "33", - }, - { - Name: "PRE_EVALUATOR", - Value: "evaluator", - }, - { - Name: "PRE_SOCKET_PATH", - Value: "socket-path", - }, - { - Name: "PRE_LOG_FORMAT", - Value: "log", - }, - } - require.Equal(t, expected, ff.Spec.ToEnvVars()) -} - func Test_FLagSourceConfiguration_Merge(t *testing.T) { ff_old := &FeatureFlagSource{ Spec: FeatureFlagSourceSpec{ @@ -107,7 +32,7 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) { Sources: []Source{ { Source: "src1", - Provider: SyncProviderGrpc, + Provider: common.SyncProviderGrpc, TLS: true, CertPath: "etc/cert.ca", ProviderID: "app", @@ -115,10 +40,10 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) { }, }, SyncProviderArgs: []string{"arg1", "arg2"}, - DefaultSyncProvider: SyncProviderKubernetes, - RolloutOnChange: utils.TrueVal(), - ProbesEnabled: utils.TrueVal(), - DebugLogging: utils.TrueVal(), + DefaultSyncProvider: common.SyncProviderKubernetes, + RolloutOnChange: common.TrueVal(), + ProbesEnabled: common.TrueVal(), + DebugLogging: common.TrueVal(), OtelCollectorUri: "", }, } @@ -148,7 +73,7 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) { Sources: []Source{ { Source: "src1", - Provider: SyncProviderGrpc, + Provider: common.SyncProviderGrpc, TLS: true, CertPath: "etc/cert.ca", ProviderID: "app", @@ -156,10 +81,10 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) { }, }, SyncProviderArgs: []string{"arg1", "arg2"}, - DefaultSyncProvider: SyncProviderKubernetes, - RolloutOnChange: utils.TrueVal(), - ProbesEnabled: utils.TrueVal(), - DebugLogging: utils.TrueVal(), + DefaultSyncProvider: common.SyncProviderKubernetes, + RolloutOnChange: common.TrueVal(), + ProbesEnabled: common.TrueVal(), + DebugLogging: common.TrueVal(), OtelCollectorUri: "", }, }, ff_old) @@ -187,14 +112,14 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) { Sources: []Source{ { Source: "src2", - Provider: SyncProviderFilepath, + Provider: common.SyncProviderFilepath, }, }, SyncProviderArgs: []string{"arg3", "arg4"}, - DefaultSyncProvider: SyncProviderFilepath, - RolloutOnChange: utils.FalseVal(), - ProbesEnabled: utils.FalseVal(), - DebugLogging: utils.FalseVal(), + DefaultSyncProvider: common.SyncProviderFilepath, + RolloutOnChange: common.FalseVal(), + ProbesEnabled: common.FalseVal(), + DebugLogging: common.FalseVal(), OtelCollectorUri: "", }, } @@ -232,7 +157,7 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) { Sources: []Source{ { Source: "src1", - Provider: SyncProviderGrpc, + Provider: common.SyncProviderGrpc, TLS: true, CertPath: "etc/cert.ca", ProviderID: "app", @@ -240,14 +165,14 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) { }, { Source: "src2", - Provider: SyncProviderFilepath, + Provider: common.SyncProviderFilepath, }, }, SyncProviderArgs: []string{"arg1", "arg2", "arg3", "arg4"}, - DefaultSyncProvider: SyncProviderFilepath, - RolloutOnChange: utils.FalseVal(), - ProbesEnabled: utils.FalseVal(), - DebugLogging: utils.FalseVal(), + DefaultSyncProvider: common.SyncProviderFilepath, + RolloutOnChange: common.FalseVal(), + ProbesEnabled: common.FalseVal(), + DebugLogging: common.FalseVal(), OtelCollectorUri: "", }, }, ff_old) @@ -255,17 +180,17 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) { func Test_FLagSourceConfiguration_NewFeatureFlagSourceSpec(t *testing.T) { //happy path - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarMetricPortEnvVar), "22") - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarPortEnvVar), "33") - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarSocketPathEnvVar), "val1") - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarEvaluatorEnvVar), "val2") - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarImageEnvVar), "val3") - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarVersionEnvVar), "val4") - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarProviderArgsEnvVar), "val11,val22") - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarDefaultSyncProviderEnvVar), "kubernetes") - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarLogFormatEnvVar), "val5") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarMetricPortEnvVar), "22") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarPortEnvVar), "33") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarSocketPathEnvVar), "val1") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarEvaluatorEnvVar), "val2") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarImageEnvVar), "val3") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarVersionEnvVar), "val4") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarProviderArgsEnvVar), "val11,val22") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarDefaultSyncProviderEnvVar), "kubernetes") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarLogFormatEnvVar), "val5") t.Setenv(SidecarEnvVarPrefix, "val6") - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarProbesEnabledVar), "true") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarProbesEnabledVar), "true") fs, err := NewFeatureFlagSourceSpec() @@ -280,24 +205,78 @@ func Test_FLagSourceConfiguration_NewFeatureFlagSourceSpec(t *testing.T) { Sources: []Source{}, EnvVars: []v1.EnvVar{}, SyncProviderArgs: []string{"val11", "val22"}, - DefaultSyncProvider: SyncProviderKubernetes, + DefaultSyncProvider: common.SyncProviderKubernetes, EnvVarPrefix: "val6", LogFormat: "val5", - ProbesEnabled: utils.TrueVal(), - DebugLogging: utils.FalseVal(), + ProbesEnabled: common.TrueVal(), + DebugLogging: common.FalseVal(), OtelCollectorUri: "", }, fs) //error paths - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarProbesEnabledVar), "blah") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarProbesEnabledVar), "blah") _, err = NewFeatureFlagSourceSpec() require.NotNil(t, err) - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarPortEnvVar), "blah") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarPortEnvVar), "blah") _, err = NewFeatureFlagSourceSpec() require.NotNil(t, err) - t.Setenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarMetricPortEnvVar), "blah") + t.Setenv(common.EnvVarKey(InputConfigurationEnvVarPrefix, SidecarMetricPortEnvVar), "blah") _, err = NewFeatureFlagSourceSpec() require.NotNil(t, err) } + +func Test_FLagSourceConfiguration_ToEnvVars(t *testing.T) { + ff := FeatureFlagSource{ + Spec: FeatureFlagSourceSpec{ + EnvVars: []v1.EnvVar{ + { + Name: "env1", + Value: "val1", + }, + { + Name: "env2", + Value: "val2", + }, + }, + EnvVarPrefix: "PRE", + MetricsPort: 22, + Port: 33, + Evaluator: "evaluator", + SocketPath: "socket-path", + LogFormat: "log", + }, + } + expected := []v1.EnvVar{ + { + Name: "PRE_env1", + Value: "val1", + }, + { + Name: "PRE_env2", + Value: "val2", + }, + { + Name: "PRE_METRICS_PORT", + Value: "22", + }, + { + Name: "PRE_PORT", + Value: "33", + }, + { + Name: "PRE_EVALUATOR", + Value: "evaluator", + }, + { + Name: "PRE_SOCKET_PATH", + Value: "socket-path", + }, + { + Name: "PRE_LOG_FORMAT", + Value: "log", + }, + } + require.Equal(t, expected, ff.Spec.ToEnvVars()) +} diff --git a/chart/open-feature-operator/README.md b/chart/open-feature-operator/README.md index ca1b0ea92..7d6d926c6 100644 --- a/chart/open-feature-operator/README.md +++ b/chart/open-feature-operator/README.md @@ -98,7 +98,7 @@ The command removes all the Kubernetes components associated with the chart and | `sidecarConfiguration.metricsPort` | Sets the value of the `XXX_METRICS_PORT` environment variable for the injected sidecar. | `8014` | | `sidecarConfiguration.socketPath` | Sets the value of the `XXX_SOCKET_PATH` environment variable for the injected sidecar. | `""` | | `sidecarConfiguration.image.repository` | Sets the image for the injected sidecar. | `ghcr.io/open-feature/flagd` | -| `sidecarConfiguration.image.tag` | Sets the version tag for the injected sidecar. | `v0.6.3` | +| `sidecarConfiguration.image.tag` | Sets the version tag for the injected sidecar. | `v0.7.0` | | `sidecarConfiguration.providerArgs` | Used to append arguments to the sidecar startup command. This value is a comma separated string of key values separated by '=', e.g. `key=value,key2=value2` results in the appending of `--sync-provider-args key=value --sync-provider-args key2=value2`. | `""` | | `sidecarConfiguration.envVarPrefix` | Sets the prefix for all environment variables set in the injected sidecar. | `FLAGD` | | `sidecarConfiguration.defaultSyncProvider` | Sets the value of the `XXX_SYNC_PROVIDER` environment variable for the injected sidecar container. There are 4 valid sync providers: `kubernetes`, `grpc`, `filepath` and `http`. | `kubernetes` | diff --git a/chart/open-feature-operator/values.yaml b/chart/open-feature-operator/values.yaml index b414a6a3f..4fd679f68 100644 --- a/chart/open-feature-operator/values.yaml +++ b/chart/open-feature-operator/values.yaml @@ -16,7 +16,7 @@ sidecarConfiguration: ## @param sidecarConfiguration.image.repository Sets the image for the injected sidecar. repository: "ghcr.io/open-feature/flagd" ## @param sidecarConfiguration.image.tag Sets the version tag for the injected sidecar. - tag: v0.6.3 + tag: v0.7.0 ## @param sidecarConfiguration.providerArgs Used to append arguments to the sidecar startup command. This value is a comma separated string of key values separated by '=', e.g. `key=value,key2=value2` results in the appending of `--sync-provider-args key=value --sync-provider-args key2=value2`. providerArgs: "" ## @param sidecarConfiguration.envVarPrefix Sets the prefix for all environment variables set in the injected sidecar. diff --git a/common/flagdinjector/flagdinjector.go b/common/flagdinjector/flagdinjector.go index b93934a59..6be100eca 100644 --- a/common/flagdinjector/flagdinjector.go +++ b/common/flagdinjector/flagdinjector.go @@ -8,6 +8,7 @@ import ( "github.com/go-logr/logr" api "github.com/open-feature/open-feature-operator/apis/core/v1beta1" + apicommon "github.com/open-feature/open-feature-operator/apis/core/v1beta1/common" "github.com/open-feature/open-feature-operator/common" "github.com/open-feature/open-feature-operator/common/constant" "github.com/open-feature/open-feature-operator/common/flagdproxy" @@ -287,7 +288,7 @@ func (fi *FlagdContainerInjector) updateCMOwnerReference(ctx context.Context, ob func (fi *FlagdContainerInjector) toHttpProviderConfig(source api.Source) types.SourceConfig { return types.SourceConfig{ URI: source.Source, - Provider: string(api.SyncProviderHttp), + Provider: string(apicommon.SyncProviderHttp), BearerToken: source.HttpSyncBearerToken, } } @@ -295,7 +296,7 @@ func (fi *FlagdContainerInjector) toHttpProviderConfig(source api.Source) types. func (fi *FlagdContainerInjector) toGrpcProviderConfig(source api.Source) types.SourceConfig { return types.SourceConfig{ URI: source.Source, - Provider: string(api.SyncProviderGrpc), + Provider: string(apicommon.SyncProviderGrpc), TLS: source.TLS, CertPath: source.CertPath, ProviderID: source.ProviderID, @@ -368,7 +369,7 @@ func (fi *FlagdContainerInjector) toKubernetesProviderConfig(ctx context.Context // build K8s config return types.SourceConfig{ URI: fmt.Sprintf("%s/%s", ns, n), - Provider: string(api.SyncProviderKubernetes), + Provider: string(apicommon.SyncProviderKubernetes), }, nil } diff --git a/common/flagdinjector/flagdinjector_test.go b/common/flagdinjector/flagdinjector_test.go index 29af4bc97..59af79840 100644 --- a/common/flagdinjector/flagdinjector_test.go +++ b/common/flagdinjector/flagdinjector_test.go @@ -8,6 +8,7 @@ import ( "github.com/go-logr/logr/testr" api "github.com/open-feature/open-feature-operator/apis/core/v1beta1" + apicommon "github.com/open-feature/open-feature-operator/apis/core/v1beta1/common" "github.com/open-feature/open-feature-operator/common/constant" "github.com/open-feature/open-feature-operator/common/flagdproxy" "github.com/open-feature/open-feature-operator/common/utils" @@ -46,7 +47,7 @@ func TestFlagdContainerInjector_InjectDefaultSyncProvider(t *testing.T) { flagSourceConfig := getFlagSourceConfigSpec() - flagSourceConfig.DefaultSyncProvider = api.SyncProviderGrpc + flagSourceConfig.DefaultSyncProvider = apicommon.SyncProviderGrpc flagSourceConfig.Sources = []api.Source{{}} @@ -83,7 +84,7 @@ func TestFlagdContainerInjector_InjectDefaultSyncProvider_WithDebugLogging(t *te flagSourceConfig := getFlagSourceConfigSpec() - flagSourceConfig.DefaultSyncProvider = api.SyncProviderGrpc + flagSourceConfig.DefaultSyncProvider = apicommon.SyncProviderGrpc flagSourceConfig.DebugLogging = utils.TrueVal() @@ -122,7 +123,7 @@ func TestFlagdContainerInjector_InjectDefaultSyncProvider_WithOtelCollectorUri(t flagSourceConfig := getFlagSourceConfigSpec() - flagSourceConfig.DefaultSyncProvider = api.SyncProviderGrpc + flagSourceConfig.DefaultSyncProvider = apicommon.SyncProviderGrpc flagSourceConfig.OtelCollectorUri = "localhost:4317" @@ -161,7 +162,7 @@ func TestFlagdContainerInjector_InjectDefaultSyncProvider_WithResources(t *testi flagSourceConfig := getFlagSourceConfigSpec() - flagSourceConfig.DefaultSyncProvider = api.SyncProviderGrpc + flagSourceConfig.DefaultSyncProvider = apicommon.SyncProviderGrpc flagSourceConfig.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ @@ -212,7 +213,7 @@ func TestFlagdContainerInjector_InjectDefaultSyncProvider_WithSyncProviderArgs(t flagSourceConfig.SyncProviderArgs = []string{"arg-1", "arg-2"} - flagSourceConfig.DefaultSyncProvider = api.SyncProviderGrpc + flagSourceConfig.DefaultSyncProvider = apicommon.SyncProviderGrpc flagSourceConfig.Sources = []api.Source{{}} @@ -251,7 +252,7 @@ func TestFlagdContainerInjector_InjectFlagdKubernetesSource(t *testing.T) { flagSourceConfig.Sources = []api.Source{ { Source: "my-namespace/server-side", - Provider: api.SyncProviderKubernetes, + Provider: apicommon.SyncProviderKubernetes, }, } @@ -303,7 +304,7 @@ func TestFlagdContainerInjector_InjectFlagdFilePathSource(t *testing.T) { flagSourceConfig.Sources = []api.Source{ { Source: "my-namespace/server-side", - Provider: api.SyncProviderFilepath, + Provider: apicommon.SyncProviderFilepath, }, } @@ -387,7 +388,7 @@ func TestFlagdContainerInjector_InjectFlagdFilePathSource_UpdateReferencedConfig flagSourceConfig.Sources = []api.Source{ { Source: "my-namespace/server-side", - Provider: api.SyncProviderFilepath, + Provider: apicommon.SyncProviderFilepath, }, } @@ -459,7 +460,7 @@ func TestFlagdContainerInjector_InjectHttpSource(t *testing.T) { { Source: "http://localhost:8013", HttpSyncBearerToken: "my-token", - Provider: api.SyncProviderHttp, + Provider: apicommon.SyncProviderHttp, }, } @@ -500,7 +501,7 @@ func TestFlagdContainerInjector_InjectGrpcSource(t *testing.T) { flagSourceConfig.Sources = []api.Source{ { Source: "grpc://localhost:8013", - Provider: api.SyncProviderGrpc, + Provider: apicommon.SyncProviderGrpc, TLS: true, CertPath: "cert-path", ProviderID: "provider-id", @@ -544,7 +545,7 @@ func TestFlagdContainerInjector_InjectProxySource_ProxyNotAvailable(t *testing.T flagSourceConfig.Sources = []api.Source{ { - Provider: api.SyncProviderFlagdProxy, + Provider: apicommon.SyncProviderFlagdProxy, }, } @@ -585,7 +586,7 @@ func TestFlagdContainerInjector_InjectProxySource_ProxyNotReady(t *testing.T) { flagSourceConfig.Sources = []api.Source{ { - Provider: api.SyncProviderFlagdProxy, + Provider: apicommon.SyncProviderFlagdProxy, }, } @@ -629,7 +630,7 @@ func TestFlagdContainerInjector_InjectProxySource_ProxyIsReady(t *testing.T) { flagSourceConfig.Sources = []api.Source{ { - Provider: api.SyncProviderFlagdProxy, + Provider: apicommon.SyncProviderFlagdProxy, }, } diff --git a/controllers/core/featureflagsource/controller_test.go b/controllers/core/featureflagsource/controller_test.go index de3e481f8..e2693698f 100644 --- a/controllers/core/featureflagsource/controller_test.go +++ b/controllers/core/featureflagsource/controller_test.go @@ -7,6 +7,7 @@ import ( "time" api "github.com/open-feature/open-feature-operator/apis/core/v1beta1" + apicommon "github.com/open-feature/open-feature-operator/apis/core/v1beta1/common" "github.com/open-feature/open-feature-operator/common" "github.com/open-feature/open-feature-operator/common/flagdproxy" "github.com/stretchr/testify/require" @@ -37,28 +38,28 @@ func TestFeatureFlagSourceReconciler_Reconcile(t *testing.T) { }{ { name: "deployment gets restarted with rollout", - fsConfig: createTestFSConfig(fsConfigName, testNamespace, deploymentName, true, api.SyncProviderHttp), + fsConfig: createTestFSConfig(fsConfigName, testNamespace, deploymentName, true, apicommon.SyncProviderHttp), deployment: createTestDeployment(fsConfigName, testNamespace, deploymentName), restartedAtValueBeforeReconcile: "", restartedAtValueAfterReconcile: time.Now().Format(time.RFC3339), }, { name: "deployment without rollout", - fsConfig: createTestFSConfig(fsConfigName, testNamespace, deploymentName, false, api.SyncProviderHttp), + fsConfig: createTestFSConfig(fsConfigName, testNamespace, deploymentName, false, apicommon.SyncProviderHttp), deployment: createTestDeployment(fsConfigName, testNamespace, deploymentName), restartedAtValueBeforeReconcile: "", restartedAtValueAfterReconcile: "", }, { name: "no deployment", - fsConfig: createTestFSConfig(fsConfigName, testNamespace, deploymentName, true, api.SyncProviderHttp), + fsConfig: createTestFSConfig(fsConfigName, testNamespace, deploymentName, true, apicommon.SyncProviderHttp), deployment: nil, restartedAtValueBeforeReconcile: "", restartedAtValueAfterReconcile: "", }, { name: "no deployment, kube proxy deployment", - fsConfig: createTestFSConfig(fsConfigName, testNamespace, deploymentName, true, api.SyncProviderFlagdProxy), + fsConfig: createTestFSConfig(fsConfigName, testNamespace, deploymentName, true, apicommon.SyncProviderFlagdProxy), deployment: nil, restartedAtValueBeforeReconcile: "", restartedAtValueAfterReconcile: "", @@ -187,7 +188,7 @@ func createTestDeployment(fsConfigName string, testNamespace string, deploymentN return deployment } -func createTestFSConfig(fsConfigName string, testNamespace string, deploymentName string, rollout bool, provider api.SyncProviderType) *api.FeatureFlagSource { +func createTestFSConfig(fsConfigName string, testNamespace string, deploymentName string, rollout bool, provider apicommon.SyncProviderType) *api.FeatureFlagSource { fsConfig := &api.FeatureFlagSource{ ObjectMeta: metav1.ObjectMeta{ Name: fsConfigName, diff --git a/test/e2e/kuttl/fsconfig-file-sync/00-install.yaml b/test/e2e/kuttl/fsconfig-file-sync/00-install.yaml index 11d02f270..b249c99ff 100644 --- a/test/e2e/kuttl/fsconfig-file-sync/00-install.yaml +++ b/test/e2e/kuttl/fsconfig-file-sync/00-install.yaml @@ -8,7 +8,7 @@ spec: evaluator: json defaultSyncProvider: file # renovate: datasource=github-tags depName=open-feature/flagd/flagd - tag: v0.6.3 + tag: v0.7.0 sources: - source: end-to-end-test provider: file diff --git a/test/e2e/kuttl/fsconfig-file-sync/01-assert.yaml b/test/e2e/kuttl/fsconfig-file-sync/01-assert.yaml index ee5efbed5..747459483 100644 --- a/test/e2e/kuttl/fsconfig-file-sync/01-assert.yaml +++ b/test/e2e/kuttl/fsconfig-file-sync/01-assert.yaml @@ -13,4 +13,4 @@ spec: - name: open-feature-e2e-test image: nginx:stable-alpine - name: flagd # this part verifies flagd injection happened - image: ghcr.io/open-feature/flagd:v0.6.3 + image: ghcr.io/open-feature/flagd:v0.7.0 diff --git a/webhooks/common_test.go b/webhooks/common_test.go index efb17e172..2b46446ae 100644 --- a/webhooks/common_test.go +++ b/webhooks/common_test.go @@ -6,6 +6,7 @@ import ( "testing" api "github.com/open-feature/open-feature-operator/apis/core/v1beta1" + apicommon "github.com/open-feature/open-feature-operator/apis/core/v1beta1/common" "github.com/open-feature/open-feature-operator/common/constant" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -113,16 +114,16 @@ func TestPodMutator_containsK8sProvider(t *testing.T) { { name: "non-kubernetes", sources: []api.Source{ - {Provider: api.SyncProviderFilepath}, - {Provider: api.SyncProviderGrpc}, + {Provider: apicommon.SyncProviderFilepath}, + {Provider: apicommon.SyncProviderGrpc}, }, want: false, }, { name: "kubernetes", sources: []api.Source{ - {Provider: api.SyncProviderFilepath}, - {Provider: api.SyncProviderKubernetes}, + {Provider: apicommon.SyncProviderFilepath}, + {Provider: apicommon.SyncProviderKubernetes}, }, want: true, }, diff --git a/webhooks/pod_webhook_test.go b/webhooks/pod_webhook_test.go index 547652aa0..ed3e2b38c 100644 --- a/webhooks/pod_webhook_test.go +++ b/webhooks/pod_webhook_test.go @@ -12,6 +12,7 @@ import ( "github.com/go-logr/logr/testr" "github.com/golang/mock/gomock" api "github.com/open-feature/open-feature-operator/apis/core/v1beta1" + apicommon "github.com/open-feature/open-feature-operator/apis/core/v1beta1/common" "github.com/open-feature/open-feature-operator/common/constant" flagdinjectorfake "github.com/open-feature/open-feature-operator/common/flagdinjector/fake" "github.com/stretchr/testify/require" @@ -317,7 +318,7 @@ func TestPodMutator_Handle(t *testing.T) { }, Spec: api.FeatureFlagSourceSpec{ Sources: []api.Source{ - {Provider: api.SyncProviderKubernetes}, + {Provider: apicommon.SyncProviderKubernetes}, }, }, }, @@ -372,13 +373,6 @@ func TestPodMutator_Handle(t *testing.T) { }, }, setup: func(mockInjector *flagdinjectorfake.MockFlagdContainerInjector) { - mockInjector.EXPECT(). - EnableClusterRoleBinding( - gomock.Any(), - antPod.Namespace, - antPod.Spec.ServiceAccountName, - ).Return(nil).Times(1) - mockInjector.EXPECT(). InjectFlagd( gomock.Any(), @@ -406,22 +400,6 @@ func TestPodMutator_Handle(t *testing.T) { }, }, }, - setup: func(mockInjector *flagdinjectorfake.MockFlagdContainerInjector) { - mockInjector.EXPECT(). - EnableClusterRoleBinding( - gomock.Any(), - antPod.Namespace, - antPod.Spec.ServiceAccountName, - ).Return(nil).Times(1) - - mockInjector.EXPECT(). - InjectFlagd( - gomock.Any(), - gomock.AssignableToTypeOf(&antPod.ObjectMeta), - gomock.AssignableToTypeOf(&antPod.Spec), - gomock.AssignableToTypeOf(&api.FeatureFlagSourceSpec{}), - ).Return(constant.ErrFlagdProxyNotReady).Times(1) - }, wantCode: http.StatusNotFound, }, { @@ -461,13 +439,6 @@ func TestPodMutator_Handle(t *testing.T) { }, }, setup: func(mockInjector *flagdinjectorfake.MockFlagdContainerInjector) { - mockInjector.EXPECT(). - EnableClusterRoleBinding( - gomock.Any(), - antPod.Namespace, - antPod.Spec.ServiceAccountName, - ).Return(nil).Times(1) - mockInjector.EXPECT(). InjectFlagd( gomock.Any(),