Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(migrations): Add migration for inputs.kafka_consumer_legacy #14122

Merged
merged 4 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions migrations/all/inputs_kafka_consumer_legacy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build !custom || (migrations && (inputs || inputs.kafka_consumer_legacy))

package all

import _ "github.com/influxdata/telegraf/migrations/inputs_kafka_consumer_legacy" // register migration
Empty file.
21 changes: 21 additions & 0 deletions migrations/inputs_kafka_consumer_legacy/migration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package inputs_kafka_consumer_legacy

import (
"github.com/influxdata/toml/ast"

"github.com/influxdata/telegraf/migrations"
)

const msg = `
This plugin cannot be migrated automatically and requires manual intervention!
`

// Migration function
func migrate(_ *ast.Table) ([]byte, string, error) {
return nil, msg, nil
}

// Register the migration function for the plugin type
func init() {
migrations.AddPluginMigration("inputs.kafka_consumer_legacy", migrate)
}
29 changes: 29 additions & 0 deletions migrations/inputs_kafka_consumer_legacy/migration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package inputs_kafka_consumer_legacy_test

import (
"strings"
"testing"

"github.com/stretchr/testify/require"

"github.com/influxdata/telegraf/config"
_ "github.com/influxdata/telegraf/migrations/inputs_kafka_consumer_legacy" // register migration
)

func TestNoMigration(t *testing.T) {
input := []byte(`
[[inputs.kafka_consumer_legacy]]
topics = ["telegraf"]
zookeeper_peers = ["localhost:2181"]
zookeeper_chroot = ""
consumer_group = "telegraf_metrics_consumers"
offset = "oldest"
data_format = "influx"
max_message_len = 65536
`)

output, n, err := config.ApplyMigrations(input)
require.NoError(t, err)
require.Empty(t, strings.TrimSpace(string(output)))
require.Equal(t, uint64(1), n)
}