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

fix for static mode extra-args #5989

Merged
merged 1 commit into from
Dec 15, 2023
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
10 changes: 8 additions & 2 deletions cmd/internal/flowmode/cmd_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func parseExtraArgs(extraArgs string) ([]string, error) {
}

arguments := strings.Fields(extraArgs)
for _, arg := range arguments {
for i, arg := range arguments {
fs := pflag.NewFlagSet("extra-args", pflag.ExitOnError)
fs.ParseErrorsWhitelist.UnknownFlags = true
keyStartIndex := 0
Expand Down Expand Up @@ -226,7 +226,13 @@ func parseExtraArgs(extraArgs string) ([]string, error) {
if keyStartIndex == 2 {
fs.StringVar(&result[lastIndex], key, result[lastIndex], "")
} else {
fs.StringVarP(&result[lastIndex], "", key, result[lastIndex], "")
// static mode uses keys with a single dash. We need to sanitize them here.
if len(key) != 1 {
arguments[i] = "-" + arguments[i]
fs.StringVar(&result[lastIndex], key, result[lastIndex], "")
} else {
fs.StringVarP(&result[lastIndex], "", key, result[lastIndex], "")
}
}

// We must parse the flag here because the pointer to the array element
Expand Down
5 changes: 5 additions & 0 deletions cmd/internal/flowmode/cmd_convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func TestParseExtraArgs(t *testing.T) {
}

var testCases = []testCase{
{
name: "integrations next with env vars",
extraArgs: "-enable-features=integrations-next -config.expand-env",
expected: []string{"-enable-features", "integrations-next", "-config.expand-env"},
},
{
name: "longhand",
extraArgs: "--key=value",
Expand Down