Skip to content

Commit

Permalink
Merge pull request #703 from surajnarwade/minor_fix
Browse files Browse the repository at this point in the history
Refactoring code as per gosimple check
  • Loading branch information
cdrage committed Jul 12, 2017
2 parents 0143dee + 8dfa0e0 commit 1af8656
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
11 changes: 4 additions & 7 deletions pkg/transformer/kubernetes/k8sutils.go
Expand Up @@ -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...)

}

Expand Down Expand Up @@ -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 != "" {
Expand Down
10 changes: 5 additions & 5 deletions pkg/transformer/kubernetes/k8sutils_test.go
Expand Up @@ -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")
}
}
Expand Down Expand Up @@ -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")
}
}
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/transformer/kubernetes/kubernetes_test.go
Expand Up @@ -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 {
Expand Down

0 comments on commit 1af8656

Please sign in to comment.