Skip to content

Commit

Permalink
feat(kafka list): add search flag
Browse files Browse the repository at this point in the history
Search flag has been added to kafka list to filter by text.

fixes #181
  • Loading branch information
rkpattnaik780 committed Feb 18, 2021
1 parent 654cfb7 commit a44649c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/commands/rhoas_kafka_list.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ rhoas kafka list [flags]
--limit int The maximum number of Kafka instances to be returned (default 100)
-o, --output string Format in which to display the Kafka instances. Choose from: "json", "yml", "yaml"
--page int Display the Kafka instances from the specified page number.
--search string Query string to filter the kafka list by text
....

=== Options inherited from parent commands
Expand Down
4 changes: 4 additions & 0 deletions locales/cmd/kafka/list/active.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ one = 'Display the Kafka instances from the specified page number.'
description = 'Description for the --limit flag'
one = 'The maximum number of Kafka instances to be returned'

[kafka.list.flag.search]
description = 'Description for the --search flag'
one = 'Query string to filter the kafka list by text'

[kafka.list.log.info.noKafkaInstances]
description = 'Info message when no Kafkas were found'
one = 'No Kafka instances were found.'
3 changes: 3 additions & 0 deletions pkg/cmd/kafka/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type options struct {
outputFormat string
page int
limit int
search string

Config config.IConfig
Connection func() (connection.Connection, error)
Expand Down Expand Up @@ -75,6 +76,7 @@ func NewListCommand(f *factory.Factory) *cobra.Command {
}))
cmd.Flags().IntVarP(&opts.page, "page", "", 0, localizer.MustLocalizeFromID("kafka.list.flag.page"))
cmd.Flags().IntVarP(&opts.limit, "limit", "", 100, localizer.MustLocalizeFromID("kafka.list.flag.limit"))
cmd.Flags().StringVarP(&opts.search, "search", "", "", localizer.MustLocalizeFromID("kafka.list.flag.search"))

return cmd
}
Expand All @@ -95,6 +97,7 @@ func runList(opts *options) error {
a := api.Kafka().ListKafkas(context.Background())
a = a.Page(strconv.Itoa(opts.page))
a = a.Size(strconv.Itoa(opts.limit))
a = a.Search(opts.search)
response, _, apiErr := a.Execute()

if apiErr.Error() != "" {
Expand Down

0 comments on commit a44649c

Please sign in to comment.