Skip to content

Commit

Permalink
feat(consumer-group list): add search flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rkpattnaik780 committed Jul 9, 2021
1 parent cd8ffbc commit afda40f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/commands/rhoas_kafka_consumer-group_list.adoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pkg/cmd/kafka/consumergroup/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Options struct {
kafkaID string
limit int32
topic string
search string
}

type consumerGroupRow struct {
Expand Down Expand Up @@ -81,6 +82,7 @@ func NewListConsumerGroupCommand(f *factory.Factory) *cobra.Command {
cmd.Flags().Int32VarP(&opts.limit, "limit", "", 1000, opts.localizer.MustLocalize("kafka.consumerGroup.list.flag.limit"))
cmd.Flags().StringVarP(&opts.output, "output", "o", "", opts.localizer.MustLocalize("kafka.consumerGroup.list.flag.output.description"))
cmd.Flags().StringVar(&opts.topic, "topic", "", opts.localizer.MustLocalize("kafka.consumerGroup.list.flag.topic.description"))
cmd.Flags().StringVar(&opts.search, "search", "", opts.localizer.MustLocalize("kafka.consumerGroup.list.flag.search"))

_ = cmd.RegisterFlagCompletionFunc("topic", func(cmd *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return cmdutil.FilterValidTopicNameArgs(f, toComplete)
Expand All @@ -91,6 +93,7 @@ func NewListConsumerGroupCommand(f *factory.Factory) *cobra.Command {
return cmd
}

// nolint:funlen
func runList(opts *Options) (err error) {
conn, err := opts.Connection(connection.DefaultConfigRequireMasAuth)
if err != nil {
Expand All @@ -114,6 +117,10 @@ func runList(opts *Options) (err error) {
if opts.topic != "" {
req = req.Topic(opts.topic)
}
if opts.search != "" {
req = req.GroupIdFilter(opts.search)
}

consumerGroupData, httpRes, err := req.Execute()
if err != nil {
if httpRes == nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/localize/locales/en/cmd/kafka_consumergroup_list.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ $ rhoas kafka consumer-group list -o json
description = 'Description for the --limit flag'
one = 'The maximum number of consumer groups to be returned'

[kafka.consumerGroup.list.flag.search]
description = 'Description for the --search flag'
one = 'Text search to filter consumer groups by ID'

[kafka.consumerGroup.list.log.info.noConsumerGroups]
one = 'Kafka instance "{{.InstanceName}}" has no consumer groups'

Expand Down

0 comments on commit afda40f

Please sign in to comment.