diff --git a/plugins/common/shim/config.go b/plugins/common/shim/config.go index 33ae8ab2cfb55..9d76d3572e3fb 100644 --- a/plugins/common/shim/config.go +++ b/plugins/common/shim/config.go @@ -146,7 +146,11 @@ func createPluginsWithTomlConfig(md toml.MetaData, conf config) (loadedConfig, e // have registered themselves with the registry. This makes loading plugins // without having to define a config dead easy. func DefaultImportedPlugins() (config, error) { - conf := config{} + conf := config{ + Inputs: map[string][]toml.Primitive{}, + Processors: map[string][]toml.Primitive{}, + Outputs: map[string][]toml.Primitive{}, + } for name := range inputs.Inputs { conf.Inputs[name] = []toml.Primitive{} return conf, nil diff --git a/plugins/common/shim/config_test.go b/plugins/common/shim/config_test.go index 1a6e0bc32e6cd..1aee40df0f07a 100644 --- a/plugins/common/shim/config_test.go +++ b/plugins/common/shim/config_test.go @@ -27,3 +27,13 @@ func TestLoadConfig(t *testing.T) { require.Equal(t, "xxxxxxxxxx", inp.SecretToken) require.Equal(t, `test"\test`, inp.SecretValue) } + +func TestDefaultImportedPluginsSelfRegisters(t *testing.T) { + inputs.Add("test", func() telegraf.Input { + return &testInput{} + }) + + cfg, err := LoadConfig(nil) + require.NoError(t, err) + require.Equal(t, "test", cfg.Input.Description()) +} diff --git a/plugins/common/shim/input_test.go b/plugins/common/shim/input_test.go index 709ac79ef4fdc..32f97d5924bc5 100644 --- a/plugins/common/shim/input_test.go +++ b/plugins/common/shim/input_test.go @@ -85,7 +85,7 @@ func (i *testInput) SampleConfig() string { } func (i *testInput) Description() string { - return "" + return "test" } func (i *testInput) Gather(acc telegraf.Accumulator) error {