Skip to content
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
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/otel_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func setupOtelFlags(flags *pflag.FlagSet) {
" single location can be set per flag entry e.g. `--config=file:/path/to/first --config=file:path/to/second`.")

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

goFlags := new(flag.FlagSet)
featuregate.GlobalRegistry().RegisterFlags(goFlags)
Expand Down
12 changes: 11 additions & 1 deletion internal/pkg/agent/cmd/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func TestValidateCommand(t *testing.T) {
[]string{filepath.Join("testdata", "otel", "otel.yml")},
false,
},
{
"otel config with set",
[]string{filepath.Join("testdata", "otel", "otel.yml"), "yaml:processors::resource::attributes: [{ key: service.name, action: insert, value: elastic-otel-test1 }]"},
false,
},
{
"agent config",
[]string{filepath.Join("testdata", "otel", "elastic-agent.yml")},
Expand All @@ -33,7 +38,12 @@ func TestValidateCommand(t *testing.T) {
for _, tc := range tt {
t.Run(tc.Name, func(t *testing.T) {
err := validateOtelConfig(context.Background(), tc.ConfigPaths)
require.Equal(t, tc.ExpectingErr, err != nil)

if tc.ExpectingErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}
})
}
}