From a3d0821f6453056487ac1bc4e0fa2ae79e28462c Mon Sep 17 00:00:00 2001 From: davidvader Date: Tue, 29 Oct 2024 11:12:03 -0500 Subject: [PATCH] chore: more linting --- compiler/types/yaml/build.go | 2 +- compiler/types/yaml/git.go | 2 +- scm/github/app_transport.go | 10 ++++------ scm/github/webhook.go | 5 ++--- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/compiler/types/yaml/build.go b/compiler/types/yaml/build.go index 07e0eae6e..b2a6e872b 100644 --- a/compiler/types/yaml/build.go +++ b/compiler/types/yaml/build.go @@ -18,7 +18,7 @@ type Build struct { Stages StageSlice `yaml:"stages,omitempty" json:"stages,omitempty" jsonschema:"oneof_required=stages,description=Provide parallel execution instructions.\nReference: https://go-vela.github.io/docs/reference/yaml/stages/"` Steps StepSlice `yaml:"steps,omitempty" json:"steps,omitempty" jsonschema:"oneof_required=steps,description=Provide sequential execution instructions.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/"` Templates TemplateSlice `yaml:"templates,omitempty" json:"templates,omitempty" jsonschema:"description=Provide the name of templates to expand.\nReference: https://go-vela.github.io/docs/reference/yaml/templates/"` - Git Git `yaml:"git,omitempty" json:"git,omitempty" jsonschema:"description=Provide the git access specifications.\nReference: https://go-vela.github.io/docs/reference/yaml/git/"` + Git Git `yaml:"git,omitempty" json:"git,omitempty" jsonschema:"description=Provide the git access specifications.\nReference: https://go-vela.github.io/docs/reference/yaml/git/"` } // ToPipelineAPI converts the Build type to an API Pipeline type. diff --git a/compiler/types/yaml/git.go b/compiler/types/yaml/git.go index a71c64f81..7391714e5 100644 --- a/compiler/types/yaml/git.go +++ b/compiler/types/yaml/git.go @@ -13,7 +13,7 @@ type Git struct { // Only applies when using GitHub App installations. type Token struct { Repositories []string `yaml:"repositories,omitempty" json:"repositories,omitempty" jsonschema:"description=Provide a list of repositories to clone.\nReference: https://go-vela.github.io/docs/reference/yaml/git/#repositories"` - Permissions map[string]string `yaml:"permissions,omitempty" json:"permissions,omitempty" jsonschema:"description=Provide a list of repository permissions to apply to the git token.\nReference: https://go-vela.github.io/docs/reference/yaml/git/#permissions"` + Permissions map[string]string `yaml:"permissions,omitempty" json:"permissions,omitempty" jsonschema:"description=Provide a list of repository permissions to apply to the git token.\nReference: https://go-vela.github.io/docs/reference/yaml/git/#permissions"` } // ToPipeline converts the Git type diff --git a/scm/github/app_transport.go b/scm/github/app_transport.go index 070fc4ad8..9857f81fc 100644 --- a/scm/github/app_transport.go +++ b/scm/github/app_transport.go @@ -37,8 +37,7 @@ 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. - //nolint:unused // ignore false positive - appID int64 // appID is the GitHub App's ID + appID int64 // appID is the GitHub App's ID } // NewAppsTransportFromPrivateKey returns an AppsTransport using a crypto/rsa.(*PrivateKey). @@ -67,7 +66,7 @@ func (t *AppsTransport) RoundTrip(req *http.Request) (*http.Response, error) { ss, err := t.signer.Sign(claims) if err != nil { - return nil, fmt.Errorf("could not sign jwt: %s", err) + return nil, fmt.Errorf("could not sign jwt: %w", err) } req.Header.Set("Authorization", "Bearer "+ss) @@ -87,7 +86,6 @@ type Transport struct { BaseURL string // BaseURL is the scheme and host for GitHub API, defaults to https://api.github.com 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 - appID int64 // appID is the GitHub App's ID installationID int64 // installationID is the GitHub App Installation ID InstallationTokenOptions *github.InstallationTokenOptions // parameters restrict a token's access appsTransport *AppsTransport @@ -137,8 +135,8 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { } reqBodyClosed = true - resp, err := t.tr.RoundTrip(creq) - return resp, err + + return t.tr.RoundTrip(creq) } // getRefreshTime returns the time when the token should be refreshed. diff --git a/scm/github/webhook.go b/scm/github/webhook.go index a3bed07e1..54ed1dee5 100644 --- a/scm/github/webhook.go +++ b/scm/github/webhook.go @@ -544,7 +544,7 @@ func (c *client) processRepositoryEvent(h *api.Hook, payload *github.RepositoryE } // processInstallationEvent is a helper function to process the installation event. -func (c *client) processInstallationEvent(ctx context.Context, h *api.Hook, payload *github.InstallationEvent) (*internal.Webhook, error) { +func (c *client) processInstallationEvent(_ context.Context, h *api.Hook, payload *github.InstallationEvent) (*internal.Webhook, error) { h.SetEvent(constants.EventRepository) h.SetEventAction(payload.GetAction()) @@ -559,7 +559,6 @@ func (c *client) processInstallationEvent(ctx context.Context, h *api.Hook, payl for _, repo := range payload.Repositories { install.RepositoriesAdded = append(install.RepositoriesAdded, repo.GetName()) } - break case "deleted": for _, repo := range payload.Repositories { install.RepositoriesRemoved = append(install.RepositoriesRemoved, repo.GetName()) @@ -573,7 +572,7 @@ func (c *client) processInstallationEvent(ctx context.Context, h *api.Hook, payl } // processInstallationRepositoriesEvent is a helper function to process the installation repositories event. -func (c *client) processInstallationRepositoriesEvent(ctx context.Context, h *api.Hook, payload *github.InstallationRepositoriesEvent) (*internal.Webhook, error) { +func (c *client) processInstallationRepositoriesEvent(_ context.Context, h *api.Hook, payload *github.InstallationRepositoriesEvent) (*internal.Webhook, error) { install := new(internal.Installation) install.Action = payload.GetAction()