Skip to content

Commit

Permalink
iam/user.go: Improve logging (#2747)
Browse files Browse the repository at this point in the history
Avoid log & return (leads to double log), add more error information on err returns.
  • Loading branch information
orestisfl authored Nov 19, 2024
1 parent 0d9b68f commit fa1dc29
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internal/resources/providers/awslib/iam/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const (
func (p Provider) GetUsers(ctx context.Context) ([]awslib.AwsResource, error) {
apiUsers, err := p.listUsers(ctx)
if err != nil {
p.log.Errorf("fail to list users, error: %v", err)
return nil, err
}

Expand Down Expand Up @@ -142,7 +141,7 @@ func (p Provider) listUsers(ctx context.Context) ([]types.User, error) {
for {
users, err := p.client.ListUsers(ctx, input)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to list users: %w", err)
}
nativeUsers = append(nativeUsers, users.Users...)
if !users.IsTruncated {
Expand Down Expand Up @@ -239,7 +238,7 @@ func (p Provider) getCredentialReport(ctx context.Context) (map[string]*Credenti
// generate a new report
_, err = p.client.GenerateCredentialReport(ctx, &iamsdk.GenerateCredentialReportInput{})
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to generate credential report: %w", err)
}
}
}
Expand Down

0 comments on commit fa1dc29

Please sign in to comment.