Skip to content

Commit 6c229ae

Browse files
fix(acl): Improve error handling -- apply suggestions
Co-authored-by: J. Fernández <7312236+fernandezcuesta@users.noreply.github.com> Signed-off-by: Viacheslav Vasilyev <avoidik@gmail.com>
1 parent 45736b7 commit 6c229ae

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • internal/clients/kafka/acl

internal/clients/kafka/acl/acl.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ func Create(ctx context.Context, cl adminClient, accessControlList *AccessContro
114114
if resp[0].Err != nil {
115115
return fmt.Errorf("create ACL failed: %w", resp[0].Err)
116116
}
117+
if len(resp[0].Principal) == 0 {
118+
return errors.New("no create response for acl")
119+
}
117120

118121
return nil
119122
}
@@ -129,8 +132,10 @@ func Delete(ctx context.Context, cl adminClient, accessControlList *AccessContro
129132
if err != nil {
130133
return err
131134
}
132-
if len(resp) > 0 && resp[0].Err != nil {
133-
return fmt.Errorf("delete ACL failed: %w", resp[0].Err)
135+
for _, r := range resp {
136+
if r.Err != nil {
137+
return fmt.Errorf("delete ACL failed: %w", r.Err)
138+
}
134139
}
135140
return nil
136141
}

0 commit comments

Comments
 (0)