diff --git a/github/integration_test.go b/github/integration_test.go index d0063c7d..9a11b8ac 100644 --- a/github/integration_test.go +++ b/github/integration_test.go @@ -392,7 +392,7 @@ var _ = Describe("GitHub Provider", func() { if err == nil && !actionTaken { err = errors.New("expecting action taken to be true") } - return retryOp.Retry(err, fmt.Sprintf("reconcile user repository: %s", repoRef.RepositoryName)) + return retryOp.IsRetryable(err, fmt.Sprintf("reconcile user repository: %s", repoRef.RepositoryName)) }, time.Second*90, retryOp.Interval()).Should(BeTrue()) Expect(actionTaken).To(BeTrue()) @@ -410,7 +410,7 @@ var _ = Describe("GitHub Provider", func() { if err == nil && !actionTaken { err = errors.New("expecting action taken to be true") } - return retryOp.Retry(err, fmt.Sprintf("reconcile repository: %s", newRepo.Repository().GetRepository())) + return retryOp.IsRetryable(err, fmt.Sprintf("reconcile repository: %s", newRepo.Repository().GetRepository())) }, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue()) Expect(actionTaken).To(BeTrue()) @@ -435,7 +435,7 @@ var _ = Describe("GitHub Provider", func() { Eventually(func() bool { var err error userRepo, err = c.UserRepositories().Get(ctx, userRepoRef) - return retryOp.Retry(err, fmt.Sprintf("get user repository: %s", userRepoRef.RepositoryName)) + return retryOp.IsRetryable(err, fmt.Sprintf("get user repository: %s", userRepoRef.RepositoryName)) }, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue()) defaultBranch := userRepo.Get().DefaultBranch @@ -448,7 +448,7 @@ var _ = Describe("GitHub Provider", func() { if err == nil && len(commits) == 0 { err = errors.New("empty commits list") } - return retryOp.Retry(err, fmt.Sprintf("get commits, repository: %s", userRepo.Repository().GetRepository())) + return retryOp.IsRetryable(err, fmt.Sprintf("get commits, repository: %s", userRepo.Repository().GetRepository())) }, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue()) latestCommit := commits[0] diff --git a/gitlab/client.go b/gitlab/client.go index 0146043d..ab2d3cc3 100644 --- a/gitlab/client.go +++ b/gitlab/client.go @@ -112,6 +112,6 @@ func (c *Client) UserRepositories() gitprovider.UserRepositoriesClient { } // HasTokenPermission returns true if the given token has the given permissions. -func (c *Client) HasTokenPermission(ctx context.Context, permission gitprovider.TokenPermission) (bool, error) { +func (c *Client) HasTokenPermission(_ context.Context, _ gitprovider.TokenPermission) (bool, error) { return false, gitprovider.ErrNoProviderSupport } diff --git a/gitlab/client_repository_branch.go b/gitlab/client_repository_branch.go index 3e533d0c..feea7cf2 100644 --- a/gitlab/client_repository_branch.go +++ b/gitlab/client_repository_branch.go @@ -18,6 +18,7 @@ package gitlab import ( "context" + "github.com/fluxcd/go-git-providers/gitprovider" "github.com/xanzy/go-gitlab" ) @@ -32,7 +33,7 @@ type BranchClient struct { } // Create creates a branch with the given specifications. -func (c *BranchClient) Create(ctx context.Context, branch, sha string) error { +func (c *BranchClient) Create(_ context.Context, branch, sha string) error { ref := &gitlab.CreateBranchOptions{ Ref: &sha, diff --git a/gitlab/client_repository_commit.go b/gitlab/client_repository_commit.go index 065ccd7b..18ddfefd 100644 --- a/gitlab/client_repository_commit.go +++ b/gitlab/client_repository_commit.go @@ -34,8 +34,8 @@ type CommitClient struct { } // ListPage lists repository commits of the given page and page size. -func (c *CommitClient) ListPage(ctx context.Context, branch string, perPage, page int) ([]gitprovider.Commit, error) { - dks, err := c.listPage(ctx, branch, perPage, page) +func (c *CommitClient) ListPage(_ context.Context, branch string, perPage, page int) ([]gitprovider.Commit, error) { + dks, err := c.listPage(branch, perPage, page) if err != nil { return nil, err } @@ -47,9 +47,9 @@ func (c *CommitClient) ListPage(ctx context.Context, branch string, perPage, pag return commits, nil } -func (c *CommitClient) listPage(ctx context.Context, branch string, perPage, page int) ([]*commitType, error) { +func (c *CommitClient) listPage(branch string, perPage, page int) ([]*commitType, error) { // GET /repos/{owner}/{repo}/commits - apiObjs, err := c.c.ListCommitsPage(ctx, getRepoPath(c.ref), branch, perPage, page) + apiObjs, err := c.c.ListCommitsPage(getRepoPath(c.ref), branch, perPage, page) if err != nil { return nil, err } @@ -64,7 +64,7 @@ func (c *CommitClient) listPage(ctx context.Context, branch string, perPage, pag } // Create creates a commit with the given specifications. -func (c *CommitClient) Create(ctx context.Context, branch string, message string, files []gitprovider.CommitFile) (gitprovider.Commit, error) { +func (c *CommitClient) Create(_ context.Context, branch string, message string, files []gitprovider.CommitFile) (gitprovider.Commit, error) { if len(files) == 0 { return nil, fmt.Errorf("no files added") diff --git a/gitlab/client_repository_deploykey.go b/gitlab/client_repository_deploykey.go index 524258ad..c0fe301c 100644 --- a/gitlab/client_repository_deploykey.go +++ b/gitlab/client_repository_deploykey.go @@ -37,12 +37,12 @@ type DeployKeyClient struct { // Get returns the repository at the given path. // // ErrNotFound is returned if the resource does not exist. -func (c *DeployKeyClient) Get(ctx context.Context, deployKeyName string) (gitprovider.DeployKey, error) { - return c.get(ctx, deployKeyName) +func (c *DeployKeyClient) Get(_ context.Context, deployKeyName string) (gitprovider.DeployKey, error) { + return c.get(deployKeyName) } -func (c *DeployKeyClient) get(ctx context.Context, deployKeyName string) (*deployKey, error) { - deployKeys, err := c.list(ctx) +func (c *DeployKeyClient) get(deployKeyName string) (*deployKey, error) { + deployKeys, err := c.list() if err != nil { return nil, err } @@ -59,8 +59,8 @@ func (c *DeployKeyClient) get(ctx context.Context, deployKeyName string) (*deplo // // List returns all available repository deploy keys for the given type, // using multiple paginated requests if needed. -func (c *DeployKeyClient) List(ctx context.Context) ([]gitprovider.DeployKey, error) { - dks, err := c.list(ctx) +func (c *DeployKeyClient) List(_ context.Context) ([]gitprovider.DeployKey, error) { + dks, err := c.list() if err != nil { return nil, err } @@ -72,9 +72,9 @@ func (c *DeployKeyClient) List(ctx context.Context) ([]gitprovider.DeployKey, er return keys, nil } -func (c *DeployKeyClient) list(ctx context.Context) ([]*deployKey, error) { +func (c *DeployKeyClient) list() ([]*deployKey, error) { // GET /repos/{owner}/{repo}/keys - apiObjs, err := c.c.ListKeys(ctx, getRepoPath(c.ref)) + apiObjs, err := c.c.ListKeys(getRepoPath(c.ref)) if err != nil { return nil, err } @@ -92,8 +92,8 @@ func (c *DeployKeyClient) list(ctx context.Context) ([]*deployKey, error) { // Create creates a deploy key with the given specifications. // // ErrAlreadyExists will be returned if the resource already exists. -func (c *DeployKeyClient) Create(ctx context.Context, req gitprovider.DeployKeyInfo) (gitprovider.DeployKey, error) { - apiObj, err := createDeployKey(ctx, c.c, c.ref, req) +func (c *DeployKeyClient) Create(_ context.Context, req gitprovider.DeployKeyInfo) (gitprovider.DeployKey, error) { + apiObj, err := createDeployKey(c.c, c.ref, req) if err != nil { return nil, err } @@ -138,12 +138,12 @@ func (c *DeployKeyClient) Reconcile(ctx context.Context, req gitprovider.DeployK return actual, true, actual.Update(ctx) } -func createDeployKey(ctx context.Context, c gitlabClient, ref gitprovider.RepositoryRef, req gitprovider.DeployKeyInfo) (*gitlab.DeployKey, error) { +func createDeployKey(c gitlabClient, ref gitprovider.RepositoryRef, req gitprovider.DeployKeyInfo) (*gitlab.DeployKey, error) { // First thing, validate and default the request to ensure a valid and fully-populated object // (to minimize any possible diffs between desired and actual state) if err := gitprovider.ValidateAndDefaultInfo(&req); err != nil { return nil, err } - return c.CreateKey(ctx, fmt.Sprintf("%s/%s", ref.GetIdentity(), ref.GetRepository()), deployKeyToAPI(&req)) + return c.CreateKey(fmt.Sprintf("%s/%s", ref.GetIdentity(), ref.GetRepository()), deployKeyToAPI(&req)) } diff --git a/gitlab/client_repository_pullrequest.go b/gitlab/client_repository_pullrequest.go index b96d41a2..627b3d81 100644 --- a/gitlab/client_repository_pullrequest.go +++ b/gitlab/client_repository_pullrequest.go @@ -38,7 +38,7 @@ type PullRequestClient struct { } // List lists all pull requests in the repository -func (c *PullRequestClient) List(ctx context.Context) ([]gitprovider.PullRequest, error) { +func (c *PullRequestClient) List(_ context.Context) ([]gitprovider.PullRequest, error) { mrs, _, err := c.c.Client().MergeRequests.ListProjectMergeRequests(getRepoPath(c.ref), nil) if err != nil { return nil, err @@ -54,7 +54,7 @@ func (c *PullRequestClient) List(ctx context.Context) ([]gitprovider.PullRequest } // Create creates a pull request with the given specifications. -func (c *PullRequestClient) Create(ctx context.Context, title, branch, baseBranch, description string) (gitprovider.PullRequest, error) { +func (c *PullRequestClient) Create(_ context.Context, title, branch, baseBranch, description string) (gitprovider.PullRequest, error) { prOpts := &gitlab.CreateMergeRequestOptions{ Title: &title, @@ -72,7 +72,7 @@ func (c *PullRequestClient) Create(ctx context.Context, title, branch, baseBranc } // Get retrieves an existing pull request by number -func (c *PullRequestClient) Get(ctx context.Context, number int) (gitprovider.PullRequest, error) { +func (c *PullRequestClient) Get(_ context.Context, number int) (gitprovider.PullRequest, error) { mr, _, err := c.c.Client().MergeRequests.GetMergeRequest(getRepoPath(c.ref), number, &gitlab.GetMergeRequestsOptions{}) if err != nil { @@ -83,7 +83,7 @@ func (c *PullRequestClient) Get(ctx context.Context, number int) (gitprovider.Pu } // Merge merges a pull request with the given specifications. -func (c *PullRequestClient) Merge(ctx context.Context, number int, mergeMethod gitprovider.MergeMethod, message string) error { +func (c *PullRequestClient) Merge(_ context.Context, number int, mergeMethod gitprovider.MergeMethod, message string) error { if err := c.waitForMergeRequestToBeMergeable(number); err != nil { return err } diff --git a/gitlab/client_repository_teamaccess.go b/gitlab/client_repository_teamaccess.go index 9a3ff455..4dfdd482 100644 --- a/gitlab/client_repository_teamaccess.go +++ b/gitlab/client_repository_teamaccess.go @@ -118,7 +118,7 @@ func (c *TeamAccessClient) Create(ctx context.Context, req gitprovider.TeamAcces if err != nil { return nil, err } - if err := c.c.ShareProject(ctx, getRepoPath(c.ref), group.ID, gitlabPermission); err != nil { + if err := c.c.ShareProject(getRepoPath(c.ref), group.ID, gitlabPermission); err != nil { return nil, err } diff --git a/gitlab/gitlabclient.go b/gitlab/gitlabclient.go index 2937409f..22cf804d 100644 --- a/gitlab/gitlabclient.go +++ b/gitlab/gitlabclient.go @@ -80,28 +80,28 @@ type gitlabClient interface { // ListKeys is a wrapper for "GET /projects/{project}/deploy_keys". // This function handles pagination, HTTP error wrapping, and validates the server result. - ListKeys(ctx context.Context, projectName string) ([]*gitlab.DeployKey, error) + ListKeys(projectName string) ([]*gitlab.DeployKey, error) // CreateProjectKey is a wrapper for "POST /projects/{project}/deploy_keys". // This function handles HTTP error wrapping, and validates the server result. - CreateKey(ctx context.Context, projectName string, req *gitlab.DeployKey) (*gitlab.DeployKey, error) + CreateKey(projectName string, req *gitlab.DeployKey) (*gitlab.DeployKey, error) // DeleteKey is a wrapper for "DELETE /projects/{project}/deploy_keys/{key_id}". // This function handles HTTP error wrapping. - DeleteKey(ctx context.Context, projectName string, keyID int) error + DeleteKey(projectName string, keyID int) error // Team related methods // ShareGroup is a wrapper for "" // This function handles HTTP error wrapping, and validates the server result. - ShareProject(ctx context.Context, projectName string, groupID, groupAccess int) error + ShareProject(projectName string, groupID, groupAccess int) error // UnshareProject is a wrapper for "" // This function handles HTTP error wrapping, and validates the server result. - UnshareProject(ctx context.Context, projectName string, groupID int) error + UnshareProject(projectName string, groupID int) error // Commits // ListCommitsPage is a wrapper for "GET /projects/{project}/repository/commits". // This function handles pagination, HTTP error wrapping. - ListCommitsPage(ctx context.Context, projectName, branch string, perPage int, page int) ([]*gitlab.Commit, error) + ListCommitsPage(projectName, branch string, perPage int, page int) ([]*gitlab.Commit, error) } // gitlabClientImpl is a wrapper around *gitlab.Client, which implements higher-level methods, @@ -329,7 +329,7 @@ func (c *gitlabClientImpl) DeleteProject(ctx context.Context, projectName string return err } -func (c *gitlabClientImpl) ListKeys(ctx context.Context, projectName string) ([]*gitlab.DeployKey, error) { +func (c *gitlabClientImpl) ListKeys(projectName string) ([]*gitlab.DeployKey, error) { apiObjs := []*gitlab.DeployKey{} opts := &gitlab.ListProjectDeployKeysOptions{} err := allDeployKeyPages(opts, func() (*gitlab.Response, error) { @@ -350,7 +350,7 @@ func (c *gitlabClientImpl) ListKeys(ctx context.Context, projectName string) ([] return apiObjs, nil } -func (c *gitlabClientImpl) CreateKey(ctx context.Context, projectName string, req *gitlab.DeployKey) (*gitlab.DeployKey, error) { +func (c *gitlabClientImpl) CreateKey(projectName string, req *gitlab.DeployKey) (*gitlab.DeployKey, error) { opts := &gitlab.AddDeployKeyOptions{ Title: &req.Title, Key: &req.Key, @@ -367,13 +367,13 @@ func (c *gitlabClientImpl) CreateKey(ctx context.Context, projectName string, re return apiObj, nil } -func (c *gitlabClientImpl) DeleteKey(ctx context.Context, projectName string, keyID int) error { +func (c *gitlabClientImpl) DeleteKey(projectName string, keyID int) error { // DELETE /projects/{project}/deploy_keys _, err := c.c.DeployKeys.DeleteDeployKey(projectName, keyID) return handleHTTPError(err) } -func (c *gitlabClientImpl) ShareProject(ctx context.Context, projectName string, groupIDObj, groupAccessObj int) error { +func (c *gitlabClientImpl) ShareProject(projectName string, groupIDObj, groupAccessObj int) error { groupAccess := gitlab.AccessLevel(gitlab.AccessLevelValue(groupAccessObj)) groupID := &groupIDObj opt := &gitlab.ShareWithGroupOptions{ @@ -385,12 +385,12 @@ func (c *gitlabClientImpl) ShareProject(ctx context.Context, projectName string, return handleHTTPError(err) } -func (c *gitlabClientImpl) UnshareProject(ctx context.Context, projectName string, groupID int) error { +func (c *gitlabClientImpl) UnshareProject(projectName string, groupID int) error { _, err := c.c.Projects.DeleteSharedProjectFromGroup(projectName, groupID) return handleHTTPError(err) } -func (c *gitlabClientImpl) ListCommitsPage(ctx context.Context, projectName string, branch string, perPage int, page int) ([]*gitlab.Commit, error) { +func (c *gitlabClientImpl) ListCommitsPage(projectName string, branch string, perPage int, page int) ([]*gitlab.Commit, error) { apiObjs := make([]*gitlab.Commit, 0) opts := gitlab.ListCommitsOptions{ diff --git a/gitlab/integration_test.go b/gitlab/integration_test.go index 0d024541..f844068e 100644 --- a/gitlab/integration_test.go +++ b/gitlab/integration_test.go @@ -433,7 +433,7 @@ var _ = Describe("GitLab Provider", func() { AutoInit: gitprovider.BoolVar(true), LicenseTemplate: gitprovider.LicenseTemplateVar(gitprovider.LicenseTemplateMIT), }) - return retryOp.Retry(err, fmt.Sprintf("reconcile org repository: %s", repoRef.RepositoryName)) + return retryOp.IsRetryable(err, fmt.Sprintf("reconcile org repository: %s", repoRef.RepositoryName)) }, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue()) Expect(actionTaken).To(BeTrue()) @@ -722,7 +722,7 @@ var _ = Describe("GitLab Provider", func() { AutoInit: gitprovider.BoolVar(true), LicenseTemplate: gitprovider.LicenseTemplateVar(gitprovider.LicenseTemplateMIT), }) - return retryOp.Retry(err, fmt.Sprintf("new user repository: %s", repoRef.RepositoryName)) + return retryOp.IsRetryable(err, fmt.Sprintf("new user repository: %s", repoRef.RepositoryName)) }, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue()) // Expect the create to succeed, and have modified the state. Also validate the newRepo data @@ -757,7 +757,7 @@ var _ = Describe("GitLab Provider", func() { if err == nil && len(commits) == 0 { err = errors.New("empty commits list") } - return retryOp.Retry(err, fmt.Sprintf("get commits, repository: %s", userRepo.Repository().GetRepository())) + return retryOp.IsRetryable(err, fmt.Sprintf("get commits, repository: %s", userRepo.Repository().GetRepository())) }, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue()) latestCommit := commits[0] diff --git a/gitlab/resource_deploykey.go b/gitlab/resource_deploykey.go index 6dc1a4bc..b509c8d4 100644 --- a/gitlab/resource_deploykey.go +++ b/gitlab/resource_deploykey.go @@ -78,20 +78,20 @@ func (dk *deployKey) Update(ctx context.Context) error { if err := dk.Delete(ctx); err != nil { return err } - return dk.createIntoSelf(ctx) + return dk.createIntoSelf() } // Delete deletes a deploy key from the repository. // // ErrNotFound is returned if the resource does not exist. -func (dk *deployKey) Delete(ctx context.Context) error { +func (dk *deployKey) Delete(_ context.Context) error { // We can use the same DeployKey ID that we got from the GET calls. Make sure it's non-nil. // This _should never_ happen, but just check for it anyways to avoid panicing. if dk.k.ID == 0 { return fmt.Errorf("didn't expect ID to be 0: %w", gitprovider.ErrUnexpectedEvent) } - return dk.c.c.DeleteKey(ctx, getRepoPath(dk.c.ref), dk.k.ID) + return dk.c.c.DeleteKey(getRepoPath(dk.c.ref), dk.k.ID) } // Reconcile makes sure the desired state in this object (called "req" here) becomes @@ -103,11 +103,11 @@ func (dk *deployKey) Delete(ctx context.Context) error { // // The internal API object will be overridden with the received server data if actionTaken == true. func (dk *deployKey) Reconcile(ctx context.Context) (bool, error) { - actual, err := dk.c.get(ctx, dk.k.Title) + actual, err := dk.c.get(dk.k.Title) if err != nil { // Create if not found if errors.Is(err, gitprovider.ErrNotFound) { - return true, dk.createIntoSelf(ctx) + return true, dk.createIntoSelf() } // Unexpected path, Get should succeed or return NotFound @@ -126,9 +126,9 @@ func (dk *deployKey) Reconcile(ctx context.Context) (bool, error) { return true, dk.Update(ctx) } -func (dk *deployKey) createIntoSelf(ctx context.Context) error { +func (dk *deployKey) createIntoSelf() error { // POST /repos/{owner}/{repo}/keys - apiObj, err := dk.c.c.CreateKey(ctx, getRepoPath(dk.c.ref), &dk.k) + apiObj, err := dk.c.c.CreateKey(getRepoPath(dk.c.ref), &dk.k) if err != nil { return err } diff --git a/gitlab/resource_teamaccess.go b/gitlab/resource_teamaccess.go index 45ed2532..46a247c5 100644 --- a/gitlab/resource_teamaccess.go +++ b/gitlab/resource_teamaccess.go @@ -63,7 +63,7 @@ func (ta *teamAccess) Delete(ctx context.Context) error { if err != nil { return err } - return ta.c.c.UnshareProject(ctx, getRepoPath(ta.c.ref), group.ID) + return ta.c.c.UnshareProject(getRepoPath(ta.c.ref), group.ID) } func (ta *teamAccess) Update(ctx context.Context) error { @@ -74,7 +74,7 @@ func (ta *teamAccess) Update(ctx context.Context) error { if err != nil { return err } - err = ta.c.c.UnshareProject(ctx, getRepoPath(ta.c.ref), group.ID) + err = ta.c.c.UnshareProject(getRepoPath(ta.c.ref), group.ID) if err != nil { return err } diff --git a/gitprovider/client_options.go b/gitprovider/client_options.go index d306fabe..874ec099 100644 --- a/gitprovider/client_options.go +++ b/gitprovider/client_options.go @@ -128,11 +128,11 @@ func BuildClientFromTransportChain(chain []ChainableRoundTripperFunc) (*http.Cli // The clientOptions struct is private to force usage of the With... functions. type ClientOption interface { // ApplyToClientOptions applies set fields of this object into target. - ApplyToClientOptions(target *clientOptions) error + ApplyToClientOptions(target *ClientOptions) error } -// clientOptions is the struct that tracks data about what options have been set. -type clientOptions struct { +// ClientOptions is the struct that tracks data about what options have been set. +type ClientOptions struct { // clientOptions shares all the common options CommonClientOptions @@ -145,7 +145,7 @@ type clientOptions struct { // ApplyToClientOptions implements ClientOption, and applies the set fields of opts // into target. If both opts and target has the same specific field set, ErrInvalidClientOptions is returned. -func (opts *clientOptions) ApplyToClientOptions(target *clientOptions) error { +func (opts *ClientOptions) ApplyToClientOptions(target *ClientOptions) error { // Apply common values, if any if err := opts.CommonClientOptions.ApplyToCommonClientOptions(&target.CommonClientOptions); err != nil { return err @@ -171,7 +171,7 @@ func (opts *clientOptions) ApplyToClientOptions(target *clientOptions) error { // GetTransportChain builds the full chain of transports (from left to right, // as per gitprovider.BuildClientFromTransportChain) of the form described in NewClient. -func (opts *clientOptions) GetTransportChain() (chain []ChainableRoundTripperFunc) { +func (opts *ClientOptions) GetTransportChain() (chain []ChainableRoundTripperFunc) { if opts.PostChainTransportHook != nil { chain = append(chain, opts.PostChainTransportHook) } @@ -190,8 +190,8 @@ func (opts *clientOptions) GetTransportChain() (chain []ChainableRoundTripperFun } // buildCommonOption is a helper for returning a ClientOption out of a common option field. -func buildCommonOption(opt CommonClientOptions) *clientOptions { - return &clientOptions{CommonClientOptions: opt} +func buildCommonOption(opt CommonClientOptions) *ClientOptions { + return &ClientOptions{CommonClientOptions: opt} } // errorOption implements ClientOption, and just wraps an error which is immediately returned. @@ -202,7 +202,7 @@ type errorOption struct { } // ApplyToClientOptions implements ClientOption, but just returns the internal error. -func (e *errorOption) ApplyToClientOptions(*clientOptions) error { return e.err } +func (e *errorOption) ApplyToClientOptions(*ClientOptions) error { return e.err } // optionError is a constructor for errorOption. func optionError(err error) ClientOption { @@ -260,7 +260,7 @@ func WithOAuth2Token(oauth2Token string) ClientOption { return optionError(fmt.Errorf("oauth2Token cannot be empty: %w", ErrInvalidClientOptions)) } - return &clientOptions{authTransport: oauth2Transport(oauth2Token)} + return &ClientOptions{authTransport: oauth2Transport(oauth2Token)} } func oauth2Transport(oauth2Token string) ChainableRoundTripperFunc { @@ -279,12 +279,12 @@ func oauth2Transport(oauth2Token string) ChainableRoundTripperFunc { // See: https://gitlab.com/gitlab.org/gitlab.foss/-/issues/26926, and // https://docs.gitlab.com/ee/development/polling.html for more info. func WithConditionalRequests(conditionalRequests bool) ClientOption { - return &clientOptions{enableConditionalRequests: &conditionalRequests} + return &ClientOptions{enableConditionalRequests: &conditionalRequests} } // MakeClientOptions assembles a clientOptions struct from ClientOption mutator functions. -func MakeClientOptions(opts ...ClientOption) (*clientOptions, error) { - o := &clientOptions{} +func MakeClientOptions(opts ...ClientOption) (*ClientOptions, error) { + o := &ClientOptions{} for _, opt := range opts { if err := opt.ApplyToClientOptions(o); err != nil { return nil, err diff --git a/gitprovider/client_options_test.go b/gitprovider/client_options_test.go index 6f377551..bcd2e174 100644 --- a/gitprovider/client_options_test.go +++ b/gitprovider/client_options_test.go @@ -193,7 +193,7 @@ func Test_clientOptions_getTransportChain(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { dummy := "dummy" - opts := &clientOptions{ + opts := &ClientOptions{ CommonClientOptions: CommonClientOptions{ Domain: &dummy, PreChainTransportHook: tt.preChain, @@ -215,12 +215,12 @@ func Test_makeCientOptions(t *testing.T) { tests := []struct { name string opts []ClientOption - want *clientOptions + want *ClientOptions expectedErrs []error }{ { name: "no options", - want: &clientOptions{}, + want: &ClientOptions{}, }, { name: "WithDomain", @@ -260,7 +260,7 @@ func Test_makeCientOptions(t *testing.T) { { name: "WithOAuth2Token", opts: []ClientOption{WithOAuth2Token("foo")}, - want: &clientOptions{authTransport: oauth2Transport("foo")}, + want: &ClientOptions{authTransport: oauth2Transport("foo")}, }, { name: "WithOAuth2Token, empty", @@ -270,7 +270,7 @@ func Test_makeCientOptions(t *testing.T) { { name: "WithConditionalRequests", opts: []ClientOption{WithConditionalRequests(true)}, - want: &clientOptions{enableConditionalRequests: BoolVar(true)}, + want: &ClientOptions{enableConditionalRequests: BoolVar(true)}, }, { name: "WithConditionalRequests, exclusive", diff --git a/gitprovider/enums.go b/gitprovider/enums.go index 7329e3fc..9365b515 100644 --- a/gitprovider/enums.go +++ b/gitprovider/enums.go @@ -170,12 +170,13 @@ const ( TokenPermissionRWRepository TokenPermission = iota + 1 ) +// MergeMethod is an enum specifying the merge method for a pull request. type MergeMethod string const ( // MergeMethodMerge causes a pull request merge to create a simple merge commit MergeMethodMerge = MergeMethod("merge") - // MergeMethodMerge causes a pull request merge to first squash commits + // MergeMethodSquash causes a pull request merge to first squash commits MergeMethodSquash = MergeMethod("squash") ) diff --git a/gitprovider/repositoryref.go b/gitprovider/repositoryref.go index aa75eb70..9d6bd15b 100644 --- a/gitprovider/repositoryref.go +++ b/gitprovider/repositoryref.go @@ -318,14 +318,17 @@ func GetCloneURL(rs RepositoryRef, transport TransportType) string { return "" } +// ParseTypeHTTPS returns the HTTPS URL to clone a repository. func ParseTypeHTTPS(url string) string { return fmt.Sprintf("%s.git", url) } +// ParseTypeGit returns the URL to clone a repository using the Git protocol. func ParseTypeGit(domain, identity, repository string) string { return fmt.Sprintf("git@%s:%s/%s.git", domain, identity, repository) } +// ParseTypeSSH returns the URL to clone a repository using the SSH protocol. func ParseTypeSSH(domain, identity, repository string) string { trimmedDomain := domain trimmedDomain = strings.Replace(trimmedDomain, "https://", "", -1) diff --git a/gitprovider/testutils/key_pair.go b/gitprovider/testutils/key_pair.go index e6e79a6a..30b075d9 100644 --- a/gitprovider/testutils/key_pair.go +++ b/gitprovider/testutils/key_pair.go @@ -34,18 +34,22 @@ type KeyPair struct { PrivateKey []byte } +// KeyPairGenerator generates a new key pair. type KeyPairGenerator interface { Generate() (*KeyPair, error) } +// RSAGenerator generates RSA key pairs. type RSAGenerator struct { bits int } +// NewRSAGenerator returns a new RSA key pair generator. func NewRSAGenerator(bits int) KeyPairGenerator { return &RSAGenerator{bits} } +// Generate generates a new key pair. func (g *RSAGenerator) Generate() (*KeyPair, error) { pk, err := rsa.GenerateKey(rand.Reader, g.bits) if err != nil { @@ -69,14 +73,17 @@ func (g *RSAGenerator) Generate() (*KeyPair, error) { }, nil } +// ECDSAGenerator generates ECDSA key pairs. type ECDSAGenerator struct { c elliptic.Curve } +// NewECDSAGenerator returns a new ECDSA key pair generator. func NewECDSAGenerator(c elliptic.Curve) KeyPairGenerator { return &ECDSAGenerator{c} } +// Generate generates a new key pair. func (g *ECDSAGenerator) Generate() (*KeyPair, error) { pk, err := ecdsa.GenerateKey(g.c, rand.Reader) if err != nil { @@ -96,12 +103,15 @@ func (g *ECDSAGenerator) Generate() (*KeyPair, error) { }, nil } +// Ed25519Generator generates Ed25519 key pairs. type Ed25519Generator struct{} +// NewEd25519Generator returns a new Ed25519 key pair generator. func NewEd25519Generator() KeyPairGenerator { return &Ed25519Generator{} } +// Generate generates a new key pair. func (g *Ed25519Generator) Generate() (*KeyPair, error) { pk, pv, err := ed25519.GenerateKey(rand.Reader) if err != nil { diff --git a/gitprovider/testutils/retry.go b/gitprovider/testutils/retry.go index b27f55c6..2dc081b8 100644 --- a/gitprovider/testutils/retry.go +++ b/gitprovider/testutils/retry.go @@ -22,8 +22,9 @@ import ( "time" ) +// RetryI is an interface for retry operations type RetryI interface { - Retry(err error, opDesc string) bool + IsRetryable(err error, opDesc string) bool SetTimeout(timeout time.Duration) SetInterval(interval time.Duration) SetBackoff(backoff time.Duration) @@ -34,6 +35,7 @@ type RetryI interface { Retries() int } +// RetryOp is a retry operation type RetryOp struct { RetryI timeout time.Duration @@ -43,39 +45,48 @@ type RetryOp struct { counter int } +// Timeout returns the timeout for the retry operation func (r RetryOp) Timeout() time.Duration { return r.timeout } +// Interval returns the interval for the retry operation func (r RetryOp) Interval() time.Duration { return r.interval } +// Backoff returns the backoff for the retry operation func (r RetryOp) Backoff() time.Duration { return r.backoff } +// Retries returns the number of retries for the retry operation func (r RetryOp) Retries() int { return r.retries } +// SetTimeout sets the timeout for the retry operation func (r RetryOp) SetTimeout(timeout time.Duration) { r.timeout = timeout } +// SetInterval sets the interval for the retry operation func (r RetryOp) SetInterval(interval time.Duration) { r.interval = interval } +// SetBackoff sets the backoff for the retry operation func (r RetryOp) SetBackoff(backoff time.Duration) { r.backoff = backoff } +// SetRetries sets the number of retries for the retry operation func (r RetryOp) SetRetries(retries int) { r.retries = retries } -func (r RetryOp) Retry(err error, opDesc string) bool { +// IsRetryable returns true if the operation is retryable +func (r RetryOp) IsRetryable(err error, opDesc string) bool { if err == nil { return true } @@ -89,6 +100,7 @@ func (r RetryOp) Retry(err error, opDesc string) bool { return false } +// NewRetry returns a new retry operation func NewRetry() RetryI { r := RetryOp{ retries: 10, diff --git a/revive/config.toml b/revive/config.toml index 6e994d3b..b53e3413 100644 --- a/revive/config.toml +++ b/revive/config.toml @@ -12,8 +12,6 @@ warningCode = 0 [rule.error-strings] [rule.error-naming] [rule.exported] -[rule.function-length] - arguments = [40,60] [rule.function-result-limit] arguments = [3] [rule.if-return] diff --git a/stash/client.go b/stash/client.go index 42df5f3c..c00c5c04 100644 --- a/stash/client.go +++ b/stash/client.go @@ -273,7 +273,7 @@ func (c *Client) retryHTTPCheck(ctx context.Context, resp *http.Response, err er func (c *Client) retryHTTPBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration { // Use the rate limit backoff function when we are rate limited. if resp != nil && resp.StatusCode == http.StatusTooManyRequests { - return rateLimitBackoff(min, max, attemptNum, resp) + return rateLimitBackoff(min, max, resp) } // Set custom duration when we experience a service interruption. @@ -290,7 +290,7 @@ func (c *Client) retryHTTPBackoff(min, max time.Duration, attemptNum int, resp * // min and max are mainly used for bounding the jitter that will be added to // the reset time retrieved from the headers. But if the final wait time is // less then min, min will be used instead. -func rateLimitBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration { +func rateLimitBackoff(min, max time.Duration, resp *http.Response) time.Duration { // rnd is used to generate pseudo-random numbers. rnd := rand.New(rand.NewSource(time.Now().UnixNano())) diff --git a/stash/client_organizations.go b/stash/client_organizations.go index f93b512e..0d7ae80f 100644 --- a/stash/client_organizations.go +++ b/stash/client_organizations.go @@ -93,7 +93,7 @@ func (c *OrganizationsClient) List(ctx context.Context) ([]gitprovider.Organizat // Children returns the immediate child-organizations for the specific OrganizationRef o. // The OrganizationRef may point to any existing sub-organization. // Children returns all available organizations, using multiple paginated requests if needed. -func (c *OrganizationsClient) Children(ctx context.Context, ref gitprovider.OrganizationRef) ([]gitprovider.Organization, error) { +func (c *OrganizationsClient) Children(_ context.Context, _ gitprovider.OrganizationRef) ([]gitprovider.Organization, error) { return nil, gitprovider.ErrNoProviderSupport } diff --git a/stash/client_repositories_org.go b/stash/client_repositories_org.go index ceaf5785..30f16242 100644 --- a/stash/client_repositories_org.go +++ b/stash/client_repositories_org.go @@ -183,7 +183,7 @@ func update(ctx context.Context, c *Client, orgKey, repoSlug string, repository return apiObj, nil } -func delete(ctx context.Context, c *Client, orgKey, repoSlug string) error { +func deleteRepository(ctx context.Context, c *Client, orgKey, repoSlug string) error { if err := c.Repositories.Delete(ctx, orgKey, repoSlug); err != nil { return fmt.Errorf("failed to delete repository: %w", err) } @@ -310,7 +310,7 @@ func setDefaultBranch(ctx context.Context, c *Client, orgKey, branch string, rep } func initRepo(ctx context.Context, c *Client, initCommit *CreateCommit, repo *Repository) error { - r, dir, err := c.Git.InitRepository(ctx, initCommit, true) + r, dir, err := c.Git.InitRepository(initCommit, true) if err != nil { if err := c.Repositories.Delete(ctx, repo.Project.Key, repo.Slug); err != nil { return fmt.Errorf("failed to delete repository: %w", err) diff --git a/stash/client_repository_branch.go b/stash/client_repository_branch.go index 04ca4e15..45dea357 100644 --- a/stash/client_repository_branch.go +++ b/stash/client_repository_branch.go @@ -72,7 +72,7 @@ func (c *BranchClient) Create(ctx context.Context, branch, sha string) error { WithMessage("Create branch"), WithURL(url)) - _, err = c.client.Git.CreateCommit(ctx, dir, r, "", commit) + _, err = c.client.Git.CreateCommit(dir, r, "", commit) if err != nil { return fmt.Errorf("failed to create commit: %w", err) } diff --git a/stash/client_repository_commit.go b/stash/client_repository_commit.go index 888eac51..d17b0f0f 100644 --- a/stash/client_repository_commit.go +++ b/stash/client_repository_commit.go @@ -107,7 +107,7 @@ func (c *CommitClient) Create(ctx context.Context, branch string, message string WithURL(url), WithFiles(f)) - result, err := c.client.Git.CreateCommit(ctx, dir, r, branch, commit) + result, err := c.client.Git.CreateCommit(dir, r, branch, commit) if err != nil { return nil, fmt.Errorf("failed to create commit: %w", err) } diff --git a/stash/client_repository_deploykey.go b/stash/client_repository_deploykey.go index b2320cc2..e2230b1a 100644 --- a/stash/client_repository_deploykey.go +++ b/stash/client_repository_deploykey.go @@ -22,6 +22,7 @@ import ( "fmt" "github.com/fluxcd/go-git-providers/gitprovider" + "github.com/fluxcd/go-git-providers/validation" "github.com/hashicorp/go-multierror" ) @@ -169,7 +170,7 @@ func (c *DeployKeyClient) Reconcile(ctx context.Context, req gitprovider.DeployK return actual, false, err } // Apply the desired state by running Update - _, err = c.update(ctx, actual.Repository(), actual.Get()) + _, err = c.update(ctx, actual.Get()) if err != nil { return actual, false, fmt.Errorf("failed to update deploy key %q: %w", req.Name, err) } @@ -178,9 +179,9 @@ func (c *DeployKeyClient) Reconcile(ctx context.Context, req gitprovider.DeployK // update will apply the desired state in this object to the server. // ErrNotFound is returned if the resource does not exist. -func (c *DeployKeyClient) update(ctx context.Context, ref gitprovider.RepositoryRef, req gitprovider.DeployKeyInfo) (*DeployKey, error) { +func (c *DeployKeyClient) update(ctx context.Context, req gitprovider.DeployKeyInfo) (*DeployKey, error) { // Delete the old key and recreate - if err := c.delete(ctx, ref, req); err != nil { + if err := c.delete(ctx, req); err != nil { return nil, err } @@ -200,7 +201,7 @@ func (c *DeployKeyClient) update(ctx context.Context, ref gitprovider.Repository return apiObj, nil } -func (c *DeployKeyClient) delete(ctx context.Context, ref gitprovider.RepositoryRef, req gitprovider.DeployKeyInfo) error { +func (c *DeployKeyClient) delete(ctx context.Context, req gitprovider.DeployKeyInfo) error { projectKey, repoSlug := getStashRefs(c.ref) // check if it is a user repository @@ -245,9 +246,18 @@ func deployKeyToAPI(orgKey, repoSlug string, info *gitprovider.DeployKeyInfo) *D return k } -// TO DO: Implement this func validateDeployKeyAPI(apiObj *DeployKey) error { - return nil + return validateAPIObject("Stash.DeployKey", func(validator validation.Validator) { + // Make sure name is set + if apiObj.Permission == "" { + validator.Required("Permission") + } + + // Make sure key is set + if apiObj.Key.Label == "" { + validator.Required("Key.Label") + } + }) } func deployKeyFromAPI(apiObj *DeployKey) gitprovider.DeployKeyInfo { diff --git a/stash/client_repository_pullrequest.go b/stash/client_repository_pullrequest.go index 1d442eba..dd1384d5 100644 --- a/stash/client_repository_pullrequest.go +++ b/stash/client_repository_pullrequest.go @@ -78,7 +78,7 @@ func (c *PullRequestClient) List(ctx context.Context) ([]gitprovider.PullRequest // Merge merges the pull request. // Stash does not support message and merge strategy options for pull requests automatic merges. -func (c *PullRequestClient) Merge(ctx context.Context, number int, mergeMethod gitprovider.MergeMethod, message string) error { +func (c *PullRequestClient) Merge(ctx context.Context, number int, _ gitprovider.MergeMethod, _ string) error { projectKey, repoSlug := getStashRefs(c.ref) // check if it is a user repository diff --git a/stash/git.go b/stash/git.go index df7d00dd..3408694b 100644 --- a/stash/git.go +++ b/stash/git.go @@ -65,7 +65,7 @@ type CleanCloner interface { // CleanIniter interface defines the methods that can be used to initialize a repository // and clean it up afterwards. type CleanIniter interface { - InitRepository(ctx context.Context, c *CreateCommit, createRemote bool) (r *git.Repository, dir string, err error) + InitRepository(c *CreateCommit, createRemote bool) (r *git.Repository, dir string, err error) Cleaner } @@ -76,7 +76,7 @@ type Cleaner interface { // Committer interface defines the methods that can be used to commit to a repository type Committer interface { - CreateCommit(ctx context.Context, rPath string, r *git.Repository, branchName string, c *CreateCommit) (*Commit, error) + CreateCommit(rPath string, r *git.Repository, branchName string, c *CreateCommit) (*Commit, error) } // Brancher interface defines the methods that can be used to create a new branch @@ -246,7 +246,7 @@ func NewCommit(opts ...GitCommitOptionsFunc) (*CreateCommit, error) { // The commit is signed with the given SignKey when provided. // When committer is nil, author is used as the committer. // An optional branch name can be provided to checkout the branch before committing. -func (s *GitService) CreateCommit(ctx context.Context, rPath string, r *git.Repository, branchName string, c *CreateCommit) (*Commit, error) { +func (s *GitService) CreateCommit(rPath string, r *git.Repository, branchName string, c *CreateCommit) (*Commit, error) { if c == nil { return nil, errors.New("commit must be provided") } @@ -435,7 +435,7 @@ func (s *GitService) CreateBranch(branchName string, r *git.Repository, commitID // InitRepository is a function to create a new repository. // The caller must clean up the directory after the function returns. -func (s *GitService) InitRepository(ctx context.Context, c *CreateCommit, createRemote bool) (r *git.Repository, dir string, err error) { +func (s *GitService) InitRepository(c *CreateCommit, createRemote bool) (r *git.Repository, dir string, err error) { dir, err = os.MkdirTemp("", "repo-*") if err != nil { return nil, "", err diff --git a/stash/git_test.go b/stash/git_test.go index f8a39398..6537491d 100644 --- a/stash/git_test.go +++ b/stash/git_test.go @@ -17,7 +17,6 @@ limitations under the License. package stash import ( - "context" "testing" "time" @@ -199,16 +198,15 @@ func TestCreateCommit(t *testing.T) { t.Fatalf("unexpected error while declaring a client: %v", err) } - ctx := context.Background() //Init repo - r, dir, err := c.Git.InitRepository(ctx, &initCommit, false) + r, dir, err := c.Git.InitRepository(&initCommit, false) if err != nil { t.Fatalf("unexpected error while init repo: %v", err) } defer c.Git.Cleanup(dir) // create a commit - obj, err := c.Git.CreateCommit(ctx, dir, r, "testbranch", &testCommit) + obj, err := c.Git.CreateCommit(dir, r, "testbranch", &testCommit) if diff := cmp.Diff(testCommit.Author, obj.Author); diff != "" { t.Errorf("Author mismatch (-want +got):\n%s", diff) diff --git a/stash/integration_repositories_org_test.go b/stash/integration_repositories_org_test.go index 6cd0827d..20f68343 100644 --- a/stash/integration_repositories_org_test.go +++ b/stash/integration_repositories_org_test.go @@ -182,7 +182,7 @@ var _ = Describe("Stash Provider", func() { AutoInit: gitprovider.BoolVar(true), LicenseTemplate: gitprovider.LicenseTemplateVar(gitprovider.LicenseTemplateMIT), }) - return retryOp.Retry(err, fmt.Sprintf("reconcile org repository: %s", repoRef.RepositoryName)) + return retryOp.IsRetryable(err, fmt.Sprintf("reconcile org repository: %s", repoRef.RepositoryName)) }, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue()) Expect(actionTaken).To(BeTrue()) @@ -399,7 +399,7 @@ var _ = Describe("Stash Provider", func() { if err == nil && len(commits) == 0 { err = errors.New("empty commits list") } - return retryOp.Retry(err, fmt.Sprintf("get commits, repository: %s", orgRepo.Repository().GetRepository())) + return retryOp.IsRetryable(err, fmt.Sprintf("get commits, repository: %s", orgRepo.Repository().GetRepository())) }, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue()) latestCommit := commits[0] diff --git a/stash/integration_repositories_user_test.go b/stash/integration_repositories_user_test.go index 34a47df7..c72c4105 100644 --- a/stash/integration_repositories_user_test.go +++ b/stash/integration_repositories_user_test.go @@ -158,7 +158,7 @@ var _ = Describe("Stash Provider", func() { AutoInit: gitprovider.BoolVar(true), LicenseTemplate: gitprovider.LicenseTemplateVar(gitprovider.LicenseTemplateMIT), }) - return retryOp.Retry(err, fmt.Sprintf("new user repository: %s", repoRef.RepositoryName)) + return retryOp.IsRetryable(err, fmt.Sprintf("new user repository: %s", repoRef.RepositoryName)) }, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue()) // Expect the create to succeed, and have modified the state. Also validate the newRepo data @@ -190,7 +190,7 @@ var _ = Describe("Stash Provider", func() { if err == nil && len(commits) == 0 { err = errors.New("empty commits list") } - return retryOp.Retry(err, fmt.Sprintf("get commits, repository: %s", userRepo.Repository().GetRepository())) + return retryOp.IsRetryable(err, fmt.Sprintf("get commits, repository: %s", userRepo.Repository().GetRepository())) }, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue()) latestCommit := commits[0] diff --git a/stash/resource_deploykey.go b/stash/resource_deploykey.go index a1637f17..d3bb6f24 100644 --- a/stash/resource_deploykey.go +++ b/stash/resource_deploykey.go @@ -74,7 +74,7 @@ func (dk *deployKey) Repository() gitprovider.RepositoryRef { // The internal API object will be overridden with the received server data. func (dk *deployKey) Update(ctx context.Context) error { // update by calling client - apiObj, err := dk.c.update(ctx, dk.Repository(), dk.Get()) + apiObj, err := dk.c.update(ctx, dk.Get()) if err != nil { // Log the error and return it dk.c.log.V(1).Error(err, "failed to update deploy key", "org", dk.Repository().GetIdentity(), "repo", dk.Repository().GetRepository()) @@ -87,7 +87,7 @@ func (dk *deployKey) Update(ctx context.Context) error { // Delete deletes a deploy key from the repository. // ErrNotFound is returned if the resource does not exist. func (dk *deployKey) Delete(ctx context.Context) error { - return dk.c.delete(ctx, dk.Repository(), dk.Get()) + return dk.c.delete(ctx, dk.Get()) } // Reconcile makes sure the desired state in this object (called "req" here) becomes diff --git a/stash/resource_repository.go b/stash/resource_repository.go index 58eab6c5..eae37504 100644 --- a/stash/resource_repository.go +++ b/stash/resource_repository.go @@ -144,7 +144,7 @@ func (r *userRepository) Reconcile(ctx context.Context) (bool, error) { // ErrNotFound is returned if the resource doesn't exist anymore. func (r *userRepository) Delete(ctx context.Context) error { ref := r.ref.(gitprovider.UserRepositoryRef) - return delete(ctx, r.c.client, addTilde(ref.UserLogin), ref.Slug()) + return deleteRepository(ctx, r.c.client, addTilde(ref.UserLogin), ref.Slug()) } // GetCloneURL returns a formatted string that can be used for cloning @@ -238,7 +238,7 @@ func (r *orgRepository) Update(ctx context.Context) error { // ErrNotFound is returned if the resource doesn't exist anymore. func (r *orgRepository) Delete(ctx context.Context) error { ref := r.ref.(gitprovider.OrgRepositoryRef) - return delete(ctx, r.c.client, ref.Key(), ref.Slug()) + return deleteRepository(ctx, r.c.client, ref.Key(), ref.Slug()) } func repositoryFromAPI(apiObj *Repository) gitprovider.RepositoryInfo { diff --git a/stash/resource_teamaccess.go b/stash/resource_teamaccess.go index 267c9564..0bce6170 100644 --- a/stash/resource_teamaccess.go +++ b/stash/resource_teamaccess.go @@ -78,7 +78,7 @@ func (ta *teamAccess) Repository() gitprovider.RepositoryRef { return ta.c.ref } -func (ta *teamAccess) Delete(ctx context.Context) error { +func (ta *teamAccess) Delete(_ context.Context) error { return gitprovider.ErrNoProviderSupport } diff --git a/stash/stash.go b/stash/stash.go index 9f9b4fea..10a399d4 100644 --- a/stash/stash.go +++ b/stash/stash.go @@ -108,7 +108,7 @@ func (p *ProviderClient) UserRepositories() gitprovider.UserRepositoriesClient { } // HasTokenPermission returns a boolean indicating whether the supplied token has the requested permission. -func (p *ProviderClient) HasTokenPermission(ctx context.Context, permission gitprovider.TokenPermission) (bool, error) { +func (p *ProviderClient) HasTokenPermission(_ context.Context, _ gitprovider.TokenPermission) (bool, error) { return false, gitprovider.ErrNoProviderSupport } diff --git a/validation/multierror_test.go b/validation/multierror_test.go index 02dfeb35..9575c294 100644 --- a/validation/multierror_test.go +++ b/validation/multierror_test.go @@ -234,6 +234,6 @@ type fakeT struct { calledErrorf uint8 } -func (t *fakeT) Errorf(format string, args ...interface{}) { +func (t *fakeT) Errorf(_ string, _ ...interface{}) { t.calledErrorf++ }