mirror of https://github.com/k3s-io/k3s
All arguments should be of the form --k=v so that bool flags will work
Previously a bool flag would be rendered as --flag false for `flag: false` which is invalid and results in the opposite of what you'd expect. Signed-off-by: Darren Shepherd <darren@rancher.com>pull/2207/head
parent
64ae6affc5
commit
289ba8df6a
|
@ -104,15 +104,11 @@ func readConfigFile(file string) (result []string, _ error) {
|
|||
|
||||
if slice, ok := v.([]interface{}); ok {
|
||||
for _, v := range slice {
|
||||
result = append(result, prefix+k, convert.ToString(v))
|
||||
result = append(result)
|
||||
result = append(result, prefix+k+"="+convert.ToString(v))
|
||||
}
|
||||
} else {
|
||||
str := convert.ToString(v)
|
||||
result = append(result, prefix+k)
|
||||
if str != "" {
|
||||
result = append(result, str)
|
||||
}
|
||||
result = append(result, prefix+k+"="+str)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -150,14 +150,15 @@ func TestConfigFile(t *testing.T) {
|
|||
|
||||
func TestParse(t *testing.T) {
|
||||
testDataOutput := []string{
|
||||
"--foo-bar", "baz",
|
||||
"--a-slice", "1",
|
||||
"--a-slice", "2",
|
||||
"--a-slice", "",
|
||||
"--a-slice", "three",
|
||||
"--isempty",
|
||||
"-c", "b",
|
||||
"--islast", "true",
|
||||
"--foo-bar=baz",
|
||||
"--a-slice=1",
|
||||
"--a-slice=2",
|
||||
"--a-slice=",
|
||||
"--a-slice=three",
|
||||
"--isempty=",
|
||||
"-c=b",
|
||||
"--isfalse=false",
|
||||
"--islast=true",
|
||||
}
|
||||
|
||||
defParser := Parser{
|
||||
|
|
|
@ -6,4 +6,5 @@ a-slice:
|
|||
- three
|
||||
isempty:
|
||||
c: b
|
||||
isfalse: false
|
||||
islast: true
|
Loading…
Reference in New Issue