forked from LaconicNetwork/kompose
Merge pull request #703 from surajnarwade/minor_fix
Refactoring code as per gosimple check
This commit is contained in:
commit
1af8656ea0
@ -343,12 +343,9 @@ func (k *Kubernetes) UpdateKubernetesObjects(name string, service kobject.Servic
|
|||||||
if len(service.TmpFs) > 0 {
|
if len(service.TmpFs) > 0 {
|
||||||
TmpVolumesMount, TmpVolumes := k.ConfigTmpfs(name, service)
|
TmpVolumesMount, TmpVolumes := k.ConfigTmpfs(name, service)
|
||||||
|
|
||||||
for _, volume := range TmpVolumes {
|
volumes = append(volumes, TmpVolumes...)
|
||||||
volumes = append(volumes, volume)
|
|
||||||
}
|
volumesMount = append(volumesMount, TmpVolumesMount...)
|
||||||
for _, vMount := range TmpVolumesMount {
|
|
||||||
volumesMount = append(volumesMount, vMount)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +408,7 @@ func (k *Kubernetes) UpdateKubernetesObjects(name string, service kobject.Servic
|
|||||||
|
|
||||||
// Setup security context
|
// Setup security context
|
||||||
securityContext := &api.SecurityContext{}
|
securityContext := &api.SecurityContext{}
|
||||||
if service.Privileged == true {
|
if service.Privileged {
|
||||||
securityContext.Privileged = &service.Privileged
|
securityContext.Privileged = &service.Privileged
|
||||||
}
|
}
|
||||||
if service.User != "" {
|
if service.User != "" {
|
||||||
|
|||||||
@ -203,7 +203,7 @@ func TestTransformWithPid(t *testing.T) {
|
|||||||
for _, obj := range objects {
|
for _, obj := range objects {
|
||||||
if deploy, ok := obj.(*extensions.Deployment); ok {
|
if deploy, ok := obj.(*extensions.Deployment); ok {
|
||||||
hostPid := deploy.Spec.Template.Spec.SecurityContext.HostPID
|
hostPid := deploy.Spec.Template.Spec.SecurityContext.HostPID
|
||||||
if hostPid != true {
|
if !hostPid {
|
||||||
t.Errorf("Pid in ServiceConfig is not matching HostPID in PodSpec")
|
t.Errorf("Pid in ServiceConfig is not matching HostPID in PodSpec")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ func TestTransformWithInvaildPid(t *testing.T) {
|
|||||||
if deploy, ok := obj.(*extensions.Deployment); ok {
|
if deploy, ok := obj.(*extensions.Deployment); ok {
|
||||||
if deploy.Spec.Template.Spec.SecurityContext != nil {
|
if deploy.Spec.Template.Spec.SecurityContext != nil {
|
||||||
hostPid := deploy.Spec.Template.Spec.SecurityContext.HostPID
|
hostPid := deploy.Spec.Template.Spec.SecurityContext.HostPID
|
||||||
if hostPid != false {
|
if hostPid {
|
||||||
t.Errorf("Pid in ServiceConfig is not matching HostPID in PodSpec")
|
t.Errorf("Pid in ServiceConfig is not matching HostPID in PodSpec")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ func TestIsDir(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(errors.Wrap(err, "isDir failed"))
|
t.Error(errors.Wrap(err, "isDir failed"))
|
||||||
}
|
}
|
||||||
if output != true {
|
if !output {
|
||||||
t.Errorf("directory %v exists but isDir() returned %v", tempDir, output)
|
t.Errorf("directory %v exists but isDir() returned %v", tempDir, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ func TestIsDir(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(errors.Wrap(err, "isDir failed"))
|
t.Error(errors.Wrap(err, "isDir failed"))
|
||||||
}
|
}
|
||||||
if output != false {
|
if output {
|
||||||
t.Errorf("%v is a file but isDir() returned %v", tempDir, output)
|
t.Errorf("%v is a file but isDir() returned %v", tempDir, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ func TestIsDir(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(errors.Wrap(err, "isDir failed"))
|
t.Error(errors.Wrap(err, "isDir failed"))
|
||||||
}
|
}
|
||||||
if output != false {
|
if output {
|
||||||
t.Errorf("Directory %v does not exist, but isDir() returned %v", tempAbsentDirPath, output)
|
t.Errorf("Directory %v does not exist, but isDir() returned %v", tempAbsentDirPath, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -180,7 +180,7 @@ func checkPodTemplate(config kobject.ServiceConfig, template api.PodTemplateSpec
|
|||||||
|
|
||||||
func privilegedNilOrFalse(template api.PodTemplateSpec) bool {
|
func privilegedNilOrFalse(template api.PodTemplateSpec) bool {
|
||||||
return len(template.Spec.Containers) == 0 || template.Spec.Containers[0].SecurityContext == nil ||
|
return len(template.Spec.Containers) == 0 || template.Spec.Containers[0].SecurityContext == nil ||
|
||||||
template.Spec.Containers[0].SecurityContext.Privileged == nil || *template.Spec.Containers[0].SecurityContext.Privileged == false
|
template.Spec.Containers[0].SecurityContext.Privileged == nil || !*template.Spec.Containers[0].SecurityContext.Privileged
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkService(config kobject.ServiceConfig, svc *api.Service, expectedLabels map[string]string) error {
|
func checkService(config kobject.ServiceConfig, svc *api.Service, expectedLabels map[string]string) error {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user