diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index 610648d892..5b1bef694c 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -166,8 +166,10 @@ func (ic *ContainerEngine) PlayKube(ctx context.Context, body io.Reader, options return nil, err } + expandedContent := os.ExpandEnv(string(content)) + // split yaml document - documentList, err := splitMultiDocYAML(content) + documentList, err := splitMultiDocYAML([]byte(expandedContent)) if err != nil { return nil, err } diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 8581af4384..af6ae67c1a 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -1236,6 +1236,17 @@ items: restartPolicy: Never ` +var podWithEnvVariablesInterpolation = ` +apiVersion: v1 +kind: Pod +metadata: + name: foo +spec: + containers: + - name: bar + image: ${IMAGE} +` + var ( defaultCtrName = "testCtr" defaultCtrCmd = []string{"top"} @@ -6337,4 +6348,20 @@ spec: Expect(execArr[len(execArr)-1]).To(Not(ContainSubstring(arr[len(arr)-1]))) }) + It("support environment variables interpolation", func() { + os.Setenv("IMAGE", CITEST_IMAGE) + + err := writeYaml(podWithEnvVariablesInterpolation, kubeYaml) + Expect(err).ToNot(HaveOccurred()) + + kube := podmanTest.Podman([]string{"kube", "play", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube).Should(ExitCleanly()) + + inspect := podmanTest.Podman([]string{"inspect", "foo-bar", "--format", "'{{ .ImageName }}'"}) + inspect.WaitWithDefaultTimeout() + + imageName := inspect.OutputToString() + Expect(imageName).To(ContainSubstring(CITEST_IMAGE)) + }) })