Skip to content

Commit

Permalink
Extra arguments need to be quoted
Browse files Browse the repository at this point in the history
  • Loading branch information
r2d4 committed Oct 11, 2017
1 parent dd50d76 commit 967913b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
24 changes: 12 additions & 12 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ etcd:
dataDir: /data
nodeName: extra-args-minikube
apiServerExtraArgs:
fail-no-swap: true
fail-no-swap: "true"
controllerManagerExtraArgs:
kube-api-burst: 32
kube-api-burst: "32"
schedulerExtraArgs:
scheduler-name: mini-scheduler
scheduler-name: "mini-scheduler"
`,
},
{
Expand Down Expand Up @@ -128,8 +128,8 @@ etcd:
dataDir: /data
nodeName: extra-args-minikube
apiServerExtraArgs:
fail-no-swap: true
kube-api-burst: 32
fail-no-swap: "true"
kube-api-burst: "32"
`,
},
{
Expand All @@ -153,11 +153,11 @@ etcd:
dataDir: /data
nodeName: extra-args-minikube
apiServerExtraArgs:
feature-gates: HugePages=true,OtherFeature=false
feature-gates: "HugePages=true,OtherFeature=false"
controllerManagerExtraArgs:
feature-gates: HugePages=true,OtherFeature=false
feature-gates: "HugePages=true,OtherFeature=false"
schedulerExtraArgs:
feature-gates: HugePages=true,OtherFeature=false
feature-gates: "HugePages=true,OtherFeature=false"
`,
},
{
Expand Down Expand Up @@ -188,12 +188,12 @@ etcd:
dataDir: /data
nodeName: extra-args-minikube
apiServerExtraArgs:
fail-no-swap: true
feature-gates: HugePages=true,OtherFeature=false
fail-no-swap: "true"
feature-gates: "HugePages=true,OtherFeature=false"
controllerManagerExtraArgs:
feature-gates: HugePages=true,OtherFeature=false
feature-gates: "HugePages=true,OtherFeature=false"
schedulerExtraArgs:
feature-gates: HugePages=true,OtherFeature=false
feature-gates: "HugePages=true,OtherFeature=false"
`,
},
{
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/bootstrapper/kubeadm/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package kubeadm

import (
"fmt"
"html/template"
"sort"
"text/template"
)

var kubeadmConfigTemplate = template.Must(template.New("kubeadmConfigTemplate").Funcs(template.FuncMap{
Expand Down Expand Up @@ -89,7 +89,7 @@ func printMapInOrder(m map[string]string, sep string) []string {
}
sort.Strings(keys)
for i, k := range keys {
keys[i] = fmt.Sprintf("%s%s%s", k, sep, m[k])
keys[i] = fmt.Sprintf("%s%s\"%s\"", k, sep, m[k])
}
return keys
}
4 changes: 2 additions & 2 deletions pkg/minikube/bootstrapper/kubeadm/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestPrintMapInOrder(t *testing.T) {
m: map[string]string{
"a": "1",
},
expected: []string{"a: 1"},
expected: []string{`a: "1"`},
},
{
description: "two kv",
Expand All @@ -43,7 +43,7 @@ func TestPrintMapInOrder(t *testing.T) {
"b": "2",
"a": "1",
},
expected: []string{"a=1", "b=2"},
expected: []string{`a="1"`, `b="2"`},
},
{
description: "no kv",
Expand Down
5 changes: 5 additions & 0 deletions pkg/minikube/bootstrapper/kubeadm/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ var componentToKubeadmConfigKey = map[string]string{
Apiserver: "apiServerExtraArgs",
ControllerManager: "controllerManagerExtraArgs",
Scheduler: "schedulerExtraArgs",
// The Kubelet is not configured in kubeadm, only in systemd.
Kubelet: "",
}

func NewComponentExtraArgs(opts util.ExtraOptionSlice, version semver.Version, featureGates string) ([]ComponentExtraArgs, error) {
Expand All @@ -83,6 +85,9 @@ func NewComponentExtraArgs(opts util.ExtraOptionSlice, version semver.Version, f

for _, component := range keys {
kubeadmComponentKey := componentToKubeadmConfigKey[component]
if kubeadmComponentKey == "" {
continue
}
extraConfig, err := ExtraConfigForComponent(component, opts, version)
if err != nil {
return nil, errors.Wrapf(err, "getting kubeadm extra args for %s", component)
Expand Down

0 comments on commit 967913b

Please sign in to comment.