Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release-1.21] Improved regex for double equals arguments #4508

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/configfilearg/defaultparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Test_UnitMustParse(t *testing.T) {
args: []string{"k3s", "server", "--write-kubeconfig-mode 644"},
config: "./testdata/defaultdata.yaml",
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",
Expand Down Expand Up @@ -60,7 +60,7 @@ func Test_UnitMustParse(t *testing.T) {
args: []string{"k3s", "agent"},
config: "./testdata/defaultdata.yaml",
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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/configfilearg/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
return args, err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/configfilearg/testdata/defaultdata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ token: 12345
node-label: DEAFBEEF
etcd-s3: true
etcd-s3-bucket: my-backup
notaflag : true
notaflag : true
kubelet-arg: "max-pods=999"