From a2d799f7301165cef16c118729263b7f896a1bd2 Mon Sep 17 00:00:00 2001 From: Gaelle Fournier Date: Tue, 9 Apr 2024 16:06:29 +0200 Subject: [PATCH] fix(install): No duplicate envvars on operator pod container --- e2e/advanced/synthetic_test.go | 8 ++++++++ pkg/install/operator.go | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/e2e/advanced/synthetic_test.go b/e2e/advanced/synthetic_test.go index 4ed0d84134..74ba8f341e 100644 --- a/e2e/advanced/synthetic_test.go +++ b/e2e/advanced/synthetic_test.go @@ -30,6 +30,7 @@ import ( . "github.com/apache/camel-k/v2/e2e/support" v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" + "github.com/apache/camel-k/v2/pkg/util/envvar" . "github.com/onsi/gomega/gstruct" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -70,6 +71,13 @@ func TestSyntheticIntegrationFromDeployment(t *testing.T) { g.Expect(KamelInstallWithID(t, ctx, operatorID, ns, "--operator-env-vars", "CAMEL_K_SYNTHETIC_INTEGRATIONS=true", )).To(Succeed()) + g.Eventually(OperatorPodHas(t, ctx, ns, func(op *corev1.Pod) bool { + if envVar := envvar.Get(op.Spec.Containers[0].Env, "CAMEL_K_SYNTHETIC_INTEGRATIONS"); envVar != nil { + return envVar.Value == "true" + } + return false + + }), TestTimeoutShort).Should(BeTrue()) // Run the external deployment ExpectExecSucceed(t, g, Kubectl("apply", "-f", "files/deploy.yaml", "-n", ns)) diff --git a/pkg/install/operator.go b/pkg/install/operator.go index 4c2d0aae50..4dba69bb8e 100644 --- a/pkg/install/operator.go +++ b/pkg/install/operator.go @@ -145,7 +145,9 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client, fmt.Fprintln(cmd.ErrOrStderr(), "Warning: could not parse environment variables!") } for i := 0; i < len(d.Spec.Template.Spec.Containers); i++ { - d.Spec.Template.Spec.Containers[i].Env = append(d.Spec.Template.Spec.Containers[i].Env, envVars...) + for _, envVar := range envVars { + envvar.SetVar(&d.Spec.Template.Spec.Containers[i].Env, envVar) + } } } }