Skip to content

Commit 52e7fd4

Browse files
author
Enda
authored
fix: return request output format when list is empty (#584)
BREAKING CHANGE: The `list` commands now return the original response object in JSON or YAML, instead of nil, depending on the format requested.
1 parent 5462602 commit 52e7fd4

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

pkg/cmd/kafka/consumergroup/list/list.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ func runList(opts *Options) (err error) {
110110
req = req.Topic(opts.topic)
111111
}
112112
consumerGroupData, httpRes, err := req.Execute()
113-
114113
if err != nil {
115114
if httpRes == nil {
116115
return err
@@ -147,7 +146,7 @@ func runList(opts *Options) (err error) {
147146
}
148147
}
149148

150-
if consumerGroupData.GetCount() == 0 {
149+
if consumerGroupData.GetCount() == 0 && opts.output == "" {
151150
logger.Info(localizer.MustLocalize(&localizer.Config{
152151
MessageID: "kafka.consumerGroup.list.log.info.noConsumerGroups",
153152
TemplateData: map[string]interface{}{

pkg/cmd/kafka/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func runList(opts *options) error {
121121
return err
122122
}
123123

124-
if response.Size == 0 {
124+
if response.Size == 0 && opts.outputFormat == "" {
125125
logger.Info(localizer.MustLocalizeFromID("kafka.common.log.info.noKafkaInstances"))
126126
return nil
127127
}

pkg/cmd/kafka/topic/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func runCmd(opts *Options) error {
140140
}
141141
}
142142

143-
if topicData.GetCount() == 0 {
143+
if topicData.GetCount() == 0 && opts.output == "" {
144144
logger.Info(localizer.MustLocalize(&localizer.Config{
145145
MessageID: "kafka.topic.list.log.info.noTopics",
146146
TemplateData: map[string]interface{}{

pkg/cmd/serviceaccount/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func runList(opts *Options) (err error) {
105105
}
106106

107107
serviceaccounts := res.GetItems()
108-
if len(serviceaccounts) == 0 {
108+
if len(serviceaccounts) == 0 && opts.output == "" {
109109
logger.Info(localizer.MustLocalizeFromID("serviceAccount.list.log.info.noneFound"))
110110
return nil
111111
}

0 commit comments

Comments
 (0)