forked from LaconicNetwork/kompose
Merge pull request #122 from ngtuna/update-objects
fix #121: update all objects, even when port is missing
This commit is contained in:
commit
3f94d778d7
@ -225,9 +225,20 @@ func PortsExist(name string, service kobject.ServiceConfig) bool {
|
|||||||
|
|
||||||
// create a kubernetes Service
|
// create a kubernetes Service
|
||||||
func CreateService(name string, service kobject.ServiceConfig, objects []runtime.Object) *api.Service {
|
func CreateService(name string, service kobject.ServiceConfig, objects []runtime.Object) *api.Service {
|
||||||
|
|
||||||
svc := InitSvc(name, service)
|
svc := InitSvc(name, service)
|
||||||
|
|
||||||
|
// Configure the service ports.
|
||||||
|
servicePorts := ConfigServicePorts(name, service)
|
||||||
|
svc.Spec.Ports = servicePorts
|
||||||
|
|
||||||
|
// Configure annotations
|
||||||
|
annotations := transformer.ConfigAnnotations(service)
|
||||||
|
svc.ObjectMeta.Annotations = annotations
|
||||||
|
|
||||||
|
return svc
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateKubernetesObjects(name string, service kobject.ServiceConfig, objects []runtime.Object) {
|
||||||
// Configure the environment variables.
|
// Configure the environment variables.
|
||||||
envs := ConfigEnvs(name, service)
|
envs := ConfigEnvs(name, service)
|
||||||
|
|
||||||
@ -240,13 +251,8 @@ func CreateService(name string, service kobject.ServiceConfig, objects []runtime
|
|||||||
// Configure the container ports.
|
// Configure the container ports.
|
||||||
ports := ConfigPorts(name, service)
|
ports := ConfigPorts(name, service)
|
||||||
|
|
||||||
// Configure the service ports.
|
|
||||||
servicePorts := ConfigServicePorts(name, service)
|
|
||||||
svc.Spec.Ports = servicePorts
|
|
||||||
|
|
||||||
// Configure annotations
|
// Configure annotations
|
||||||
annotations := transformer.ConfigAnnotations(service)
|
annotations := transformer.ConfigAnnotations(service)
|
||||||
svc.ObjectMeta.Annotations = annotations
|
|
||||||
|
|
||||||
// fillTemplate fills the pod template with the value calculated from config
|
// fillTemplate fills the pod template with the value calculated from config
|
||||||
fillTemplate := func(template *api.PodTemplateSpec) {
|
fillTemplate := func(template *api.PodTemplateSpec) {
|
||||||
@ -289,6 +295,4 @@ func CreateService(name string, service kobject.ServiceConfig, objects []runtime
|
|||||||
for _, obj := range objects {
|
for _, obj := range objects {
|
||||||
UpdateController(obj, fillTemplate, fillObjectMeta)
|
UpdateController(obj, fillTemplate, fillObjectMeta)
|
||||||
}
|
}
|
||||||
|
|
||||||
return svc
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -244,6 +244,8 @@ func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject.
|
|||||||
objects = append(objects, svc)
|
objects = append(objects, svc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateKubernetesObjects(name, service, objects)
|
||||||
|
|
||||||
allobjects = append(allobjects, objects...)
|
allobjects = append(allobjects, objects...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -78,6 +78,9 @@ func (k *OpenShift) Transform(komposeObject kobject.KomposeObject, opt kobject.C
|
|||||||
svc := kubernetes.CreateService(name, service, objects)
|
svc := kubernetes.CreateService(name, service, objects)
|
||||||
objects = append(objects, svc)
|
objects = append(objects, svc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kubernetes.UpdateKubernetesObjects(name, service, objects)
|
||||||
|
|
||||||
allobjects = append(allobjects, objects...)
|
allobjects = append(allobjects, objects...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user