Skip to content

Commit 5728ad6

Browse files
[9.0] (backport #10259) [OTel] Fix CLI example to use proper syntax (#10271)
* [OTel] Fix CLI example to use proper syntax (#10259) This uses the expected `::` syntax instead of `.` for the `--set` argument. (cherry picked from commit e917e0a) * Remove tests that would require a breaking change to fix --------- Co-authored-by: Chris Earle <[email protected]> Co-authored-by: Chris Earle <[email protected]>
1 parent 4999149 commit 5728ad6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

internal/pkg/agent/cmd/otel_flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func setupOtelFlags(flags *pflag.FlagSet) {
2626
" single location can be set per flag entry e.g. `--config=file:/path/to/first --config=file:path/to/second`.")
2727

2828
flags.StringArray(otelSetFlagName, []string{}, "Set arbitrary component config property. The component has to be defined in the config file and the flag"+
29-
" has a higher precedence. Array config properties are overridden and maps are joined. Example --set=processors.batch.timeout=2s")
29+
" has a higher precedence. Array config properties are overridden and maps are joined. Example --set \"processors::batch::timeout=2s\"")
3030

3131
goFlags := new(flag.FlagSet)
3232
featuregate.GlobalRegistry().RegisterFlags(goFlags)

internal/pkg/agent/cmd/validate_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ func TestValidateCommand(t *testing.T) {
2323
[]string{filepath.Join("testdata", "otel", "otel.yml")},
2424
false,
2525
},
26+
{
27+
"otel config with set",
28+
[]string{filepath.Join("testdata", "otel", "otel.yml"), "yaml:processors::resource::attributes: [{ key: service.name, action: insert, value: elastic-otel-test1 }]"},
29+
false,
30+
},
2631
{
2732
"agent config",
2833
[]string{filepath.Join("testdata", "otel", "elastic-agent.yml")},
@@ -33,7 +38,12 @@ func TestValidateCommand(t *testing.T) {
3338
for _, tc := range tt {
3439
t.Run(tc.Name, func(t *testing.T) {
3540
err := validateOtelConfig(context.Background(), tc.ConfigPaths)
36-
require.Equal(t, tc.ExpectingErr, err != nil)
41+
42+
if tc.ExpectingErr {
43+
require.Error(t, err)
44+
} else {
45+
require.NoError(t, err)
46+
}
3747
})
3848
}
3949
}

0 commit comments

Comments
 (0)