Skip to content

Commit cd7a643

Browse files
author
Enda Phelan
committed
fix: return error only when Kafka name exists
1 parent 915df6c commit cd7a643

File tree

2 files changed

+5
-57
lines changed

2 files changed

+5
-57
lines changed

pkg/httputil/logging_round_tripper.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

pkg/kafka/kafka_util.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,13 @@ func (v *Validator) ValidateNameIsAvailable(val interface{}) error {
105105

106106
api := connection.API()
107107

108-
_, httpRes, err := GetKafkaByName(context.Background(), api.Kafka(), name)
108+
_, httpRes, _ := GetKafkaByName(context.Background(), api.Kafka(), name)
109+
109110
if httpRes != nil {
110111
defer httpRes.Body.Close()
111-
}
112-
if err != nil {
113-
return err
114-
}
115-
116-
if httpRes != nil && httpRes.StatusCode == http.StatusOK {
117-
return errors.New(v.Localizer.MustLocalize("kafka.create.error.conflictError", localize.NewEntry("Name", name)))
118-
}
119-
120-
if httpRes != nil && httpRes.Body != nil {
121-
httpRes.Body.Close()
112+
if httpRes.StatusCode == http.StatusOK {
113+
return errors.New(v.Localizer.MustLocalize("kafka.create.error.conflictError", localize.NewEntry("Name", name)))
114+
}
122115
}
123116

124117
return nil

0 commit comments

Comments
 (0)