mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2025-02-16 17:42:05 +00:00
Code quality improvements (#677)
* Code quality improvements such - 1. Improves empty string test (len vs str == "") 2. Converts fmt.Sprintf to string literal and Printf to Print where possible (as the dynamic args are missing!) * Delete .deepsource.toml Co-authored-by: DeepSource Bot <bot@deepsource.io> Co-authored-by: Liz Rice <liz@lizrice.com>
This commit is contained in:
parent
772839fc92
commit
33f6773a43
@ -105,7 +105,7 @@ func (c *Check) run() State {
|
|||||||
// Since this is an Scored check
|
// Since this is an Scored check
|
||||||
// without tests return a 'WARN' to alert
|
// without tests return a 'WARN' to alert
|
||||||
// the user that this check needs attention
|
// the user that this check needs attention
|
||||||
if c.Scored && len(strings.TrimSpace(c.Type)) == 0 && c.Tests == nil {
|
if c.Scored && strings.TrimSpace(c.Type) == "" && c.Tests == nil {
|
||||||
c.Reason = "There are no tests"
|
c.Reason = "There are no tests"
|
||||||
c.State = WARN
|
c.State = WARN
|
||||||
return c.State
|
return c.State
|
||||||
|
@ -411,7 +411,7 @@ func writeOutputToFile(output string, outputFile string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printOutput(output string, outputFile string) {
|
func printOutput(output string, outputFile string) {
|
||||||
if len(outputFile) == 0 {
|
if outputFile == "" {
|
||||||
fmt.Println(output)
|
fmt.Println(output)
|
||||||
} else {
|
} else {
|
||||||
err := writeOutputToFile(output, outputFile)
|
err := writeOutputToFile(output, outputFile)
|
||||||
|
@ -136,7 +136,7 @@ func loadCertficate(certFile string) (*tls.Certificate, error) {
|
|||||||
return nil, fmt.Errorf("unable to Decode certificate")
|
return nil, fmt.Errorf("unable to Decode certificate")
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(2).Info(fmt.Sprintf("Loading CA certificate"))
|
glog.V(2).Info("Loading CA certificate")
|
||||||
tlsCert.Certificate = append(tlsCert.Certificate, block.Bytes)
|
tlsCert.Certificate = append(tlsCert.Certificate, block.Bytes)
|
||||||
return &tlsCert, nil
|
return &tlsCert, nil
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ func getKubernetesURL() string {
|
|||||||
return fmt.Sprintf("https://%s:%s/version", k8sHost, k8sPort)
|
return fmt.Sprintf("https://%s:%s/version", k8sHost, k8sPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(2).Info(fmt.Sprintf("KUBE_BENCH_K8S_ENV is set, but environment variables KUBERNETES_SERVICE_HOST or KUBERNETES_SERVICE_PORT_HTTPS are not set"))
|
glog.V(2).Info("KUBE_BENCH_K8S_ENV is set, but environment variables KUBERNETES_SERVICE_HOST or KUBERNETES_SERVICE_PORT_HTTPS are not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
return k8sVersionURL
|
return k8sVersionURL
|
||||||
|
@ -368,7 +368,7 @@ func makeSubstitutions(s string, ext string, m map[string]string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isEmpty(str string) bool {
|
func isEmpty(str string) bool {
|
||||||
return len(strings.TrimSpace(str)) == 0
|
return strings.TrimSpace(str) == ""
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ func findPodForJob(clientset *kubernetes.Clientset, jobName string, duration tim
|
|||||||
|
|
||||||
if cp.Status.Phase == apiv1.PodFailed {
|
if cp.Status.Phase == apiv1.PodFailed {
|
||||||
fmt.Printf("pod (%s) - %s - retrying...\n", cp.Name, cp.Status.Phase)
|
fmt.Printf("pod (%s) - %s - retrying...\n", cp.Name, cp.Status.Phase)
|
||||||
fmt.Printf(getPodLogs(clientset, &cp))
|
fmt.Print(getPodLogs(clientset, &cp))
|
||||||
failedPods[cp.Name] = struct{}{}
|
failedPods[cp.Name] = struct{}{}
|
||||||
break podfailed
|
break podfailed
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user