Skip to content

Commit a72a00b

Browse files
committed
Chore: change helper texts and add debugger
1 parent 58af1e1 commit a72a00b

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

docs/commands/rhoas_kafka_list.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ rhoas kafka list [flags]
2525
--limit int The maximum number of Kafka instances to be returned (default 100)
2626
-o, --output string Format in which to display the Kafka instances. Choose from: "json", "yml", "yaml"
2727
--page int Display the Kafka instances from the specified page number.
28-
--search string Text search to filter the Kafka instances
28+
--search string Text search to filter the Kafka instances by name, owner, cloud_provider, region and status
2929
....
3030

3131
=== Options inherited from parent commands

locales/cmd/kafka/list/active.en.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ one = 'The maximum number of Kafka instances to be returned'
4242

4343
[kafka.list.flag.search]
4444
description = 'Description for the --search flag'
45-
one = 'Text search to filter the Kafka instances'
45+
one = 'Text search to filter the Kafka instances by name, owner, cloud_provider, region and status'
46+
47+
[kafka.list.log.debug.filteringKafkaList]
48+
description = 'Debugging message when filtering the list of Kafka instances'
49+
one = 'Filtering Kafka instances with the query "{{.Search}}"'
4650

4751
[kafka.list.log.info.noKafkaInstances]
4852
description = 'Info message when no Kafkas were found'

pkg/cmd/kafka/list/list.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,17 @@ func runList(opts *options) error {
9999
a := api.Kafka().ListKafkas(context.Background())
100100
a = a.Page(strconv.Itoa(opts.page))
101101
a = a.Size(strconv.Itoa(opts.limit))
102-
a = a.Search(buildQuery(opts.search))
102+
103+
if opts.search != "" {
104+
logger.Debug(localizer.MustLocalize(&localizer.Config{
105+
MessageID: "kafka.list.log.debug.filteringKafkaList",
106+
TemplateData: map[string]interface{}{
107+
"Search": buildQuery(opts.search),
108+
},
109+
}))
110+
a = a.Search(buildQuery(opts.search))
111+
}
112+
103113
response, _, apiErr := a.Execute()
104114

105115
if apiErr.Error() != "" {
@@ -148,14 +158,10 @@ func mapResponseItemsToRows(kafkas []kasclient.KafkaRequest) []kafkaRow {
148158

149159
func buildQuery(search string) string {
150160

151-
var queryString string
152-
153-
if search != "" {
154-
queryString = fmt.Sprintf(
155-
"name like %%%[1]v%% or owner like %%%[1]v%% or cloud_provider like %%%[1]v%% or region like %%%[1]v%% or status like %%%[1]v%%",
156-
search,
157-
)
158-
}
161+
queryString := fmt.Sprintf(
162+
"name like %%%[1]v%% or owner like %%%[1]v%% or cloud_provider like %%%[1]v%% or region like %%%[1]v%% or status like %%%[1]v%%",
163+
search,
164+
)
159165

160166
return queryString
161167

0 commit comments

Comments
 (0)