Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
43
migrations/inputs_nats_consumer/migration.go
Normal file
43
migrations/inputs_nats_consumer/migration.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package inputs_nats_consumer
|
||||
|
||||
import (
|
||||
"github.com/influxdata/toml"
|
||||
"github.com/influxdata/toml/ast"
|
||||
|
||||
"github.com/influxdata/telegraf/migrations"
|
||||
)
|
||||
|
||||
// Migration function
|
||||
func migrate(tbl *ast.Table) ([]byte, string, error) {
|
||||
// Decode the old data structure
|
||||
var plugin map[string]interface{}
|
||||
if err := toml.UnmarshalTable(tbl, &plugin); err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
// Check for deprecated option(s) and migrate them
|
||||
var applied bool
|
||||
if _, found := plugin["metric_buffer"]; found {
|
||||
applied = true
|
||||
|
||||
// Remove the ignored setting
|
||||
delete(plugin, "metric_buffer")
|
||||
}
|
||||
|
||||
// No options migrated so we can exit early
|
||||
if !applied {
|
||||
return nil, "", migrations.ErrNotApplicable
|
||||
}
|
||||
|
||||
// Create the corresponding plugin configurations
|
||||
cfg := migrations.CreateTOMLStruct("inputs", "nats_consumer")
|
||||
cfg.Add("inputs", "nats_consumer", plugin)
|
||||
|
||||
output, err := toml.Marshal(cfg)
|
||||
return output, "", err
|
||||
}
|
||||
|
||||
// Register the migration function for the plugin type
|
||||
func init() {
|
||||
migrations.AddPluginOptionMigration("inputs.nats_consumer", migrate)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue