kubectl: fix 'create deployment' to set container name correctly

This commit is contained in:
Michail Kargakis
2016-12-14 15:26:36 +01:00
parent 9705bb728e
commit bf78c00a96
3 changed files with 21 additions and 5 deletions

View File

@@ -67,8 +67,15 @@ func (s *DeploymentBasicGeneratorV1) StructuredGenerate() (runtime.Object, error
podSpec := api.PodSpec{Containers: []api.Container{}}
for _, imageString := range s.Images {
// Retain just the image name
imageSplit := strings.Split(imageString, "/")
name := imageSplit[len(imageSplit)-1]
// Remove any tag or hash
if strings.Contains(name, ":") {
name = strings.Split(name, ":")[0]
} else if strings.Contains(name, "@") {
name = strings.Split(name, "@")[0]
}
podSpec.Containers = append(podSpec.Containers, api.Container{Name: name, Image: imageString})
}