mirror of
https://github.com/containers/podman.git
synced 2025-06-23 18:59:30 +08:00
Merge pull request #15158 from cdoern/secrets
add omitempty to Secret in k8s VolumeSource
This commit is contained in:
@ -56,7 +56,8 @@ type VolumeSource struct {
|
|||||||
// ConfigMap represents a configMap that should populate this volume
|
// ConfigMap represents a configMap that should populate this volume
|
||||||
// +optional
|
// +optional
|
||||||
ConfigMap *ConfigMapVolumeSource `json:"configMap,omitempty"`
|
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.
|
// PersistentVolumeClaimVolumeSource references the user's PVC in the same namespace.
|
||||||
|
@ -1228,4 +1228,27 @@ USER test1`
|
|||||||
|
|
||||||
Expect(pod.Spec.Containers[0].Env).To(HaveLen(2))
|
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())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user