diff --git a/pkg/minikube/bootstrapper/bsutil/extraconfig.go b/pkg/minikube/bootstrapper/bsutil/extraconfig.go index 47b61d92e4..775f044414 100644 --- a/pkg/minikube/bootstrapper/bsutil/extraconfig.go +++ b/pkg/minikube/bootstrapper/bsutil/extraconfig.go @@ -134,18 +134,18 @@ func defaultOptionsForComponentAndVersion(component string, version semver.Versi // newComponentOptions creates a new componentOptions func newComponentOptions(opts config.ExtraOptionSlice, version semver.Version, featureGates string, cp config.Node) ([]componentOptions, error) { var kubeadmExtraArgs []componentOptions - for _, extraOpt := range opts { - if _, ok := componentToKubeadmConfigKey[extraOpt.Component]; !ok { - return nil, fmt.Errorf("unknown component %q. valid components are: %v", extraOpt.Component, componentToKubeadmConfigKey) - } - } - keys := []string{} for k := range componentToKubeadmConfigKey { keys = append(keys, k) } sort.Strings(keys) + for _, extraOpt := range opts { + if _, ok := componentToKubeadmConfigKey[extraOpt.Component]; !ok { + return nil, fmt.Errorf("unknown component %q. valid components are: %v", extraOpt.Component, keys) + } + } + for _, component := range keys { kubeadmComponentKey := componentToKubeadmConfigKey[component] if kubeadmComponentKey == "" {