Conversation
craicoverflow
left a comment
There was a problem hiding this comment.
Nice changes, left some additional improvements 👍🏻
docs/commands/rhoas_kafka_list.adoc
Outdated
| --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 Text search to filter the Kafka instances |
There was a problem hiding this comment.
It should be clear that this searches all fields.
There was a problem hiding this comment.
Or rather, it should say which fields are searched.
pkg/cmd/kafka/list/list.go
Outdated
| var queryString string | ||
|
|
||
| if search != "" { | ||
| queryString = fmt.Sprintf( |
There was a problem hiding this comment.
I would also have search on the ID field.
There was a problem hiding this comment.
The kafka list endpoint doesn't support searching through the id column.
Failed to parse search query: Unsupported column name for search: 'id'. Supported column names are: region, name, cloud_provider, status, owner. Query invalid: id like 10
There was a problem hiding this comment.
Fair enough, ignore me so :)
pkg/cmd/kafka/list/list.go
Outdated
| a := api.Kafka().ListKafkas(context.Background()) | ||
| a = a.Page(strconv.Itoa(opts.page)) | ||
| a = a.Size(strconv.Itoa(opts.limit)) | ||
| a = a.Search(buildQuery(opts.search)) |
There was a problem hiding this comment.
| a = a.Search(buildQuery(opts.search)) | |
| if opts.search != "" { | |
| a = a.Search(buildQuery(opts.search)) | |
| } |
There was a problem hiding this comment.
I also think this is a great place to have a debug log of the search query :)
|
|
||
| [kafka.list.flag.search] | ||
| description = 'Description for the --search flag' | ||
| one = 'Text search to filter the Kafka instances' |
There was a problem hiding this comment.
It should be clear on which fields it will search.
There was a problem hiding this comment.
Should we make it something like Text search to filter the kafka instances by name, owner, cloud_provider, region and status.
Can you suggest something better?
There was a problem hiding this comment.
No I think that sounds good!
1d3d2d6 to
987f1c7
Compare
|
Needs rebase. Can't verify yet until staging is fixed. |
7dc34db to
8889a1e
Compare
Rebased |
❯ rhoas kafka list --search "enda test"
Error: Failed to parse search query: Unable to list kafka requests for ephelan_kafka_devexp: MGD-SERV-API-23: Failed to parse search query: Provided search query seems incomplete: 'name like %enda test% or owner like %enda test% or cloud_provider like %enda test% or region like %enda test% or status like %enda test%'Having a space in the query throws an API error. It is best to validate this client-side. We could throw an error in the CLI if the search query has spaces? What do you think? |
Yes, that will be better. I will look into it. |
Search flag has been added to kafka list to filter by text. fixes #181
8889a1e to
8b122a8
Compare
craicoverflow
left a comment
There was a problem hiding this comment.
Left a couple of final optional changes you could make, but they are nitpicks. Approving! 👍🏻
pkg/cmd/kafka/list/list.go
Outdated
|
|
||
| if opts.search != "" { | ||
|
|
||
| if err = kafka.ValidateSearchInput(opts.search); err != nil { |
There was a problem hiding this comment.
Usually we do this validation inside RunE (as early as possible)
locales/kafka/active.en.toml
Outdated
| [kafka.validation.error.invalidSearchValue] | ||
| description = 'Error message when invalid search input is provided' | ||
| one = ''' | ||
| Illegal search value "{{.Search}}", search input must satisfy the following conditions: |
There was a problem hiding this comment.
Error messages should begin with a lowercase in Go. This is because it will usually be prefixed with something like "Error: ":
| Illegal search value "{{.Search}}", search input must satisfy the following conditions: | |
| illegal search value "{{.Search}}", search input must satisfy the following conditions: |
| return kafka | ||
| } | ||
|
|
||
| func ValidateSearchInput(val interface{}) error { |
There was a problem hiding this comment.
You should add a comment documenting the purpose of this function
18367f8 to
dcdb517
Compare
Search flag has been added to kafka list to filter by text.
fixes #181