Skip to content

Commit ad11759

Browse files
committed
more fixes
1 parent a6397b5 commit ad11759

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pkg/keycloak/admin.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (client *KeycloakClient) FindUser(ctx context.Context, realm string, email
3030
}
3131
}
3232

33-
return "", fmt.Errorf("Could not find user '%s' in Keycloak", email)
33+
return "", fmt.Errorf("could not find user '%s' in Keycloak", email)
3434
}
3535

3636
func (client *KeycloakClient) GetAdminUsersURL(realm string) *url.URL {
@@ -75,11 +75,14 @@ func (client *KeycloakClient) findRenkuAdminRole(ctx context.Context, realm stri
7575
return role, err
7676
}
7777
}
78-
return roleMapping{}, fmt.Errorf("Could not find role '%s' in Keycloak", renkuAdminRole)
78+
return roleMapping{}, fmt.Errorf("could not find role '%s' in Keycloak", renkuAdminRole)
7979
}
8080

8181
func (client *KeycloakClient) AddRenkuAdminRoleToUser(ctx context.Context, realm string, userID string) error {
8282
role, err := client.findRenkuAdminRole(ctx, realm, userID)
83+
if err != nil {
84+
return err
85+
}
8386

8487
postURL := client.GetAdminRolesURL(realm, userID)
8588

pkg/renkuapi/auth.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,11 @@ func (auth *RenkuApiAuth) postForm(ctx context.Context, url string, data url.Val
370370
}
371371

372372
func tryParseResponse(resp *http.Response, result any) error {
373-
defer resp.Body.Close()
373+
defer func() {
374+
if err := resp.Body.Close(); err != nil {
375+
fmt.Printf("Warning, could not close HTTP response: %s", err.Error())
376+
}
377+
}()
374378

375379
outBuf := new(bytes.Buffer)
376380
_, err := outBuf.ReadFrom(resp.Body)

0 commit comments

Comments
 (0)