summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-08-04 07:01:51 -0400
committerGitHub <noreply@github.com>2022-08-04 07:01:51 -0400
commit1638218d1bc1c5dee315bc5e2d8e5da2202e5def (patch)
treeaf53a192289684e8e631b6ea556ff56445f60034
parent8f3f683a31b913bb27bdfaeed82f1786e3591b3b (diff)
parent7df8d80508bbc07f8aca79b5aa37e58dfeaa5895 (diff)
downloadpodman-1638218d1bc1c5dee315bc5e2d8e5da2202e5def.tar.gz
podman-1638218d1bc1c5dee315bc5e2d8e5da2202e5def.tar.bz2
podman-1638218d1bc1c5dee315bc5e2d8e5da2202e5def.zip
Merge pull request #15158 from cdoern/secrets
add omitempty to Secret in k8s VolumeSource
-rw-r--r--pkg/k8s.io/api/core/v1/types.go3
-rw-r--r--test/e2e/generate_kube_test.go23
2 files changed, 25 insertions, 1 deletions
diff --git a/pkg/k8s.io/api/core/v1/types.go b/pkg/k8s.io/api/core/v1/types.go
index 39a675dae..384965769 100644
--- a/pkg/k8s.io/api/core/v1/types.go
+++ b/pkg/k8s.io/api/core/v1/types.go
@@ -56,7 +56,8 @@ type VolumeSource struct {
// ConfigMap represents a configMap that should populate this volume
// +optional
ConfigMap *ConfigMapVolumeSource `json:"configMap,omitempty"`
- Secret *SecretVolumeSource
+ // Secret represents a secret that should be mounted as a volume
+ Secret *SecretVolumeSource `json:"secret,omitempty"`
}
// PersistentVolumeClaimVolumeSource references the user's PVC in the same namespace.
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())
+ })
})