Use service name when image name is empty when build (#1213)

This commit is contained in:
Hang Yan
2019-12-27 13:26:25 +08:00
committed by GitHub
parent dd28e9220b
commit a3a82f55fe
2 changed files with 18 additions and 10 deletions
+8 -5
View File
@@ -74,6 +74,9 @@ var unsupportedKey = map[string]bool{}
// initImageStream initializes ImageStream object
func (o *OpenShift) initImageStream(name string, service kobject.ServiceConfig, opt kobject.ConvertOptions) *imageapi.ImageStream {
if service.Image == "" {
service.Image = name
}
// Retrieve tags and image name for mapping
tag := GetImageTag(service.Image)
@@ -309,6 +312,11 @@ func (o *OpenShift) Transform(komposeObject kobject.KomposeObject, opt kobject.C
// Lastly, we must have an Image name to continue
if opt.Build == "local" && opt.InputFiles != nil && service.Build != "" {
// If there's no "image" key, use the name of the container that's built
if service.Image == "" {
service.Image = name
}
if service.Image == "" {
return nil, fmt.Errorf("image key required within build parameters in order to build and push service '%s'", name)
}
@@ -329,11 +337,6 @@ func (o *OpenShift) Transform(komposeObject kobject.KomposeObject, opt kobject.C
}
// If there's no "image" key, use the name of the container that's built
if service.Image == "" {
service.Image = name
}
// Generate pod only and nothing more
if service.Restart == "no" || service.Restart == "on-failure" {
// Error out if Controller Object is specified with restart: 'on-failure'