Skip to content

Commit

Permalink
chore: cleanup and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Oct 29, 2024
1 parent 51960e2 commit 6ec7bbc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/build/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func PlanBuild(ctx context.Context, database database.Interface, scm scm.Service
}

// plan all steps for the build
steps, err := step.PlanSteps(ctx, database, scm, p, b, r)
steps, err := step.PlanSteps(ctx, database, scm, p, b)
if err != nil {
// clean up the objects from the pipeline in the database
CleanBuild(ctx, database, b, services, steps, err)
Expand Down
2 changes: 1 addition & 1 deletion api/step/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// PlanSteps is a helper function to plan all steps
// in the build for execution. This creates the steps
// for the build.
func PlanSteps(ctx context.Context, database database.Interface, scm scm.Service, p *pipeline.Build, b *types.Build, r *types.Repo) ([]*types.Step, error) {
func PlanSteps(ctx context.Context, database database.Interface, scm scm.Service, p *pipeline.Build, b *types.Build) ([]*types.Step, error) {
// variable to store planned steps
steps := []*types.Step{}

Expand Down
4 changes: 2 additions & 2 deletions scm/github/app_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

// NewGitHubAppTransport creates a new GitHub App transport for authenticating as the GitHub App.
func NewGitHubAppTransport(appID int64, privateKey, baseUrl string) (*AppsTransport, error) {
func NewGitHubAppTransport(appID int64, privateKey, baseURL string) (*AppsTransport, error) {
decodedPEM, err := base64.StdEncoding.DecodeString(privateKey)
if err != nil {
return nil, fmt.Errorf("error decoding base64: %w", err)
Expand All @@ -36,7 +36,7 @@ func NewGitHubAppTransport(appID int64, privateKey, baseUrl string) (*AppsTransp
}

transport := NewAppsTransportFromPrivateKey(http.DefaultTransport, appID, _privateKey)
transport.BaseURL = baseUrl
transport.BaseURL = baseURL

return transport, nil
}
Expand Down
6 changes: 4 additions & 2 deletions scm/github/app_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ type AppsTransport struct {
Client Client // Client to use to refresh tokens, defaults to http.Client with provided transport
tr http.RoundTripper // tr is the underlying roundtripper being wrapped
signer Signer // signer signs JWT tokens.
appID int64 // appID is the GitHub App's ID
//nolint:unused // ignore false positive

Check failure on line 40 in scm/github/app_transport.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] scm/github/app_transport.go#L40

directive `//nolint:unused // ignore false positive` is unused for linter "unused" (nolintlint)
Raw output
scm/github/app_transport.go:40:2: directive `//nolint:unused // ignore false positive` is unused for linter "unused" (nolintlint)
	//nolint:unused // ignore false positive
	^
appID int64 // appID is the GitHub App's ID
}

// NewAppsTransportFromPrivateKey returns an AppsTransport using a crypto/rsa.(*PrivateKey).
Expand Down Expand Up @@ -174,6 +175,7 @@ func (t *Transport) Expiry() (expiresAt time.Time, refreshAt time.Time, err erro
if t.token == nil {
return time.Time{}, time.Time{}, errors.New("Expiry() = unknown, err: nil token")
}

return t.token.ExpiresAt, t.token.getRefreshTime(), nil
}

Expand Down Expand Up @@ -207,7 +209,7 @@ func (t *Transport) refreshToken(ctx context.Context) error {

resp, err := t.appsTransport.RoundTrip(req)
if err != nil {
return fmt.Errorf("could not get access_tokens from GitHub API for installation ID %v: %v", t.installationID, err)
return fmt.Errorf("could not get access_tokens from GitHub API for installation ID %v: %w", t.installationID, err)
}

if resp.StatusCode/100 != 2 {
Expand Down

0 comments on commit 6ec7bbc

Please sign in to comment.