summaryrefslogtreecommitdiff
path: root/cmd/podman/play_kube.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-03-01 12:22:07 -0800
committerGitHub <noreply@github.com>2019-03-01 12:22:07 -0800
commitce8d7b8539ec724cce7eac14d5d555c3c3c23266 (patch)
tree74d1e06a3f6b1e8a60b7c8ee5fe641564b3bd634 /cmd/podman/play_kube.go
parent2747c20867127c930d705f5162dcd78b4faf9624 (diff)
parented1ea8dea1b2738829a05dd3c3dbcf4b6744ad3f (diff)
downloadpodman-ce8d7b8539ec724cce7eac14d5d555c3c3c23266.tar.gz
podman-ce8d7b8539ec724cce7eac14d5d555c3c3c23266.tar.bz2
podman-ce8d7b8539ec724cce7eac14d5d555c3c3c23266.zip
Merge pull request #2451 from baude/playrenamepodoncollision
rename pod when we have a name collision with a container
Diffstat (limited to 'cmd/podman/play_kube.go')
-rw-r--r--cmd/podman/play_kube.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/cmd/podman/play_kube.go b/cmd/podman/play_kube.go
index 6f23e340e..ac46ad5c6 100644
--- a/cmd/podman/play_kube.go
+++ b/cmd/podman/play_kube.go
@@ -90,8 +90,17 @@ func playKubeYAMLCmd(c *cliconfig.KubePlayValues) error {
return errors.Wrapf(err, "unable to read %s as YAML", args[0])
}
+ // check for name collision between pod and container
+ podName := podYAML.ObjectMeta.Name
+ for _, n := range podYAML.Spec.Containers {
+ if n.Name == podName {
+ fmt.Printf("a container exists with the same name (%s) as the pod in your YAML file; changing pod name to %s_pod\n", podName, podName)
+ podName = fmt.Sprintf("%s_pod", podName)
+ }
+ }
+
podOptions = append(podOptions, libpod.WithInfraContainer())
- podOptions = append(podOptions, libpod.WithPodName(podYAML.ObjectMeta.Name))
+ podOptions = append(podOptions, libpod.WithPodName(podName))
// TODO for now we just used the default kernel namespaces; we need to add/subtract this from yaml
nsOptions, err := shared.GetNamespaceOptions(strings.Split(DefaultKernelNamespaces, ","))