forked from LaconicNetwork/kompose
Merge pull request #105 from janetkuo/convert-container-name-args
Support container name and args in kompose convert
This commit is contained in:
commit
e36f38446b
@ -259,8 +259,12 @@ func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject.
|
||||
|
||||
// fillTemplate fills the pod template with the value calculated from config
|
||||
fillTemplate := func(template *api.PodTemplateSpec) {
|
||||
if len(service.ContainerName) > 0 {
|
||||
template.Spec.Containers[0].Name = service.ContainerName
|
||||
}
|
||||
template.Spec.Containers[0].Env = envs
|
||||
template.Spec.Containers[0].Command = cmds
|
||||
template.Spec.Containers[0].Args = service.Args
|
||||
template.Spec.Containers[0].WorkingDir = service.WorkingDir
|
||||
template.Spec.Containers[0].VolumeMounts = volumesMount
|
||||
template.Spec.Volumes = volumes
|
||||
|
||||
@ -132,10 +132,9 @@ func checkPodTemplate(config kobject.ServiceConfig, template api.PodTemplateSpec
|
||||
return fmt.Errorf("Failed to set container: %#v vs. %#v", config, template)
|
||||
}
|
||||
container := template.Spec.Containers[0]
|
||||
// FIXME: we should support container name and uncomment this test
|
||||
//if config.ContainerName != container.Name {
|
||||
//return fmt.Errorf("Found different container name: %v vs. %v", config.ContainerName, container.Name)
|
||||
//}
|
||||
if config.ContainerName != container.Name {
|
||||
return fmt.Errorf("Found different container name: %v vs. %v", config.ContainerName, container.Name)
|
||||
}
|
||||
if config.Image != container.Image {
|
||||
return fmt.Errorf("Found different container image: %v vs. %v", config.Image, container.Image)
|
||||
}
|
||||
@ -151,10 +150,9 @@ func checkPodTemplate(config kobject.ServiceConfig, template api.PodTemplateSpec
|
||||
if config.WorkingDir != container.WorkingDir {
|
||||
return fmt.Errorf("Found different container WorkingDir: %#v vs. %#v", config.WorkingDir, container.WorkingDir)
|
||||
}
|
||||
// FIXME: we should support container args and uncomment this test
|
||||
//if !equalStringSlice(config.Args, container.Args) {
|
||||
//return fmt.Errorf("Found different container args: %#v vs. %#v", config.Args, container.Args)
|
||||
//}
|
||||
if !equalStringSlice(config.Args, container.Args) {
|
||||
return fmt.Errorf("Found different container args: %#v vs. %#v", config.Args, container.Args)
|
||||
}
|
||||
if len(template.Spec.Volumes) == 0 || len(template.Spec.Volumes[0].Name) == 0 ||
|
||||
(template.Spec.Volumes[0].VolumeSource.HostPath == nil && template.Spec.Volumes[0].VolumeSource.EmptyDir == nil) {
|
||||
return fmt.Errorf("Found incorrect volumes: %v vs. %#v", config.Volumes, template.Spec.Volumes)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user