Skip to content

Commit

Permalink
fix for static mode extra-args
Browse files Browse the repository at this point in the history
Signed-off-by: erikbaranowski <[email protected]>
  • Loading branch information
erikbaranowski committed Dec 15, 2023
1 parent 078e736 commit 898508a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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

0 comments on commit 898508a

Please sign in to comment.