Skip to content

Commit 18367f8

Browse files
committed
Chore: handle search input validation in RunE
1 parent 8b122a8 commit 18367f8

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

cmd/rhoas/pkged.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

locales/kafka/active.en.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ one = 'Kafka instance name must be between 1 and 32 characters'
1414
[kafka.validation.error.invalidSearchValue]
1515
description = 'Error message when invalid search input is provided'
1616
one = '''
17-
Illegal search value "{{.Search}}", search input must satisfy the following conditions:
17+
illegal search value "{{.Search}}", search input must satisfy the following conditions:
1818
1919
- must be of 1 or more characters
2020
- must only consist of alphanumeric characters, '-', '_' and '%'

pkg/cmd/kafka/list/list.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ func NewListCommand(f *factory.Factory) *cobra.Command {
6868
if opts.outputFormat != "" && !flagutil.IsValidInput(opts.outputFormat, flagutil.ValidOutputFormats...) {
6969
return flag.InvalidValueError("output", opts.outputFormat, flagutil.ValidOutputFormats...)
7070
}
71+
if err := kafka.ValidateSearchInput(opts.search); err != nil {
72+
return err
73+
}
7174

7275
return runList(opts)
7376
},
@@ -103,10 +106,6 @@ func runList(opts *options) error {
103106

104107
if opts.search != "" {
105108

106-
if err = kafka.ValidateSearchInput(opts.search); err != nil {
107-
return err
108-
}
109-
110109
logger.Debug(localizer.MustLocalize(&localizer.Config{
111110
MessageID: "kafka.list.log.debug.filteringKafkaList",
112111
TemplateData: map[string]interface{}{

pkg/kafka/kafka_util.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func TransformKafkaRequest(kafka *kasclient.KafkaRequest) *kasclient.KafkaReques
7171
return kafka
7272
}
7373

74+
// ValidateSearchInput validates the text provided to filter the Kafka instances
7475
func ValidateSearchInput(val interface{}) error {
7576
search, ok := val.(string)
7677

0 commit comments

Comments
 (0)