Add initialization example to mock-plugin. (#8520)

This commit is contained in:
Sven Rebhan 2020-12-07 23:43:15 +01:00 committed by GitHub
parent 139498937a
commit d712bd13d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -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)