mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2025-01-03 04:10:55 +00:00
Rename warning printing functions.
printlnWarn: prints warning with a newline. sprintWarn: returns an optionally contextualized warning string.
This commit is contained in:
parent
82c92e0078
commit
7bb66dd2da
16
cmd/util.go
16
cmd/util.go
@ -21,14 +21,14 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func printWarn(msg string) {
|
func printlnWarn(msg string) {
|
||||||
fmt.Fprintf(os.Stderr, "[%s] %s\n",
|
fmt.Fprintf(os.Stderr, "[%s] %s\n",
|
||||||
colors[check.WARN].Sprintf("%s", check.WARN),
|
colors[check.WARN].Sprintf("%s", check.WARN),
|
||||||
msg,
|
msg,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func printWarn(msg string) string {
|
func sprintlnWarn(msg string) string {
|
||||||
return fmt.Sprintf("[%s] %s",
|
return fmt.Sprintf("[%s] %s",
|
||||||
colors[check.WARN].Sprintf("%s", check.WARN),
|
colors[check.WARN].Sprintf("%s", check.WARN),
|
||||||
msg,
|
msg,
|
||||||
@ -75,7 +75,7 @@ func verifyConf(confPath ...string) {
|
|||||||
|
|
||||||
if len(missing) > 0 {
|
if len(missing) > 0 {
|
||||||
missing = strings.Trim(missing, ", ")
|
missing = strings.Trim(missing, ", ")
|
||||||
printWarn(fmt.Sprintf("Missing kubernetes config files: %s", missing))
|
printlnWarn(fmt.Sprintf("Missing kubernetes config files: %s", missing))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -114,12 +114,12 @@ func verifyBin(binPath ...string) {
|
|||||||
|
|
||||||
if len(missing) > 0 {
|
if len(missing) > 0 {
|
||||||
missing = strings.Trim(missing, ", ")
|
missing = strings.Trim(missing, ", ")
|
||||||
printWarn(fmt.Sprintf("Missing kubernetes binaries: %s", missing))
|
printlnWarn(fmt.Sprintf("Missing kubernetes binaries: %s", missing))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(notRunning) > 0 {
|
if len(notRunning) > 0 {
|
||||||
notRunning = strings.Trim(notRunning, ", ")
|
notRunning = strings.Trim(notRunning, ", ")
|
||||||
printWarn(fmt.Sprintf("Kubernetes binaries not running: %s", notRunning))
|
printlnWarn(fmt.Sprintf("Kubernetes binaries not running: %s", notRunning))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,19 +129,19 @@ func verifyKubeVersion(b string) {
|
|||||||
|
|
||||||
_, err := exec.LookPath(b)
|
_, err := exec.LookPath(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continueWithError(err, printfWarn("Kubernetes version check skipped"))
|
continueWithError(err, sprintlnWarn("Kubernetes version check skipped"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command(b, "--version")
|
cmd := exec.Command(b, "--version")
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continueWithError(err, printfWarn("Kubernetes version check skipped"))
|
continueWithError(err, sprintlnWarn("Kubernetes version check skipped"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
matched := strings.Contains(string(out), kubeVersion)
|
matched := strings.Contains(string(out), kubeVersion)
|
||||||
if !matched {
|
if !matched {
|
||||||
printWarn(fmt.Sprintf("Unsupported kubernetes version: %s", out))
|
printlnWarn(fmt.Sprintf("Unsupported kubernetes version: %s", out))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user