@@ -2,28 +2,28 @@ package generator
22
33import (
44 "bytes"
5- "fmt"
65 "encoding/json"
7-
6+ "fmt"
7+
88 "github.com/ghodss/yaml"
99
10- "github.com/sysdiglabs/kube-psp-advisor/advisor/types"
11- "github.com/sysdiglabs/kube-psp-advisor/utils"
10+ "github.com/sysdiglabs/kube-psp-advisor/advisor/types"
11+ "github.com/sysdiglabs/kube-psp-advisor/utils"
1212
13- v1 "k8s.io/api/core/v1"
1413 appsv1 "k8s.io/api/apps/v1"
15- v1beta1 "k8s.io/api/policy/v1beta1"
1614 batch "k8s.io/api/batch/v1"
1715 batchv1beta1 "k8s.io/api/batch/v1beta1"
18-
16+ v1 "k8s.io/api/core/v1"
17+ v1beta1 "k8s.io/api/policy/v1beta1"
18+
1919 "reflect"
2020 "strings"
2121 "time"
2222)
2323
2424const (
2525 volumeTypeSecret = "secret"
26- )
26+ )
2727
2828type Generator struct {
2929}
@@ -313,7 +313,7 @@ func (pg *Generator) GeneratePSP(
313313 pssList []types.PodSecuritySpec ,
314314 namespace string ,
315315 serverGitVersion string ) * v1beta1.PodSecurityPolicy {
316-
316+
317317 var ns string
318318 // no PSP will be generated if no security spec is provided
319319 if len (cssList ) == 0 && len (pssList ) == 0 {
@@ -507,11 +507,13 @@ func (pg *Generator) fromPodObj(metadata types.Metadata, spec v1.PodSpec) (strin
507507 // 1.11, which allows enforcing ReadOnly.
508508 psp := pg .GeneratePSP (cssList , pssList , "default" , types .Version1_11 )
509509
510- pspJson , err := json .Marshal (psp ); if err != nil {
510+ pspJson , err := json .Marshal (psp )
511+ if err != nil {
511512 return "" , fmt .Errorf ("Could not marshal resulting PSP: %v" , err )
512513 }
513514
514- pspYaml , err := yaml .JSONToYAML (pspJson ); if err != nil {
515+ pspYaml , err := yaml .JSONToYAML (pspJson )
516+ if err != nil {
515517 return "" , fmt .Errorf ("Could not convert resulting PSP to Json: %v" , err )
516518 }
517519
@@ -576,7 +578,8 @@ func (pg *Generator) fromPod(pod *v1.Pod) (string, error) {
576578
577579func (pg * Generator ) FromPodObjString (podObjString string ) (string , error ) {
578580
579- podObjJson , err := yaml .YAMLToJSON ([]byte (podObjString )); if err != nil {
581+ podObjJson , err := yaml .YAMLToJSON ([]byte (podObjString ))
582+ if err != nil {
580583 return "" , fmt .Errorf ("Could not parse pod Object: %v" , err )
581584 }
582585
@@ -644,4 +647,3 @@ func (pg *Generator) FromPodObjString(podObjString string) (string, error) {
644647
645648 return "" , fmt .Errorf ("K8s Object not one of supported types" )
646649}
647-
0 commit comments