@@ -25,6 +25,8 @@ const (
2525 existingPod2ServiceAccountName = "existing-pod-2-service-account"
2626)
2727
28+ var flagConfig = corev1alpha1 .NewFlagSourceConfigurationSpec ()
29+
2830// Sets up environment to simulate an upgrade, with an existing pod already in the cluster
2931func setupPreviouslyExistingPods () {
3032 ns := & corev1.Namespace {}
@@ -213,17 +215,16 @@ var _ = Describe("pod mutation webhook", func() {
213215 podMutationWebhookCleanup ()
214216 })
215217
216- It ("should not create flagd sidecar if openfeature.dev/featureflagconfiguration annotation isn't present" , func () {
218+ It ("should create flagd sidecar even if openfeature.dev/featureflagconfiguration annotation isn't present" , func () {
217219 pod := testPod (defaultPodName , defaultPodServiceAccountName , map [string ]string {
218220 "openfeature.dev" : "enabled" ,
219221 })
220- delete (pod .Annotations , "openfeature.dev/featureflagconfiguration" )
221222 err := k8sClient .Create (testCtx , pod )
222223 Expect (err ).ShouldNot (HaveOccurred ())
223224
224225 pod = getPod (defaultPodName )
225226
226- Expect (len (pod .Spec .Containers )).To (Equal (1 ))
227+ Expect (len (pod .Spec .Containers )).To (Equal (2 ))
227228
228229 podMutationWebhookCleanup ()
229230 })
@@ -354,30 +355,30 @@ var _ = Describe("pod mutation webhook", func() {
354355 })
355356
356357 It (`should create flagd sidecar if openfeature.dev/enabled annotation is "true"` , func () {
357- pod := testPod (map [string ]string {
358+ pod := testPod (defaultPodName , defaultPodServiceAccountName , map [string ]string {
358359 "openfeature.dev/enabled" : "true" ,
359360 "openfeature.dev/featureflagconfiguration" : fmt .Sprintf ("%s/%s" , mutatePodNamespace , featureFlagConfigurationName ),
360361 })
361362 err := k8sClient .Create (testCtx , pod )
362363 Expect (err ).ShouldNot (HaveOccurred ())
363364
364- pod = getPod ()
365+ pod = getPod (defaultPodName )
365366
366367 Expect (len (pod .Spec .Containers )).To (Equal (2 ))
367368
368369 podMutationWebhookCleanup ()
369370 })
370371
371372 It (`should only write non default flagsourceconfiguration env vars to the flagd container` , func () {
372- pod := testPod (map [string ]string {
373+ pod := testPod (defaultPodName , defaultPodServiceAccountName , map [string ]string {
373374 "openfeature.dev" : "enabled" ,
374375 "openfeature.dev/featureflagconfiguration" : fmt .Sprintf ("%s/%s" , mutatePodNamespace , featureFlagConfigurationName ),
375376 "openfeature.dev/flagsourceconfiguration" : fmt .Sprintf ("%s/%s" , mutatePodNamespace , flagSourceConfigurationName ),
376377 })
377378 err := k8sClient .Create (testCtx , pod )
378379 Expect (err ).ShouldNot (HaveOccurred ())
379380
380- pod = getPod ()
381+ pod = getPod (defaultPodName )
381382 fmt .Println (pod .Spec .Containers [1 ])
382383 Expect (pod .Spec .Containers [1 ].Env ).To (Equal ([]corev1.EnvVar {
383384 {Name : "FLAGD_METRICS_PORT" , Value : "8081" },
0 commit comments