Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
samirtahir91 committed Apr 1, 2024
1 parent 3013786 commit a4172e5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/controller/githubapp_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,6 @@ func generateAccessToken(appID int, installationID int, privateKey []byte) (stri
if err != nil {
return "", metav1.Time{}, fmt.Errorf("failed to perform HTTP request: %v", err)
}
// Close connection
defer resp.Body.Close()

// Check error in response
if resp.StatusCode != http.StatusCreated {
Expand All @@ -528,6 +526,14 @@ func generateAccessToken(appID int, installationID int, privateKey []byte) (stri
return "", metav1.Time{}, fmt.Errorf("failed to parse expire time: %v", err)
}

// Close the response body to prevent resource leaks
defer func() {
if err := resp.Body.Close(); err != nil {
// Handle error if closing the response body fails
l.Error(err, "error closing response body:")

Check failure on line 533 in internal/controller/githubapp_controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: l) (typecheck)

Check failure on line 533 in internal/controller/githubapp_controller.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: l (typecheck)

Check failure on line 533 in internal/controller/githubapp_controller.go

View workflow job for this annotation

GitHub Actions / ubuntu-latest

undefined: l
}
}()

return accessToken, metav1.NewTime(expiresAt), nil
}

Expand Down

0 comments on commit a4172e5

Please sign in to comment.