mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2024-11-25 17:38:21 +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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/aquasecurity/kube-bench/check"
|
"github.com/aquasecurity/kube-bench/check"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -36,6 +37,7 @@ var masterCmd = &cobra.Command{
|
|||||||
filename := loadConfig(check.MASTER, bv)
|
filename := loadConfig(check.MASTER, bv)
|
||||||
runChecks(check.MASTER, filename, detecetedKubeVersion)
|
runChecks(check.MASTER, filename, detecetedKubeVersion)
|
||||||
writeOutput(controlsCollection)
|
writeOutput(controlsCollection)
|
||||||
|
os.Exit(exitCodeSelection(controlsCollection))
|
||||||
},
|
},
|
||||||
Deprecated: "this command will be retired soon. Please use the `run` command with `--targets=master` instead.",
|
Deprecated: "this command will be retired soon. Please use the `run` command with `--targets=master` instead.",
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/aquasecurity/kube-bench/check"
|
"github.com/aquasecurity/kube-bench/check"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -36,6 +37,7 @@ var nodeCmd = &cobra.Command{
|
|||||||
filename := loadConfig(check.NODE, bv)
|
filename := loadConfig(check.NODE, bv)
|
||||||
runChecks(check.NODE, filename, detecetedKubeVersion)
|
runChecks(check.NODE, filename, detecetedKubeVersion)
|
||||||
writeOutput(controlsCollection)
|
writeOutput(controlsCollection)
|
||||||
|
os.Exit(exitCodeSelection(controlsCollection))
|
||||||
},
|
},
|
||||||
Deprecated: "this command will be retired soon. Please use the `run` command with `--targets=node` instead.",
|
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)
|
writeOutput(controlsCollection)
|
||||||
exitCode := exitCodeSelection(controlsCollection)
|
os.Exit(exitCodeSelection(controlsCollection))
|
||||||
os.Exit(exitCode)
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,13 +54,15 @@ var runCmd = &cobra.Command{
|
|||||||
path := filepath.Join(cfgDir, bv)
|
path := filepath.Join(cfgDir, bv)
|
||||||
err = mergeConfig(path)
|
err = mergeConfig(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error in mergeConfig: %v\n", err)
|
exitWithError(fmt.Errorf("Error in mergeConfig: %v\n", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
err = run(targets, bv)
|
err = run(targets, bv)
|
||||||
if err != nil {
|
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