-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wire up support for converting integrations-next configs to flow. (#5973
) * Wire up support for converting integrations-next configs to flow. Include a mechanism for passing command line flags to the converter from the old format. Signed-off-by: erikbaranowski <[email protected]> * Update cmd/internal/flowmode/cmd_convert.go Co-authored-by: Piotr <[email protected]> * Apply suggestions from code review Co-authored-by: Clayton Cornell <[email protected]> * Update docs/sources/flow/getting-started/migrating-from-static.md Co-authored-by: Piotr <[email protected]> --------- Signed-off-by: erikbaranowski <[email protected]> Co-authored-by: Piotr <[email protected]> Co-authored-by: Clayton Cornell <[email protected]>
- Loading branch information
1 parent
fd12c48
commit 078e736
Showing
13 changed files
with
224 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package flowmode | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestParseExtraArgs(t *testing.T) { | ||
type testCase struct { | ||
name string | ||
extraArgs string | ||
expected []string | ||
expectedError string | ||
} | ||
|
||
var testCases = []testCase{ | ||
{ | ||
name: "longhand", | ||
extraArgs: "--key=value", | ||
expected: []string{"--key", "value"}, | ||
}, | ||
{ | ||
name: "shorthand", | ||
extraArgs: "-k=value", | ||
expected: []string{"-k", "value"}, | ||
}, | ||
{ | ||
name: "bool longhand", | ||
extraArgs: "--boolVariable", | ||
expected: []string{"--boolVariable"}, | ||
}, | ||
{ | ||
name: "bool shorthand", | ||
extraArgs: "-b", | ||
expected: []string{"-b"}, | ||
}, | ||
{ | ||
name: "combo", | ||
extraArgs: "--key=value -k=value --boolVariable -b", | ||
expected: []string{"--key", "value", "-k", "value", "--boolVariable", "-b"}, | ||
}, | ||
{ | ||
name: "spaced", | ||
extraArgs: "--key value", | ||
expected: []string{"--key", "value"}, | ||
}, | ||
{ | ||
name: "value with equals", | ||
extraArgs: `--key="foo=bar"`, | ||
expected: []string{"--key", `"foo=bar"`}, | ||
}, | ||
{ | ||
name: "no value", | ||
extraArgs: "--key=", | ||
expected: []string{"--key"}, | ||
}, | ||
{ | ||
name: "no dashes", | ||
extraArgs: "key", | ||
expected: []string{"key"}, | ||
}, | ||
{ | ||
name: "no dashes with value", | ||
extraArgs: "key=value", | ||
expectedError: "invalid flag found: key=value", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
res, err := parseExtraArgs(tc.extraArgs) | ||
if tc.expectedError != "" { | ||
require.EqualError(t, err, tc.expectedError) | ||
return | ||
} | ||
require.NoError(t, err) | ||
require.Equal(t, tc.expected, res) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
converter/internal/staticconvert/testdata-v2/integrations_v2.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
server: | ||
log_level: ${SOME_ENVIRONMENT_VARIABLE:='debug'} | ||
log_format: json | ||
|
||
metrics: | ||
global: | ||
remote_write: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.