Skip to content

Commit 5d19a7a

Browse files
committed
topic: fix set-config
1 parent 556273f commit 5d19a7a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cmd/kaf/topic.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var topicsCmd = &cobra.Command{
5555

5656
var topicSetConfig = &cobra.Command{
5757
Use: "set-config",
58-
Short: "set topic config",
58+
Short: "set topic config. requires Kafka >=2.3.0 on broker side and kaf cluster config.",
5959
Example: "kaf topic set-config topic.name \"cleanup.policy=delete\"",
6060
Args: cobra.ExactArgs(2),
6161
Run: func(cmd *cobra.Command, args []string) {
@@ -64,7 +64,7 @@ var topicSetConfig = &cobra.Command{
6464
topic := args[0]
6565

6666
splt := strings.Split(args[1], ",")
67-
configs := make(map[string]*string)
67+
configs := make(map[string]sarama.IncrementalAlterConfigsEntry)
6868

6969
for _, kv := range splt {
7070
s := strings.Split(kv, "=")
@@ -75,14 +75,17 @@ var topicSetConfig = &cobra.Command{
7575

7676
key := s[0]
7777
value := s[1]
78-
configs[key] = &value
78+
configs[key] = sarama.IncrementalAlterConfigsEntry{
79+
Operation: sarama.IncrementalAlterConfigsOperationSet,
80+
Value: &value,
81+
}
7982
}
8083

8184
if len(configs) < 1 {
8285
errorExit("No valid configs found")
8386
}
8487

85-
err := admin.AlterConfig(sarama.TopicResource, topic, configs, false)
88+
err := admin.IncrementalAlterConfig(sarama.TopicResource, topic, configs, false)
8689
if err != nil {
8790
errorExit("Unable to alter topic config: %v\n", err)
8891
}

0 commit comments

Comments
 (0)