Skip to content

Commit 635665f

Browse files
author
Enda Phelan
committed
refactor: return plain err
1 parent 8270542 commit 635665f

File tree

8 files changed

+49
-49
lines changed

8 files changed

+49
-49
lines changed

pkg/cmd/kafka/consumergroup/delete/delete.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ func runCmd(opts *Options) error {
8989

9090
ctx := context.Background()
9191

92-
_, httpRes, consumerGroupErr := api.GetConsumerGroupById(ctx, opts.id).Execute()
92+
_, httpRes, err := api.GetConsumerGroupById(ctx, opts.id).Execute()
9393

94-
if consumerGroupErr.Error() != "" {
94+
if err.Error() != "" {
9595
if httpRes == nil {
96-
return consumerGroupErr
96+
return err
9797
}
9898
if httpRes.StatusCode == 404 {
9999
return errors.New(localizer.MustLocalize(&localizer.Config{
@@ -128,11 +128,11 @@ func runCmd(opts *Options) error {
128128
}
129129
}
130130

131-
httpRes, consumerGroupErr = api.DeleteConsumerGroupById(ctx, opts.id).Execute()
131+
httpRes, err = api.DeleteConsumerGroupById(ctx, opts.id).Execute()
132132

133133
if err != nil {
134134
if httpRes == nil {
135-
return consumerGroupErr
135+
return err
136136
}
137137

138138
switch httpRes.StatusCode {
@@ -158,9 +158,9 @@ func runCmd(opts *Options) error {
158158
TemplateData: map[string]interface{}{
159159
"Name": kafkaInstance.GetName(),
160160
},
161-
}), consumerGroupErr)
161+
}), err)
162162
default:
163-
return consumerGroupErr
163+
return err
164164
}
165165
}
166166

pkg/cmd/kafka/consumergroup/describe/describe.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ func runCmd(opts *Options) error {
105105

106106
ctx := context.Background()
107107

108-
consumerGroupData, httpRes, consumerGroupErr := api.GetConsumerGroupById(ctx, opts.id).Execute()
108+
consumerGroupData, httpRes, err := api.GetConsumerGroupById(ctx, opts.id).Execute()
109109

110-
if consumerGroupErr != nil && consumerGroupErr.Error() != "" {
110+
if err != nil {
111111
if httpRes == nil {
112-
return consumerGroupErr
112+
return err
113113
}
114114

115115
switch httpRes.StatusCode {
@@ -143,9 +143,9 @@ func runCmd(opts *Options) error {
143143
TemplateData: map[string]interface{}{
144144
"Name": kafkaInstance.GetName(),
145145
},
146-
}), consumerGroupErr)
146+
}), err)
147147
default:
148-
return consumerGroupErr
148+
return err
149149
}
150150
}
151151

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ func runList(opts *Options) (err error) {
102102
return err
103103
}
104104

105-
consumerGroupData, httpRes, consumerGroupErr := api.GetConsumerGroupList(ctx).Limit(opts.limit).Execute()
105+
consumerGroupData, httpRes, err := api.GetConsumerGroupList(ctx).Limit(opts.limit).Execute()
106106

107-
if consumerGroupErr != nil && consumerGroupErr.Error() != "" {
107+
if err != nil && err.Error() != "" {
108108
if httpRes == nil {
109-
return consumerGroupErr
109+
return err
110110
}
111111

112112
switch httpRes.StatusCode {
@@ -134,9 +134,9 @@ func runList(opts *Options) (err error) {
134134
TemplateData: map[string]interface{}{
135135
"Name": kafkaInstance.GetName(),
136136
},
137-
}), consumerGroupErr)
137+
}), err)
138138
default:
139-
return consumerGroupErr
139+
return err
140140
}
141141
}
142142

pkg/cmd/kafka/topic/create/create.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ func runCmd(opts *Options) error {
165165
}
166166
createTopicReq = createTopicReq.NewTopicInput(topicInput)
167167

168-
response, httpRes, topicErr := createTopicReq.Execute()
169-
if topicErr.Error() != "" {
168+
response, httpRes, err := createTopicReq.Execute()
169+
if err != nil {
170170
if httpRes == nil {
171-
return topicErr
171+
return err
172172
}
173173

174174
switch httpRes.StatusCode {
@@ -202,9 +202,9 @@ func runCmd(opts *Options) error {
202202
TemplateData: map[string]interface{}{
203203
"Name": kafkaInstance.GetName(),
204204
},
205-
}), topicErr)
205+
}), err)
206206
default:
207-
return topicErr
207+
return err
208208
}
209209
}
210210

pkg/cmd/kafka/topic/delete/delete.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ func runCmd(opts *Options) error {
122122
}
123123

124124
// perform delete topic API request
125-
_, httpRes, topicErr := api.GetTopic(context.Background(), opts.topicName).
125+
_, httpRes, err := api.GetTopic(context.Background(), opts.topicName).
126126
Execute()
127127

