This is an automated email from the ASF dual-hosted git repository.
gfournier pushed a commit to branch release-2.3.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/release-2.3.x by this push:
new 882e7b5ef fix(install): No duplicate envvars on operator pod container
882e7b5ef is described below
commit 882e7b5efeebe17664fd868d79039248e19ddf71
Author: Gaelle Fournier <[email protected]>
AuthorDate: Tue Apr 9 16:06:29 2024 +0200
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 4ed0d8413..74ba8f341 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 4c2d0aae5..4dba69bb8 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)
+ }
}
}
}