forked from LaconicNetwork/kompose
Use service name when image name is empty when build (#1213)
This commit is contained in:
parent
dd28e9220b
commit
a3a82f55fe
@ -125,6 +125,11 @@ func (k *Kubernetes) CheckUnsupportedKey(komposeObject *kobject.KomposeObject, u
|
|||||||
|
|
||||||
// InitPodSpec creates the pod specification
|
// InitPodSpec creates the pod specification
|
||||||
func (k *Kubernetes) InitPodSpec(name string, image string, pullSecret string) api.PodSpec {
|
func (k *Kubernetes) InitPodSpec(name string, image string, pullSecret string) api.PodSpec {
|
||||||
|
|
||||||
|
if image == "" {
|
||||||
|
image = name
|
||||||
|
}
|
||||||
|
|
||||||
pod := api.PodSpec{
|
pod := api.PodSpec{
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
@ -1018,6 +1023,11 @@ func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject.
|
|||||||
// Lastly, we must have an Image name to continue
|
// Lastly, we must have an Image name to continue
|
||||||
if opt.Build == "local" && opt.InputFiles != nil && service.Build != "" {
|
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 == "" {
|
if service.Image == "" {
|
||||||
return nil, fmt.Errorf("image key required within build parameters in order to build and push service '%s'", name)
|
return nil, fmt.Errorf("image key required within build parameters in order to build and push service '%s'", name)
|
||||||
}
|
}
|
||||||
@ -1040,11 +1050,6 @@ func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
// Generate pod only and nothing more
|
||||||
if service.Restart == "no" || service.Restart == "on-failure" {
|
if service.Restart == "no" || service.Restart == "on-failure" {
|
||||||
// Error out if Controller Object is specified with restart: 'on-failure'
|
// Error out if Controller Object is specified with restart: 'on-failure'
|
||||||
|
|||||||
@ -74,6 +74,9 @@ var unsupportedKey = map[string]bool{}
|
|||||||
|
|
||||||
// initImageStream initializes ImageStream object
|
// initImageStream initializes ImageStream object
|
||||||
func (o *OpenShift) initImageStream(name string, service kobject.ServiceConfig, opt kobject.ConvertOptions) *imageapi.ImageStream {
|
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
|
// Retrieve tags and image name for mapping
|
||||||
tag := GetImageTag(service.Image)
|
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
|
// Lastly, we must have an Image name to continue
|
||||||
if opt.Build == "local" && opt.InputFiles != nil && service.Build != "" {
|
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 == "" {
|
if service.Image == "" {
|
||||||
return nil, fmt.Errorf("image key required within build parameters in order to build and push service '%s'", name)
|
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
|
// Generate pod only and nothing more
|
||||||
if service.Restart == "no" || service.Restart == "on-failure" {
|
if service.Restart == "no" || service.Restart == "on-failure" {
|
||||||
// Error out if Controller Object is specified with restart: 'on-failure'
|
// Error out if Controller Object is specified with restart: 'on-failure'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user