128-
if topicErr.Error() != "" {
128+
if err != nil {
129129
if httpRes == nil {
130-
return topicErr
130+
return err
131131
}
132132
if httpRes.StatusCode == 404 {
133133
return errors.New(localizer.MustLocalize(&localizer.Config{
@@ -145,7 +145,7 @@ func runCmd(opts *Options) error {
145145
Message: localizer.MustLocalizeFromID("kafka.topic.delete.input.name.message"),
146146
}
147147
var userConfirmedName string
148-
if err := survey.AskOne(promptConfirmName, &userConfirmedName); err != nil {
148+
if err = survey.AskOne(promptConfirmName, &userConfirmedName); err != nil {
149149
return err
150150
}
151151

@@ -162,11 +162,11 @@ func runCmd(opts *Options) error {
162162
}
163163

164164
// perform delete topic API request
165-
httpRes, topicErr = api.DeleteTopic(context.Background(), opts.topicName).
165+
httpRes, err = api.DeleteTopic(context.Background(), opts.topicName).
166166
Execute()
167-
if topicErr.Error() != "" {
167+
if err != nil {
168168
if httpRes == nil {
169-
return topicErr
169+
return err
170170
}
171171

172172
switch httpRes.StatusCode {
@@ -200,9 +200,9 @@ func runCmd(opts *Options) error {
200200
TemplateData: map[string]interface{}{
201201
"Name": kafkaInstance.GetName(),
202202
},
203-
}), topicErr)
203+
}), err)
204204
default:
205-
return topicErr
205+
return err
206206
}
207207
}
208208

pkg/cmd/kafka/topic/describe/describe.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ func runCmd(opts *Options) error {
118118
}
119119

120120
// fetch the topic
121-
topicResponse, httpRes, topicErr := api.
121+
topicResponse, httpRes, err := api.
122122
GetTopic(context.Background(), opts.topicName).
123123
Execute()
124124

125-
if topicErr.Error() != "" {
125+
if err != nil {
126126
if httpRes == nil {
127-
return topicErr
127+
return err
128128
}
129129

130130
switch httpRes.StatusCode {
@@ -158,9 +158,9 @@ func runCmd(opts *Options) error {
158158
TemplateData: map[string]interface{}{
159159
"Name": kafkaInstance.GetName(),
160160
},
161-
}), topicErr)
161+
}), err)
162162
default:
163-
return topicErr
163+
return err
164164
}
165165
}
166166

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ func runCmd(opts *Options) error {
102102
}
103103

104104
a := api.GetTopicsList(context.Background())
105-
topicData, httpRes, topicErr := a.Execute()
105+
topicData, httpRes, err := a.Execute()
106106

107-
if topicErr != nil {
107+
if err != nil {
108108
if httpRes == nil {
109-
return topicErr
109+
return err
110110
}
111111

112112
switch httpRes.StatusCode {
@@ -134,9 +134,9 @@ func runCmd(opts *Options) error {
134134
TemplateData: map[string]interface{}{
135135
"Name": kafkaInstance.GetName(),
136136
},
137-
}), topicErr)
137+
}), err)
138138
default:
139-
return topicErr
139+
return err
140140
}
141141
}
142142

pkg/cmd/kafka/topic/update/update.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ func runCmd(opts *Options) error {
219219
// track if any values have changed
220220
var needsUpdate bool
221221

222-
_, httpRes, topicErr := api.GetTopic(context.Background(), opts.topicName).Execute()
222+
_, httpRes, err := api.GetTopic(context.Background(), opts.topicName).Execute()
223223

224-
if topicErr.Error() != "" {
224+
if err.Error() != "" {
225225
if httpRes == nil {
226-
return topicErr
226+
return err
227227
}
228228
if httpRes.StatusCode == 404 {
229229
return errors.New(localizer.MustLocalize(&localizer.Config{
@@ -266,11 +266,11 @@ func runCmd(opts *Options) error {
266266
updateTopicReq = updateTopicReq.UpdateTopicInput(*topicSettings)
267267

268268
// update the topic
269-
response, httpRes, topicErr := updateTopicReq.Execute()
269+
response, httpRes, err := updateTopicReq.Execute()
270270
// handle error
271-
if topicErr.Error() != "" {
271+
if err != nil {
272272
if httpRes == nil {
273-
return topicErr
273+
return err
274274
}
275275

276276
switch httpRes.StatusCode {
@@ -304,9 +304,9 @@ func runCmd(opts *Options) error {
304304
TemplateData: map[string]interface{}{
305305
"Name": kafkaInstance.GetName(),
306306
},
307-
}), topicErr)
307+
}), err)
308308
default:
309-
return topicErr
309+
return err
310310
}
311311
}
312312

0 commit comments

Comments
 (0)