Replace whitelist/blacklist withallow/deny
parent
fa0812c8f0
commit
a60c7d3d1d
|
@ -49,12 +49,6 @@ var dirs = [...]string{
|
|||
localpath.MakeMiniPath("logs"),
|
||||
}
|
||||
|
||||
var viperWhiteList = []string{
|
||||
"alsologtostderr",
|
||||
"log_dir",
|
||||
"v",
|
||||
}
|
||||
|
||||
// RootCmd represents the base command when called without any subcommands
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "minikube",
|
||||
|
@ -148,7 +142,7 @@ func usageTemplate() string {
|
|||
// Handle config values for flags used in external packages (e.g. glog)
|
||||
// by setting them directly, using values from viper when not passed in as args
|
||||
func setFlagsUsingViper() {
|
||||
for _, config := range viperWhiteList {
|
||||
for _, config := range []string{"alsologtostderr", "log_dir", "v"} {
|
||||
var a = pflag.Lookup(config)
|
||||
viper.SetDefault(a.Name, a.DefValue)
|
||||
// If the flag is set, override viper value
|
||||
|
|
|
@ -865,10 +865,10 @@ func validateFlags(cmd *cobra.Command, drvName string) {
|
|||
}
|
||||
}
|
||||
|
||||
// check that kubeadm extra args contain only whitelisted parameters
|
||||
// check that kubeadm extra args contain only allowed parameters
|
||||
for param := range config.ExtraOptions.AsMap().Get(bsutil.Kubeadm) {
|
||||
if !config.ContainsParam(bsutil.KubeadmExtraArgsWhitelist[bsutil.KubeadmCmdParam], param) &&
|
||||
!config.ContainsParam(bsutil.KubeadmExtraArgsWhitelist[bsutil.KubeadmConfigParam], param) {
|
||||
if !config.ContainsParam(bsutil.KubeadmExtraArgsAllow[bsutil.KubeadmCmdParam], param) &&
|
||||
!config.ContainsParam(bsutil.KubeadmExtraArgsAllow[bsutil.KubeadmConfigParam], param) {
|
||||
exit.UsageT("Sorry, the kubeadm.{{.parameter_name}} parameter is currently not supported by --extra-config", out.V{"parameter_name": param})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ func initKubernetesFlags() {
|
|||
`A set of key=value pairs that describe configuration that may be passed to different components.
|
||||
The key should be '.' separated, and the first part before the dot is the component to apply the configuration to.
|
||||
Valid components are: kubelet, kubeadm, apiserver, controller-manager, etcd, proxy, scheduler
|
||||
Valid kubeadm parameters: `+fmt.Sprintf("%s, %s", strings.Join(bsutil.KubeadmExtraArgsWhitelist[bsutil.KubeadmCmdParam], ", "), strings.Join(bsutil.KubeadmExtraArgsWhitelist[bsutil.KubeadmConfigParam], ",")))
|
||||
Valid kubeadm parameters: `+fmt.Sprintf("%s, %s", strings.Join(bsutil.KubeadmExtraArgsAllow[bsutil.KubeadmCmdParam], ", "), strings.Join(bsutil.KubeadmExtraArgsAllow[bsutil.KubeadmConfigParam], ",")))
|
||||
startCmd.Flags().String(featureGates, "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
|
||||
startCmd.Flags().String(dnsDomain, constants.ClusterDNSDomain, "The cluster dns domain name used in the Kubernetes cluster")
|
||||
startCmd.Flags().Int(apiServerPort, constants.APIServerPort, "The apiserver listening port")
|
||||
|
|
33
go.mod
33
go.mod
|
@ -3,7 +3,7 @@ module k8s.io/minikube
|
|||
go 1.13
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.45.1
|
||||
cloud.google.com/go/storage v1.8.0
|
||||
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5 // indirect
|
||||
github.com/Parallels/docker-machine-parallels v1.3.0
|
||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
|
||||
|
@ -22,20 +22,17 @@ require (
|
|||
github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect
|
||||
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
|
||||
github.com/go-ole/go-ole v1.2.4 // indirect
|
||||
github.com/gogo/protobuf v1.3.1 // indirect
|
||||
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||
github.com/google/go-cmp v0.4.0
|
||||
github.com/google/go-cmp v0.4.1
|
||||
github.com/google/go-containerregistry v0.0.0-20200601195303-96cf69f03a3c
|
||||
github.com/google/go-github v17.0.0+incompatible
|
||||
github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible // indirect
|
||||
github.com/google/slowjam v0.0.0-20200530021616-df27e642fe7b
|
||||
github.com/googleapis/gnostic v0.3.0 // indirect
|
||||
github.com/hashicorp/go-getter v1.4.0
|
||||
github.com/hashicorp/go-retryablehttp v0.5.4
|
||||
github.com/hashicorp/go-retryablehttp v0.6.6
|
||||
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 // indirect
|
||||
github.com/hooklift/iso9660 v0.0.0-20170318115843-1cf07e5970d8
|
||||
github.com/imdario/mergo v0.3.8 // indirect
|
||||
github.com/intel-go/cpuid v0.0.0-20181003105527-1a4a6f06a1c6 // indirect
|
||||
github.com/johanneswuerbach/nfsexports v0.0.0-20200318065542-c48c3734757f
|
||||
github.com/juju/clock v0.0.0-20190205081909-9c5c9712527c
|
||||
|
@ -47,19 +44,15 @@ require (
|
|||
github.com/juju/utils v0.0.0-20180820210520-bf9cc5bdd62d // indirect
|
||||
github.com/juju/version v0.0.0-20180108022336-b64dbd566305 // indirect
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
|
||||
github.com/kr/pretty v0.2.0 // indirect
|
||||
github.com/libvirt/libvirt-go v3.4.0+incompatible
|
||||
github.com/machine-drivers/docker-machine-driver-vmware v0.1.1
|
||||
github.com/mattn/go-isatty v0.0.12
|
||||
github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936
|
||||
github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b
|
||||
github.com/moby/hyperkit v0.0.0-20171020124204-a12cd7250bcd
|
||||
github.com/olekukonko/tablewriter v0.0.4
|
||||
github.com/onsi/ginkgo v1.10.3 // indirect
|
||||
github.com/onsi/gomega v1.7.1 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1
|
||||
github.com/otiai10/copy v1.0.2
|
||||
github.com/pborman/uuid v1.2.0
|
||||
github.com/pelletier/go-toml v1.6.0 // indirect
|
||||
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
|
||||
github.com/pkg/browser v0.0.0-20160118053552-9302be274faa
|
||||
github.com/pkg/errors v0.9.1
|
||||
|
@ -70,27 +63,21 @@ require (
|
|||
github.com/russross/blackfriday v1.5.3-0.20200218234912-41c5fccfd6f6 // indirect
|
||||
github.com/samalba/dockerclient v0.0.0-20160414174713-91d7393ff859 // indirect
|
||||
github.com/shirou/gopsutil v2.18.12+incompatible
|
||||
github.com/spf13/cast v1.3.1 // indirect
|
||||
github.com/spf13/cobra v1.0.0
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/spf13/viper v1.6.1
|
||||
github.com/spf13/viper v1.7.0
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||
github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f
|
||||
github.com/zchee/go-vmnet v0.0.0-20161021174912-97ebf9174097
|
||||
golang.org/x/build v0.0.0-20190927031335-2835ba2e683f
|
||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121
|
||||
golang.org/x/text v0.3.2
|
||||
google.golang.org/api v0.9.0
|
||||
google.golang.org/genproto v0.0.0-20200117163144-32f20d992d24 // indirect
|
||||
google.golang.org/grpc v1.26.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||
gopkg.in/ini.v1 v1.51.1 // indirect
|
||||
google.golang.org/api v0.25.0
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
|
||||
gopkg.in/yaml.v2 v2.2.8
|
||||
gopkg.in/yaml.v2 v2.3.0
|
||||
gotest.tools/v3 v3.0.2 // indirect
|
||||
k8s.io/api v0.17.4
|
||||
k8s.io/apimachinery v0.17.4
|
||||
|
|
|
@ -29,7 +29,7 @@ import (
|
|||
)
|
||||
|
||||
// enum to differentiate kubeadm command line parameters from kubeadm config file parameters (see the
|
||||
// KubeadmExtraArgsWhitelist variable for more info)
|
||||
// KubeadmExtraArgsAllow variable for more info)
|
||||
const (
|
||||
// KubeadmCmdParam is command parameters for kubeadm
|
||||
KubeadmCmdParam = iota
|
||||
|
@ -56,12 +56,12 @@ var componentToKubeadmConfigKey = map[string]string{
|
|||
Kubelet: "",
|
||||
}
|
||||
|
||||
// KubeadmExtraArgsWhitelist is a whitelist of supported kubeadm params that can be supplied to kubeadm through
|
||||
// KubeadmExtraArgsAllow is a list of supported kubeadm params that can be supplied to kubeadm through
|
||||
// minikube's ExtraArgs parameter. The list is split into two parts - params that can be supplied as flags on the
|
||||
// command line and params that have to be inserted into the kubeadm config file. This is because of a kubeadm
|
||||
// constraint which allows only certain params to be provided from the command line when the --config parameter
|
||||
// is specified
|
||||
var KubeadmExtraArgsWhitelist = map[int][]string{
|
||||
var KubeadmExtraArgsAllow = map[int][]string{
|
||||
KubeadmCmdParam: {
|
||||
"ignore-preflight-errors",
|
||||
"dry-run",
|
||||
|
@ -86,7 +86,7 @@ func CreateFlagsFromExtraArgs(extraOptions config.ExtraOptionSlice) string {
|
|||
// kubeadm allows only a small set of parameters to be supplied from the command line when the --config param
|
||||
// is specified, here we remove those that are not allowed
|
||||
for opt := range kubeadmExtraOpts {
|
||||
if !config.ContainsParam(KubeadmExtraArgsWhitelist[KubeadmCmdParam], opt) {
|
||||
if !config.ContainsParam(KubeadmExtraArgsAllow[KubeadmCmdParam], opt) {
|
||||
// kubeadmExtraOpts is a copy so safe to delete
|
||||
delete(kubeadmExtraOpts, opt)
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ import (
|
|||
"k8s.io/minikube/pkg/util/lock"
|
||||
)
|
||||
|
||||
// blacklist is a list of strings to explicitly omit from translation files.
|
||||
var blacklist = []string{
|
||||
// exclude is a list of strings to explicitly omit from translation files.
|
||||
var exclude = []string{
|
||||
"{{.error}}",
|
||||
"{{.url}}",
|
||||
"{{.msg}}: {{.err}}",
|
||||
|
@ -351,9 +351,9 @@ func checkString(s string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
// Don't translate blacklisted strings
|
||||
for _, b := range blacklist {
|
||||
if b == stringToTranslate {
|
||||
// Don't translate excluded strings
|
||||
for _, e := range exclude {
|
||||
if e == stringToTranslate {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
// stderrWhitelist are regular expressions acceptable to find in normal stderr
|
||||
var stderrWhitelist = []string{
|
||||
// stderrAllow are regular expressions acceptable to find in normal stderr
|
||||
var stderrAllow = []string{
|
||||
// kubectl out of date warning
|
||||
`kubectl`,
|
||||
// slow docker warning
|
||||
|
@ -38,8 +38,8 @@ var stderrWhitelist = []string{
|
|||
`cache_images.go:.*Failed to load profile`,
|
||||
}
|
||||
|
||||
// stderrWhitelistRe combines rootCauses into a single regex
|
||||
var stderrWhitelistRe = regexp.MustCompile(strings.Join(stderrWhitelist, "|"))
|
||||
// stderrAllowRe combines rootCauses into a single regex
|
||||
var stderrAllowRe = regexp.MustCompile(strings.Join(stderrAllow, "|"))
|
||||
|
||||
// TestErrorSpam asserts that there are no errors displayed
|
||||
func TestErrorSpam(t *testing.T) {
|
||||
|
@ -69,7 +69,7 @@ func TestErrorSpam(t *testing.T) {
|
|||
continue
|
||||
}
|
||||
|
||||
if stderrWhitelistRe.MatchString(line) {
|
||||
if stderrAllowRe.MatchString(line) {
|
||||
t.Logf("acceptable stderr: %q", line)
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue