mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2024-11-21 23:58:06 +00:00
Fix the --exit-code
flag doesn't work when run with subcommand (#1084)
This commit is contained in:
parent
9119968940
commit
d232ae0fb9
@ -16,6 +16,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/aquasecurity/kube-bench/check"
|
||||
"github.com/spf13/cobra"
|
||||
@ -36,6 +37,7 @@ var masterCmd = &cobra.Command{
|
||||
filename := loadConfig(check.MASTER, bv)
|
||||
runChecks(check.MASTER, filename, detecetedKubeVersion)
|
||||
writeOutput(controlsCollection)
|
||||
os.Exit(exitCodeSelection(controlsCollection))
|
||||
},
|
||||
Deprecated: "this command will be retired soon. Please use the `run` command with `--targets=master` instead.",
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/aquasecurity/kube-bench/check"
|
||||
"github.com/spf13/cobra"
|
||||
@ -36,6 +37,7 @@ var nodeCmd = &cobra.Command{
|
||||
filename := loadConfig(check.NODE, bv)
|
||||
runChecks(check.NODE, filename, detecetedKubeVersion)
|
||||
writeOutput(controlsCollection)
|
||||
os.Exit(exitCodeSelection(controlsCollection))
|
||||
},
|
||||
Deprecated: "this command will be retired soon. Please use the `run` command with `--targets=node` instead.",
|
||||
}
|
||||
|
@ -136,8 +136,7 @@ var RootCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
writeOutput(controlsCollection)
|
||||
exitCode := exitCodeSelection(controlsCollection)
|
||||
os.Exit(exitCode)
|
||||
os.Exit(exitCodeSelection(controlsCollection))
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -54,13 +54,15 @@ var runCmd = &cobra.Command{
|
||||
path := filepath.Join(cfgDir, bv)
|
||||
err = mergeConfig(path)
|
||||
if err != nil {
|
||||
fmt.Printf("Error in mergeConfig: %v\n", err)
|
||||
exitWithError(fmt.Errorf("Error in mergeConfig: %v\n", err))
|
||||
}
|
||||
|
||||
err = run(targets, bv)
|
||||
if err != nil {
|
||||
fmt.Printf("Error in run: %v\n", err)
|
||||
exitWithError(fmt.Errorf("Error in run: %v\n", err))
|
||||
}
|
||||
|
||||
os.Exit(exitCodeSelection(controlsCollection))
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user