Unverified Commit ef263bd2 authored by Derek Nola's avatar Derek Nola Committed by GitHub

Improved regex for double equals arguments (#4505)

parent 535a9196
...@@ -29,7 +29,7 @@ func Test_UnitMustParse(t *testing.T) { ...@@ -29,7 +29,7 @@ func Test_UnitMustParse(t *testing.T) {
args: []string{"k3s", "server", "--write-kubeconfig-mode 644"}, args: []string{"k3s", "server", "--write-kubeconfig-mode 644"},
config: "./testdata/defaultdata.yaml", config: "./testdata/defaultdata.yaml",
want: []string{"k3s", "server", "--token=12345", "--node-label=DEAFBEEF", want: []string{"k3s", "server", "--token=12345", "--node-label=DEAFBEEF",
"--etcd-s3=true", "--etcd-s3-bucket=my-backup", "--write-kubeconfig-mode 644"}, "--etcd-s3=true", "--etcd-s3-bucket=my-backup", "--kubelet-arg=max-pods=999", "--write-kubeconfig-mode 644"},
}, },
{ {
name: "Basic etcd-snapshot", name: "Basic etcd-snapshot",
...@@ -60,7 +60,7 @@ func Test_UnitMustParse(t *testing.T) { ...@@ -60,7 +60,7 @@ func Test_UnitMustParse(t *testing.T) {
args: []string{"k3s", "agent"}, args: []string{"k3s", "agent"},
config: "./testdata/defaultdata.yaml", config: "./testdata/defaultdata.yaml",
want: []string{"k3s", "agent", "--token=12345", "--node-label=DEAFBEEF", want: []string{"k3s", "agent", "--token=12345", "--node-label=DEAFBEEF",
"--etcd-s3=true", "--etcd-s3-bucket=my-backup", "--notaflag=true"}, "--etcd-s3=true", "--etcd-s3-bucket=my-backup", "--notaflag=true", "--kubelet-arg=max-pods=999"},
}, },
} }
for _, tt := range tests { for _, tt := range tests {
......
...@@ -78,7 +78,7 @@ func (p *Parser) stripInvalidFlags(command string, args []string) ([]string, err ...@@ -78,7 +78,7 @@ func (p *Parser) stripInvalidFlags(command string, args []string) ([]string, err
} }
} }
re, err := regexp.Compile("^-+(.+)=") re, err := regexp.Compile("^-+([^=]*)=")
if err != nil { if err != nil {
return args, err return args, err
} }
......
...@@ -2,4 +2,5 @@ token: 12345 ...@@ -2,4 +2,5 @@ token: 12345
node-label: DEAFBEEF node-label: DEAFBEEF
etcd-s3: true etcd-s3: true
etcd-s3-bucket: my-backup etcd-s3-bucket: my-backup
notaflag : true notaflag : true
\ No newline at end of file kubelet-arg: "max-pods=999"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment