diff --git a/cmd/internal/flowmode/cmd_convert.go b/cmd/internal/flowmode/cmd_convert.go index bb7f11cc9c61..01e03a08002e 100644 --- a/cmd/internal/flowmode/cmd_convert.go +++ b/cmd/internal/flowmode/cmd_convert.go @@ -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 @@ -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 diff --git a/cmd/internal/flowmode/cmd_convert_test.go b/cmd/internal/flowmode/cmd_convert_test.go index 571ea3667326..4871a8d2b977 100644 --- a/cmd/internal/flowmode/cmd_convert_test.go +++ b/cmd/internal/flowmode/cmd_convert_test.go @@ -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",