Skip to content

Commit 26ae125

Browse files
authored
feat: introduce debugLogging parameter to FlagSourceConfiguration CRD (#434)
Signed-off-by: odubajDT <[email protected]>
1 parent f24b6c4 commit 26ae125

16 files changed

+175
-30
lines changed

apis/core/v1alpha1/flagsourceconfiguration_types.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"strconv"
2323
"strings"
2424

25+
"github.com/open-feature/open-feature-operator/pkg/utils"
2526
corev1 "k8s.io/api/core/v1"
2627
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2728
)
@@ -119,9 +120,13 @@ type FlagSourceConfigurationSpec struct {
119120
// +optional
120121
RolloutOnChange *bool `json:"rolloutOnChange"`
121122

122-
// ProbesEnabled defines whether to enable liveness and readiness probes of flagd sidecar. Default true(enabled)
123+
// ProbesEnabled defines whether to enable liveness and readiness probes of flagd sidecar. Default true (enabled).
123124
// +optional
124125
ProbesEnabled *bool `json:"probesEnabled"`
126+
127+
// DebugLogging defines whether to enable --debug flag of flagd sidecar. Default false (disabled).
128+
// +optional
129+
DebugLogging *bool `json:"debugLogging"`
125130
}
126131

127132
type Source struct {
@@ -197,6 +202,7 @@ func NewFlagSourceConfigurationSpec() (*FlagSourceConfigurationSpec, error) {
197202
EnvVarPrefix: defaultSidecarEnvVarPrefix,
198203
LogFormat: defaultLogFormat,
199204
RolloutOnChange: nil,
205+
DebugLogging: utils.FalseVal(),
200206
}
201207

202208
// set default value derived from constant default
@@ -308,6 +314,9 @@ func (fc *FlagSourceConfigurationSpec) Merge(new *FlagSourceConfigurationSpec) {
308314
if new.ProbesEnabled != nil {
309315
fc.ProbesEnabled = new.ProbesEnabled
310316
}
317+
if new.DebugLogging != nil {
318+
fc.DebugLogging = new.DebugLogging
319+
}
311320
}
312321

313322
func (fc *FlagSourceConfigurationSpec) ToEnvVars() []corev1.EnvVar {

apis/core/v1alpha1/flagsourceconfiguration_types_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
118118
DefaultSyncProvider: SyncProviderKubernetes,
119119
RolloutOnChange: utils.TrueVal(),
120120
ProbesEnabled: utils.TrueVal(),
121+
DebugLogging: utils.TrueVal(),
121122
},
122123
}
123124

@@ -157,6 +158,7 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
157158
DefaultSyncProvider: SyncProviderKubernetes,
158159
RolloutOnChange: utils.TrueVal(),
159160
ProbesEnabled: utils.TrueVal(),
161+
DebugLogging: utils.TrueVal(),
160162
},
161163
}, ff_old)
162164

@@ -190,6 +192,7 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
190192
DefaultSyncProvider: SyncProviderFilepath,
191193
RolloutOnChange: utils.FalseVal(),
192194
ProbesEnabled: utils.FalseVal(),
195+
DebugLogging: utils.FalseVal(),
193196
},
194197
}
195198

@@ -241,6 +244,7 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
241244
DefaultSyncProvider: SyncProviderFilepath,
242245
RolloutOnChange: utils.FalseVal(),
243246
ProbesEnabled: utils.FalseVal(),
247+
DebugLogging: utils.FalseVal(),
244248
},
245249
}, ff_old)
246250
}
@@ -276,6 +280,7 @@ func Test_FLagSourceConfiguration_NewFlagSourceConfigurationSpec(t *testing.T) {
276280
EnvVarPrefix: "val6",
277281
LogFormat: "val5",
278282
ProbesEnabled: utils.TrueVal(),
283+
DebugLogging: utils.FalseVal(),
279284
}, fs)
280285

281286
//error paths

apis/core/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/core/v1alpha2/flagsourceconfiguration_conversion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
2323
"github.com/open-feature/open-feature-operator/apis/core/v1alpha2/common"
24+
"github.com/open-feature/open-feature-operator/pkg/utils"
2425
"sigs.k8s.io/controller-runtime/pkg/conversion"
2526
)
2627

@@ -47,6 +48,7 @@ func (src *FlagSourceConfiguration) ConvertTo(dstRaw conversion.Hub) error {
4748
LogFormat: src.Spec.LogFormat,
4849
DefaultSyncProvider: v1alpha1.SyncProviderType(src.Spec.DefaultSyncProvider),
4950
ProbesEnabled: src.Spec.ProbesEnabled,
51+
DebugLogging: utils.FalseVal(),
5052
}
5153
return nil
5254
}

