Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix GetBannedUser #436

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/banneduser/banneduser.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func NewBannedUser(userSignup *toolchainv1alpha1.UserSignup, bannedBy, banReason
return bannedUser, nil
}

// GetBannedUser returns BannedUser with the provided user email hash if found. Otherwise it returns nil.
// GetBannedUser returns BannedUser with the provided user email hash, if found.
// If not found, it returns an error.
func GetBannedUser(ctx context.Context, userEmailHash string, hostClient client.Client, hostNamespace string) (*toolchainv1alpha1.BannedUser, error) {
emailHashLabelMatch := client.MatchingLabels(map[string]string{
toolchainv1alpha1.BannedUserEmailHashLabelKey: userEmailHash,
Expand All @@ -54,5 +55,5 @@ func GetBannedUser(ctx context.Context, userEmailHash string, hostClient client.
return &bannedUsers.Items[0], nil
}

return nil, nil
return nil, fmt.Errorf("failed to get banned user %s", userEmailHash)
rsoaresd marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion pkg/banneduser/banneduser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func TestGetBannedUser(t *testing.T) {
name: "user is not banned",
toBan: bannedUser2,
wantResult: nil,
wantError: false,
wantError: true,
fakeClient: fakeClient,
},
{
Expand Down
Loading