Skip to content

Commit

Permalink
replication factor is now printed for most topic output formats (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
d-rk committed Feb 11, 2025
1 parent 8d5dc6d commit 6d5d7e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- [#234](https://github.com/deviceinsight/kafkactl/pull/234) caching to arvo client when producing messages
- [#236](https://github.com/deviceinsight/kafkactl/issues/236) set working directory to path with first loaded config file.
- [#233](https://github.com/deviceinsight/kafkactl/issues/233) replication factor is now printed for most topic output formats.

### Removed
- [#231](https://github.com/deviceinsight/kafkactl/issues/231) Remove support for installing kafkactl via snap.
Expand Down
13 changes: 8 additions & 5 deletions internal/topic/topic-operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
)

type Topic struct {
Name string
Partitions []Partition `json:",omitempty" yaml:",omitempty"`
Configs []internal.Config `json:",omitempty" yaml:",omitempty"`
Name string
ReplicationFactor int
Partitions []Partition `json:",omitempty" yaml:",omitempty"`
Configs []internal.Config `json:",omitempty" yaml:",omitempty"`
}

type Partition struct {
Expand Down Expand Up @@ -694,7 +695,7 @@ func (operation *Operation) GetTopics(flags GetTopicsFlags) error {
return output.PrintObject(topicList, flags.OutputFormat)
} else if flags.OutputFormat == "wide" {
for _, t := range topicList {
if err := tableWriter.Write(t.Name, strconv.Itoa(len(t.Partitions)), strconv.Itoa(replicationFactor(t)), getConfigString(t.Configs)); err != nil {
if err := tableWriter.Write(t.Name, strconv.Itoa(len(t.Partitions)), strconv.Itoa(t.ReplicationFactor), getConfigString(t.Configs)); err != nil {
return err
}
}
Expand All @@ -706,7 +707,7 @@ func (operation *Operation) GetTopics(flags GetTopicsFlags) error {
}
} else {
for _, t := range topicList {
if err := tableWriter.Write(t.Name, strconv.Itoa(len(t.Partitions)), strconv.Itoa(replicationFactor(t))); err != nil {
if err := tableWriter.Write(t.Name, strconv.Itoa(len(t.Partitions)), strconv.Itoa(t.ReplicationFactor)); err != nil {
return err
}
}
Expand Down Expand Up @@ -829,6 +830,8 @@ func readTopic(client *sarama.Client, admin *sarama.ClusterAdmin, name string, r
}
}

top.ReplicationFactor = replicationFactor(top)

return top, nil
}

Expand Down

0 comments on commit 6d5d7e5

Please sign in to comment.