apis/core/v1alpha2/flagsourceconfiguration_conversion_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
77
"github.com/open-feature/open-feature-operator/apis/core/v1alpha2/common"
8+
"github.com/open-feature/open-feature-operator/pkg/utils"
89
"github.com/stretchr/testify/require"
910
corev1 "k8s.io/api/core/v1"
1011
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -63,6 +64,7 @@ func TestFlagSourceConfiguration_ConvertFrom(t *testing.T) {
6364
EnvVarPrefix: "pre",
6465
RolloutOnChange: &tt,
6566
SyncProviderArgs: []string{"provider", "arg"},
67+
DebugLogging: utils.FalseVal(),
6668
},
6769
},
6870
wantErr: false,
@@ -152,6 +154,7 @@ func TestFlagSourceConfiguration_ConvertTo(t *testing.T) {
152154
EnvVarPrefix: "",
153155
RolloutOnChange: nil,
154156
SyncProviderArgs: []string{"provider", "arg"},
157+
DebugLogging: utils.FalseVal(),
155158
},
156159
},
157160
},

apis/core/v1alpha2/flagsourceconfiguration_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type FlagSourceConfigurationSpec struct {
6464
// +optional
6565
LogFormat string `json:"logFormat"`
6666

67-
// ProbesEnabled defines whether to enable liveness and readiness probes of flagd sidecar. Default true(enabled)
67+
// ProbesEnabled defines whether to enable liveness and readiness probes of flagd sidecar. Default true (enabled).
6868
// +optional
6969
ProbesEnabled *bool `json:"probesEnabled"`
7070
}

apis/core/v1alpha3/flagsourceconfiguration_conversion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func (src *FlagSourceConfiguration) ConvertTo(dstRaw conversion.Hub) error {
6262
EnvVarPrefix: src.Spec.EnvVarPrefix,
6363
RolloutOnChange: src.Spec.RolloutOnChange,
6464
ProbesEnabled: src.Spec.ProbesEnabled,
65+
DebugLogging: src.Spec.DebugLogging,
6566
}
6667
return nil
6768
}
@@ -104,6 +105,7 @@ func (dst *FlagSourceConfiguration) ConvertFrom(srcRaw conversion.Hub) error {
104105
EnvVarPrefix: src.Spec.EnvVarPrefix,
105106
RolloutOnChange: src.Spec.RolloutOnChange,
106107
ProbesEnabled: src.Spec.ProbesEnabled,
108+
DebugLogging: src.Spec.DebugLogging,
107109
}
108110
return nil
109111
}

apis/core/v1alpha3/flagsourceconfiguration_conversion_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
77
"github.com/open-feature/open-feature-operator/apis/core/v1alpha3/common"
8+
"github.com/open-feature/open-feature-operator/pkg/utils"
89
"github.com/stretchr/testify/require"
910
corev1 "k8s.io/api/core/v1"
1011
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -62,6 +63,7 @@ func TestFlagSourceConfiguration_ConvertFrom(t *testing.T) {
6263
LogFormat: "log",
6364
EnvVarPrefix: "pre",
6465
RolloutOnChange: &tt,
66+
DebugLogging: utils.FalseVal(),
6567
},
6668
},
6769
wantErr: false,
@@ -102,6 +104,7 @@ func TestFlagSourceConfiguration_ConvertFrom(t *testing.T) {
102104
LogFormat: "log",
103105
EnvVarPrefix: "pre",
104106
RolloutOnChange: &tt,
107+
DebugLogging: utils.FalseVal(),
105108
},
106109
},
107110
},
@@ -175,6 +178,7 @@ func TestFlagSourceConfiguration_ConvertTo(t *testing.T) {
175178
LogFormat: "log",
176179
EnvVarPrefix: "pre",
177180
RolloutOnChange: &tt,
181+
DebugLogging: utils.FalseVal(),
178182
},
179183
},
180184
wantErr: false,
@@ -215,6 +219,7 @@ func TestFlagSourceConfiguration_ConvertTo(t *testing.T) {
215219
LogFormat: "log",
216220
EnvVarPrefix: "pre",
217221
RolloutOnChange: &tt,
222+
DebugLogging: utils.FalseVal(),
218223
},
219224
},
220225
},

apis/core/v1alpha3/flagsourceconfiguration_types.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,13 @@ type FlagSourceConfigurationSpec struct {
8585
// +optional
8686
RolloutOnChange *bool `json:"rolloutOnChange"`
8787

88-
// ProbesEnabled defines whether to enable liveness and readiness probes of flagd sidecar. Default true(enabled)
88+
// ProbesEnabled defines whether to enable liveness and readiness probes of flagd sidecar. Default true (enabled).
8989
// +optional
9090
ProbesEnabled *bool `json:"probesEnabled"`
91+
92+
// DebugLogging defines whether to enable --debug flag of flagd sidecar. Default false (disabled).
93+
// +optional
94+
DebugLogging *bool `json:"debugLogging"`
9195
}
9296

9397
type Source struct {

apis/core/v1alpha3/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)