fix bug with loading plugins in shim with no config (#7816)
This commit is contained in:
parent
37f12ec6ea
commit
db02ae5829
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue