Modify the pod name suffix '_pod' to '-pod'

Signed-off-by: aonoa <1991849113@qq.com>
This commit is contained in:
aonoa 2022-04-25 15:47:24 +08:00
parent ba6356280a
commit 94d043be8c
2 changed files with 3 additions and 3 deletions

View File

@ -525,9 +525,9 @@ func simplePodWithV1Containers(ctx context.Context, ctrs []*Container) (*v1.Pod,
} }
podName := strings.ReplaceAll(ctrs[0].Name(), "_", "") podName := strings.ReplaceAll(ctrs[0].Name(), "_", "")
// Check if the pod name and container name will end up conflicting // Check if the pod name and container name will end up conflicting
// Append _pod if so // Append -pod if so
if util.StringInSlice(podName, ctrNames) { if util.StringInSlice(podName, ctrNames) {
podName = podName + "_pod" podName = podName + "-pod"
} }
return newPodObject( return newPodObject(

View File

@ -71,7 +71,7 @@ var _ = Describe("Podman generate kube", func() {
Expect(pod.Spec.DNSConfig).To(BeNil()) Expect(pod.Spec.DNSConfig).To(BeNil())
Expect(pod.Spec.Containers[0].WorkingDir).To(Equal("")) Expect(pod.Spec.Containers[0].WorkingDir).To(Equal(""))
Expect(pod.Spec.Containers[0].Env).To(BeNil()) Expect(pod.Spec.Containers[0].Env).To(BeNil())
Expect(pod.Name).To(Equal("top_pod")) Expect(pod.Name).To(Equal("top-pod"))
numContainers := 0 numContainers := 0
for range pod.Spec.Containers { for range pod.Spec.Containers {