mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2026-02-14 18:10:00 +00:00
Merge branch 'master' into master
This commit is contained in:
@@ -29,24 +29,6 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
apiserverBin string
|
||||
apiserverConf string
|
||||
schedulerBin string
|
||||
schedulerConf string
|
||||
controllerManagerBin string
|
||||
controllerManagerConf string
|
||||
config string
|
||||
etcdBin string
|
||||
etcdConf string
|
||||
flanneldBin string
|
||||
flanneldConf string
|
||||
kubeletBin string
|
||||
kubeletConf string
|
||||
proxyBin string
|
||||
proxyConf string
|
||||
fedApiserverBin string
|
||||
fedControllerManagerBin string
|
||||
|
||||
errmsgs string
|
||||
)
|
||||
|
||||
@@ -71,7 +53,9 @@ func runChecks(t check.NodeType) {
|
||||
// Get the set of exectuables and config files we care about on this type of node. This also
|
||||
// checks that the executables we need for the node type are running.
|
||||
binmap := getBinaries(typeConf)
|
||||
confmap := getConfigFiles(typeConf)
|
||||
confmap := getConfigFiles(typeConf, "conf")
|
||||
podspecmap := getConfigFiles(typeConf, "podspec")
|
||||
unitfilemap := getConfigFiles(typeConf, "unitfile")
|
||||
|
||||
switch t {
|
||||
case check.MASTER:
|
||||
@@ -93,6 +77,8 @@ func runChecks(t check.NodeType) {
|
||||
s := string(in)
|
||||
s = makeSubstitutions(s, "bin", binmap)
|
||||
s = makeSubstitutions(s, "conf", confmap)
|
||||
s = makeSubstitutions(s, "podspec", podspecmap)
|
||||
s = makeSubstitutions(s, "unitfile", unitfilemap)
|
||||
|
||||
glog.V(1).Info(fmt.Sprintf("Using config file: %s\n", viper.ConfigFileUsed()))
|
||||
glog.V(1).Info(fmt.Sprintf("Using benchmark file: %s\n", path))
|
||||
|
||||
10
cmd/util.go
10
cmd/util.go
@@ -117,7 +117,9 @@ func getBinaries(v *viper.Viper) map[string]string {
|
||||
}
|
||||
|
||||
// getConfigFiles finds which of the set of candidate config files exist
|
||||
func getConfigFiles(v *viper.Viper) map[string]string {
|
||||
// accepts a string 't' which indicates the type of config file, conf,
|
||||
// podspec or untifile.
|
||||
func getConfigFiles(v *viper.Viper, t string) map[string]string {
|
||||
confmap := make(map[string]string)
|
||||
|
||||
for _, component := range v.GetStringSlice("components") {
|
||||
@@ -127,10 +129,10 @@ func getConfigFiles(v *viper.Viper) map[string]string {
|
||||
}
|
||||
|
||||
// See if any of the candidate config files exist
|
||||
conf := findConfigFile(s.GetStringSlice("confs"))
|
||||
conf := findConfigFile(s.GetStringSlice(t + "s"))
|
||||
if conf == "" {
|
||||
if s.IsSet("defaultconf") {
|
||||
conf = s.GetString("defaultconf")
|
||||
if s.IsSet("default" + t) {
|
||||
conf = s.GetString("default" + t)
|
||||
glog.V(2).Info(fmt.Sprintf("Using default config file name '%s' for component %s", conf, component))
|
||||
} else {
|
||||
// Default the config file name that we'll substitute to the name of the component
|
||||
|
||||
@@ -282,7 +282,7 @@ func TestGetConfigFiles(t *testing.T) {
|
||||
e = c.statResults
|
||||
eIndex = 0
|
||||
|
||||
m := getConfigFiles(v)
|
||||
m := getConfigFiles(v, "conf")
|
||||
if !reflect.DeepEqual(m, c.exp) {
|
||||
t.Fatalf("Got %v\nExpected %v", m, c.exp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user