Skip to content

Commit

Permalink
fix(install): No duplicate envvars on operator pod container
Browse files Browse the repository at this point in the history
  • Loading branch information
gansheer committed Apr 11, 2024
1 parent 926a1ab commit 882e7b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions e2e/advanced/synthetic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 3 additions & 1 deletion pkg/install/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down

0 comments on commit 882e7b5

Please sign in to comment.