summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorCharlie Doern <cdoern@redhat.com>2022-08-02 11:31:59 -0400
committerCharlie Doern <cdoern@redhat.com>2022-08-03 16:42:28 -0400
commit7df8d80508bbc07f8aca79b5aa37e58dfeaa5895 (patch)
treebc34ac6b9a890aff272e51c3f5e3af07dce4bbac /test/e2e
parent549974d97e9c5f1adb1158d1a523777ea722bf65 (diff)
downloadpodman-7df8d80508bbc07f8aca79b5aa37e58dfeaa5895.tar.gz
podman-7df8d80508bbc07f8aca79b5aa37e58dfeaa5895.tar.bz2
podman-7df8d80508bbc07f8aca79b5aa37e58dfeaa5895.zip
add omitempty to Secret in k8s VolumeSource
Secret was populating a generated kube as `null`. Add omitempty so that when the volume source is not a secret, we do not print unnecessary info resolves #15156 Signed-off-by: Charlie Doern <cdoern@redhat.com>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/generate_kube_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go
index 845aa60ce..5e9881c4f 100644
--- a/test/e2e/generate_kube_test.go
+++ b/test/e2e/generate_kube_test.go
@@ -1228,4 +1228,27 @@ USER test1`
Expect(pod.Spec.Containers[0].Env).To(HaveLen(2))
})
+
+ It("podman generate kube omit secret if empty", func() {
+ dir, err := os.MkdirTemp(tempdir, "podman")
+ Expect(err).Should(BeNil())
+
+ defer os.RemoveAll(dir)
+
+ podCreate := podmanTest.Podman([]string{"run", "-d", "--pod", "new:" + "noSecretsPod", "--name", "noSecretsCtr", "--volume", dir + ":/foobar", ALPINE})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate).Should(Exit(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "noSecretsPod"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube).Should(Exit(0))
+
+ Expect(kube.OutputToString()).ShouldNot(ContainSubstring("secret"))
+
+ pod := new(v1.Pod)
+ err = yaml.Unmarshal(kube.Out.Contents(), pod)
+ Expect(err).To(BeNil())
+
+ Expect(pod.Spec.Volumes[0].Secret).To(BeNil())
+ })
})