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
|
// have registered themselves with the registry. This makes loading plugins
|
||||||
// without having to define a config dead easy.
|
// without having to define a config dead easy.
|
||||||
func DefaultImportedPlugins() (config, error) {
|
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 {
|
for name := range inputs.Inputs {
|
||||||
conf.Inputs[name] = []toml.Primitive{}
|
conf.Inputs[name] = []toml.Primitive{}
|
||||||
return conf, nil
|
return conf, nil
|
||||||
|
|
|
||||||
|
|
@ -27,3 +27,13 @@ func TestLoadConfig(t *testing.T) {
|
||||||
require.Equal(t, "xxxxxxxxxx", inp.SecretToken)
|
require.Equal(t, "xxxxxxxxxx", inp.SecretToken)
|
||||||
require.Equal(t, `test"\test`, inp.SecretValue)
|
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 {
|
func (i *testInput) Description() string {
|
||||||
return ""
|
return "test"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *testInput) Gather(acc telegraf.Accumulator) error {
|
func (i *testInput) Gather(acc telegraf.Accumulator) error {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue