Add initialization example to mock-plugin. (#8520)
This commit is contained in:
parent
139498937a
commit
d712bd13d6
|
|
@ -9,6 +9,8 @@ import (
|
|||
// MockPlugin struct should be named the same as the Plugin
|
||||
type MockPlugin struct {
|
||||
mock.Mock
|
||||
|
||||
constructedVariable string
|
||||
}
|
||||
|
||||
// Description will appear directly above the plugin definition in the config file
|
||||
|
|
@ -21,6 +23,12 @@ func (m *MockPlugin) SampleConfig() string {
|
|||
return ` sampleVar = 'foo'`
|
||||
}
|
||||
|
||||
// Init can be implemented to do one-time processing stuff like initializing variables
|
||||
func (m *MockPlugin) Init() error {
|
||||
m.constructedVariable = "I'm initialized now."
|
||||
return nil
|
||||
}
|
||||
|
||||
// Gather defines what data the plugin will gather.
|
||||
func (m *MockPlugin) Gather(_a0 telegraf.Accumulator) error {
|
||||
ret := m.Called(_a0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue