fix(inputs.mock): Plugin not aligned with documentation (#13997)
This commit is contained in:
parent
f58c9555dd
commit
3b00b1da95
|
|
@ -29,26 +29,25 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
||||||
# "key" = "value"
|
# "key" = "value"
|
||||||
|
|
||||||
## One or more mock data fields *must* be defined.
|
## One or more mock data fields *must* be defined.
|
||||||
##
|
# [[inputs.mock.constant]]
|
||||||
## [[inputs.mock.constant]]
|
# name = "constant"
|
||||||
## name = "constant"
|
# value = value_of_any_type
|
||||||
## value = value_of_any_type
|
# [[inputs.mock.random]]
|
||||||
## [[inputs.mock.random]]
|
# name = "rand"
|
||||||
## name = "rand"
|
# min = 1.0
|
||||||
## min = 1.0
|
# max = 6.0
|
||||||
## max = 6.0
|
# [[inputs.mock.sine_wave]]
|
||||||
## [[inputs.mock.sine_wave]]
|
# name = "wave"
|
||||||
## name = "wave"
|
# amplitude = 1.0
|
||||||
## amplitude = 1.0
|
# period = 0.5
|
||||||
## period = 0.5
|
# [[inputs.mock.step]]
|
||||||
## [[inputs.mock.step]]
|
# name = "plus_one"
|
||||||
## name = "plus_one"
|
# start = 0.0
|
||||||
## start = 0.0
|
# step = 1.0
|
||||||
## step = 1.0
|
# [[inputs.mock.stock]]
|
||||||
## [[inputs.mock.stock]]
|
# name = "abc"
|
||||||
## name = "abc"
|
# price = 50.00
|
||||||
## price = 50.00
|
# volatility = 0.2
|
||||||
## volatility = 0.2
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The mock plugin only requires that:
|
The mock plugin only requires that:
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,11 @@ type step struct {
|
||||||
latest float64
|
latest float64
|
||||||
|
|
||||||
Name string `toml:"name"`
|
Name string `toml:"name"`
|
||||||
Start float64 `toml:"min"`
|
Start float64 `toml:"start"`
|
||||||
Step float64 `toml:"max"`
|
Step float64 `toml:"step"`
|
||||||
|
|
||||||
|
Min float64 `toml:"min" deprecated:"1.28.2;use 'start' instead"`
|
||||||
|
Max float64 `toml:"max" deprecated:"1.28.2;use 'step' instead"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type stock struct {
|
type stock struct {
|
||||||
|
|
@ -67,6 +70,17 @@ func (*Mock) SampleConfig() string {
|
||||||
|
|
||||||
func (m *Mock) Init() error {
|
func (m *Mock) Init() error {
|
||||||
m.rand = rand.New(rand.NewSource(time.Now().UnixNano())) //nolint:gosec // G404: not security critical
|
m.rand = rand.New(rand.NewSource(time.Now().UnixNano())) //nolint:gosec // G404: not security critical
|
||||||
|
|
||||||
|
// backward compatibility
|
||||||
|
for _, step := range m.Step {
|
||||||
|
if step.Min != 0 && step.Start == 0 {
|
||||||
|
step.Start = step.Min
|
||||||
|
}
|
||||||
|
if step.Max != 0 && step.Step == 0 {
|
||||||
|
step.Step = step.Max
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,23 +8,22 @@
|
||||||
# "key" = "value"
|
# "key" = "value"
|
||||||
|
|
||||||
## One or more mock data fields *must* be defined.
|
## One or more mock data fields *must* be defined.
|
||||||
##
|
# [[inputs.mock.constant]]
|
||||||
## [[inputs.mock.constant]]
|
# name = "constant"
|
||||||
## name = "constant"
|
# value = value_of_any_type
|
||||||
## value = value_of_any_type
|
# [[inputs.mock.random]]
|
||||||
## [[inputs.mock.random]]
|
# name = "rand"
|
||||||
## name = "rand"
|
# min = 1.0
|
||||||
## min = 1.0
|
# max = 6.0
|
||||||
## max = 6.0
|
# [[inputs.mock.sine_wave]]
|
||||||
## [[inputs.mock.sine_wave]]
|
# name = "wave"
|
||||||
## name = "wave"
|
# amplitude = 1.0
|
||||||
## amplitude = 1.0
|
# period = 0.5
|
||||||
## period = 0.5
|
# [[inputs.mock.step]]
|
||||||
## [[inputs.mock.step]]
|
# name = "plus_one"
|
||||||
## name = "plus_one"
|
# start = 0.0
|
||||||
## start = 0.0
|
# step = 1.0
|
||||||
## step = 1.0
|
# [[inputs.mock.stock]]
|
||||||
## [[inputs.mock.stock]]
|
# name = "abc"
|
||||||
## name = "abc"
|
# price = 50.00
|
||||||
## price = 50.00
|
# volatility = 0.2
|
||||||
## volatility = 0.2
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue