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 {
|
||||
TmpVolumesMount, TmpVolumes := k.ConfigTmpfs(name, service)
|
||||
|
||||
for _, volume := range TmpVolumes {
|
||||
volumes = append(volumes, volume)
|
||||
}
|
||||
for _, vMount := range TmpVolumesMount {
|
||||
volumesMount = append(volumesMount, vMount)
|
||||
}
|
||||
volumes = append(volumes, TmpVolumes...)
|
||||
|
||||
volumesMount = append(volumesMount, TmpVolumesMount...)
|
||||
|
||||
}
|
||||
|
||||
@ -411,7 +408,7 @@ func (k *Kubernetes) UpdateKubernetesObjects(name string, service kobject.Servic
|
||||
|
||||
// Setup security context
|
||||
securityContext := &api.SecurityContext{}
|
||||
if service.Privileged == true {
|
||||
if service.Privileged {
|
||||
securityContext.Privileged = &service.Privileged
|
||||
}
|
||||
if service.User != "" {
|
||||
|
||||
@ -203,7 +203,7 @@ func TestTransformWithPid(t *testing.T) {
|
||||
for _, obj := range objects {
|
||||
if deploy, ok := obj.(*extensions.Deployment); ok {
|
||||
hostPid := deploy.Spec.Template.Spec.SecurityContext.HostPID
|
||||
if hostPid != true {
|
||||
if !hostPid {
|
||||
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.Spec.Template.Spec.SecurityContext != nil {
|
||||
hostPid := deploy.Spec.Template.Spec.SecurityContext.HostPID
|
||||
if hostPid != false {
|
||||
if hostPid {
|
||||
t.Errorf("Pid in ServiceConfig is not matching HostPID in PodSpec")
|
||||
}
|
||||
}
|
||||
@ -272,7 +272,7 @@ func TestIsDir(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(errors.Wrap(err, "isDir failed"))
|
||||
}
|
||||
if output != true {
|
||||
if !output {
|
||||
t.Errorf("directory %v exists but isDir() returned %v", tempDir, output)
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ func TestIsDir(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(errors.Wrap(err, "isDir failed"))
|
||||
}
|
||||
if output != false {
|
||||
if 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 {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@ -180,7 +180,7 @@ func checkPodTemplate(config kobject.ServiceConfig, template api.PodTemplateSpec
|
||||
|
||||
func privilegedNilOrFalse(template api.PodTemplateSpec) bool {
|
||||
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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user