Skip to content

Commit e5c9808

Browse files
committed
Fix few linter warnings
Signed-off-by: Soule BA <[email protected]>
1 parent f3378ec commit e5c9808

34 files changed

+140
-107
lines changed

github/integration_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ var _ = Describe("GitHub Provider", func() {
392392
if err == nil && !actionTaken {
393393
err = errors.New("expecting action taken to be true")
394394
}
395-
return retryOp.Retry(err, fmt.Sprintf("reconcile user repository: %s", repoRef.RepositoryName))
395+
return retryOp.IsRetryable(err, fmt.Sprintf("reconcile user repository: %s", repoRef.RepositoryName))
396396
}, time.Second*90, retryOp.Interval()).Should(BeTrue())
397397

398398
Expect(actionTaken).To(BeTrue())
@@ -410,7 +410,7 @@ var _ = Describe("GitHub Provider", func() {
410410
if err == nil && !actionTaken {
411411
err = errors.New("expecting action taken to be true")
412412
}
413-
return retryOp.Retry(err, fmt.Sprintf("reconcile repository: %s", newRepo.Repository().GetRepository()))
413+
return retryOp.IsRetryable(err, fmt.Sprintf("reconcile repository: %s", newRepo.Repository().GetRepository()))
414414
}, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue())
415415

416416
Expect(actionTaken).To(BeTrue())
@@ -435,7 +435,7 @@ var _ = Describe("GitHub Provider", func() {
435435
Eventually(func() bool {
436436
var err error
437437
userRepo, err = c.UserRepositories().Get(ctx, userRepoRef)
438-
return retryOp.Retry(err, fmt.Sprintf("get user repository: %s", userRepoRef.RepositoryName))
438+
return retryOp.IsRetryable(err, fmt.Sprintf("get user repository: %s", userRepoRef.RepositoryName))
439439
}, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue())
440440

441441
defaultBranch := userRepo.Get().DefaultBranch
@@ -448,7 +448,7 @@ var _ = Describe("GitHub Provider", func() {
448448
if err == nil && len(commits) == 0 {
449449
err = errors.New("empty commits list")
450450
}
451-
return retryOp.Retry(err, fmt.Sprintf("get commits, repository: %s", userRepo.Repository().GetRepository()))
451+
return retryOp.IsRetryable(err, fmt.Sprintf("get commits, repository: %s", userRepo.Repository().GetRepository()))
452452
}, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue())
453453

454454
latestCommit := commits[0]

gitlab/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,6 @@ func (c *Client) UserRepositories() gitprovider.UserRepositoriesClient {
112112
}
113113

114114
// HasTokenPermission returns true if the given token has the given permissions.
115-
func (c *Client) HasTokenPermission(ctx context.Context, permission gitprovider.TokenPermission) (bool, error) {
115+
func (c *Client) HasTokenPermission(_ context.Context, _ gitprovider.TokenPermission) (bool, error) {
116116
return false, gitprovider.ErrNoProviderSupport
117117
}

gitlab/client_repository_branch.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package gitlab
1818

1919
import (
2020
"context"
21+
2122
"github.com/fluxcd/go-git-providers/gitprovider"
2223
"github.com/xanzy/go-gitlab"
2324
)
@@ -32,7 +33,7 @@ type BranchClient struct {
3233
}
3334

3435
// Create creates a branch with the given specifications.
35-
func (c *BranchClient) Create(ctx context.Context, branch, sha string) error {
36+
func (c *BranchClient) Create(_ context.Context, branch, sha string) error {
3637

3738
ref := &gitlab.CreateBranchOptions{
3839
Ref: &sha,

gitlab/client_repository_commit.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ type CommitClient struct {
3434
}
3535

3636
// ListPage lists repository commits of the given page and page size.
37-
func (c *CommitClient) ListPage(ctx context.Context, branch string, perPage, page int) ([]gitprovider.Commit, error) {
38-
dks, err := c.listPage(ctx, branch, perPage, page)
37+
func (c *CommitClient) ListPage(_ context.Context, branch string, perPage, page int) ([]gitprovider.Commit, error) {
38+
dks, err := c.listPage(branch, perPage, page)
3939
if err != nil {
4040
return nil, err
4141
}
@@ -47,9 +47,9 @@ func (c *CommitClient) ListPage(ctx context.Context, branch string, perPage, pag
4747
return commits, nil
4848
}
4949

50-
func (c *CommitClient) listPage(ctx context.Context, branch string, perPage, page int) ([]*commitType, error) {
50+
func (c *CommitClient) listPage(branch string, perPage, page int) ([]*commitType, error) {
5151
// GET /repos/{owner}/{repo}/commits
52-
apiObjs, err := c.c.ListCommitsPage(ctx, getRepoPath(c.ref), branch, perPage, page)
52+
apiObjs, err := c.c.ListCommitsPage(getRepoPath(c.ref), branch, perPage, page)
5353
if err != nil {
5454
return nil, err
5555
}
@@ -64,7 +64,7 @@ func (c *CommitClient) listPage(ctx context.Context, branch string, perPage, pag
6464
}
6565

6666
// Create creates a commit with the given specifications.
67-
func (c *CommitClient) Create(ctx context.Context, branch string, message string, files []gitprovider.CommitFile) (gitprovider.Commit, error) {
67+
func (c *CommitClient) Create(_ context.Context, branch string, message string, files []gitprovider.CommitFile) (gitprovider.Commit, error) {
6868

6969
if len(files) == 0 {
7070
return nil, fmt.Errorf("no files added")

gitlab/client_repository_deploykey.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ type DeployKeyClient struct {
3737
// Get returns the repository at the given path.
3838
//
3939
// ErrNotFound is returned if the resource does not exist.
40-
func (c *DeployKeyClient) Get(ctx context.Context, deployKeyName string) (gitprovider.DeployKey, error) {
41-
return c.get(ctx, deployKeyName)
40+
func (c *DeployKeyClient) Get(_ context.Context, deployKeyName string) (gitprovider.DeployKey, error) {
41+
return c.get(deployKeyName)
4242
}
4343

44-
func (c *DeployKeyClient) get(ctx context.Context, deployKeyName string) (*deployKey, error) {
45-
deployKeys, err := c.list(ctx)
44+
func (c *DeployKeyClient) get(deployKeyName string) (*deployKey, error) {
45+
deployKeys, err := c.list()
4646
if err != nil {
4747
return nil, err
4848
}
@@ -59,8 +59,8 @@ func (c *DeployKeyClient) get(ctx context.Context, deployKeyName string) (*deplo
5959
//
6060
// List returns all available repository deploy keys for the given type,
6161
// using multiple paginated requests if needed.
62-
func (c *DeployKeyClient) List(ctx context.Context) ([]gitprovider.DeployKey, error) {
63-
dks, err := c.list(ctx)
62+
func (c *DeployKeyClient) List(_ context.Context) ([]gitprovider.DeployKey, error) {
63+
dks, err := c.list()
6464
if err != nil {
6565
return nil, err
6666
}
@@ -72,9 +72,9 @@ func (c *DeployKeyClient) List(ctx context.Context) ([]gitprovider.DeployKey, er
7272
return keys, nil
7373
}
7474

75-
func (c *DeployKeyClient) list(ctx context.Context) ([]*deployKey, error) {
75+
func (c *DeployKeyClient) list() ([]*deployKey, error) {
7676
// GET /repos/{owner}/{repo}/keys
77-
apiObjs, err := c.c.ListKeys(ctx, getRepoPath(c.ref))
77+
apiObjs, err := c.c.ListKeys(getRepoPath(c.ref))
7878
if err != nil {
7979
return nil, err
8080
}
@@ -92,8 +92,8 @@ func (c *DeployKeyClient) list(ctx context.Context) ([]*deployKey, error) {
9292
// Create creates a deploy key with the given specifications.
9393
//
9494
// ErrAlreadyExists will be returned if the resource already exists.
95-
func (c *DeployKeyClient) Create(ctx context.Context, req gitprovider.DeployKeyInfo) (gitprovider.DeployKey, error) {
96-
apiObj, err := createDeployKey(ctx, c.c, c.ref, req)
95+
func (c *DeployKeyClient) Create(_ context.Context, req gitprovider.DeployKeyInfo) (gitprovider.DeployKey, error) {
96+
apiObj, err := createDeployKey(c.c, c.ref, req)
9797
if err != nil {
9898
return nil, err
9999
}
@@ -138,12 +138,12 @@ func (c *DeployKeyClient) Reconcile(ctx context.Context, req gitprovider.DeployK
138138
return actual, true, actual.Update(ctx)
139139
}
140140

141-
func createDeployKey(ctx context.Context, c gitlabClient, ref gitprovider.RepositoryRef, req gitprovider.DeployKeyInfo) (*gitlab.DeployKey, error) {
141+
func createDeployKey(c gitlabClient, ref gitprovider.RepositoryRef, req gitprovider.DeployKeyInfo) (*gitlab.DeployKey, error) {
142142
// First thing, validate and default the request to ensure a valid and fully-populated object
143143
// (to minimize any possible diffs between desired and actual state)
144144
if err := gitprovider.ValidateAndDefaultInfo(&req); err != nil {
145145
return nil, err
146146
}
147147

148-
return c.CreateKey(ctx, fmt.Sprintf("%s/%s", ref.GetIdentity(), ref.GetRepository()), deployKeyToAPI(&req))
148+
return c.CreateKey(fmt.Sprintf("%s/%s", ref.GetIdentity(), ref.GetRepository()), deployKeyToAPI(&req))
149149
}

gitlab/client_repository_pullrequest.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type PullRequestClient struct {
3838
}
3939

4040
// List lists all pull requests in the repository
41-
func (c *PullRequestClient) List(ctx context.Context) ([]gitprovider.PullRequest, error) {
41+
func (c *PullRequestClient) List(_ context.Context) ([]gitprovider.PullRequest, error) {
4242
mrs, _, err := c.c.Client().MergeRequests.ListProjectMergeRequests(getRepoPath(c.ref), nil)
4343
if err != nil {
4444
return nil, err
@@ -54,7 +54,7 @@ func (c *PullRequestClient) List(ctx context.Context) ([]gitprovider.PullRequest
5454
}
5555

5656
// Create creates a pull request with the given specifications.
57-
func (c *PullRequestClient) Create(ctx context.Context, title, branch, baseBranch, description string) (gitprovider.PullRequest, error) {
57+
func (c *PullRequestClient) Create(_ context.Context, title, branch, baseBranch, description string) (gitprovider.PullRequest, error) {
5858

5959
prOpts := &gitlab.CreateMergeRequestOptions{
6060
Title: &title,
@@ -72,7 +72,7 @@ func (c *PullRequestClient) Create(ctx context.Context, title, branch, baseBranc
7272
}
7373

7474
// Get retrieves an existing pull request by number
75-
func (c *PullRequestClient) Get(ctx context.Context, number int) (gitprovider.PullRequest, error) {
75+
func (c *PullRequestClient) Get(_ context.Context, number int) (gitprovider.PullRequest, error) {
7676

7777
mr, _, err := c.c.Client().MergeRequests.GetMergeRequest(getRepoPath(c.ref), number, &gitlab.GetMergeRequestsOptions{})
7878
if err != nil {
@@ -83,7 +83,7 @@ func (c *PullRequestClient) Get(ctx context.Context, number int) (gitprovider.Pu
8383
}
8484

8585
// Merge merges a pull request with the given specifications.
86-
func (c *PullRequestClient) Merge(ctx context.Context, number int, mergeMethod gitprovider.MergeMethod, message string) error {
86+
func (c *PullRequestClient) Merge(_ context.Context, number int, mergeMethod gitprovider.MergeMethod, message string) error {
8787
if err := c.waitForMergeRequestToBeMergeable(number); err != nil {
8888
return err
8989
}

gitlab/client_repository_teamaccess.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (c *TeamAccessClient) Create(ctx context.Context, req gitprovider.TeamAcces
118118
if err != nil {
119119
return nil, err
120120
}
121-
if err := c.c.ShareProject(ctx, getRepoPath(c.ref), group.ID, gitlabPermission); err != nil {
121+
if err := c.c.ShareProject(getRepoPath(c.ref), group.ID, gitlabPermission); err != nil {
122122
return nil, err
123123
}
124124

gitlab/gitlabclient.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,28 @@ type gitlabClient interface {
8080

8181
// ListKeys is a wrapper for "GET /projects/{project}/deploy_keys".
8282
// This function handles pagination, HTTP error wrapping, and validates the server result.
83-
ListKeys(ctx context.Context, projectName string) ([]*gitlab.DeployKey, error)
83+
ListKeys(projectName string) ([]*gitlab.DeployKey, error)
8484
// CreateProjectKey is a wrapper for "POST /projects/{project}/deploy_keys".
8585
// This function handles HTTP error wrapping, and validates the server result.
86-
CreateKey(ctx context.Context, projectName string, req *gitlab.DeployKey) (*gitlab.DeployKey, error)
86+
CreateKey(projectName string, req *gitlab.DeployKey) (*gitlab.DeployKey, error)
8787
// DeleteKey is a wrapper for "DELETE /projects/{project}/deploy_keys/{key_id}".
8888
// This function handles HTTP error wrapping.
89-
DeleteKey(ctx context.Context, projectName string, keyID int) error
89+
DeleteKey(projectName string, keyID int) error
9090

9191
// Team related methods
9292

9393
// ShareGroup is a wrapper for ""
9494
// This function handles HTTP error wrapping, and validates the server result.
95-
ShareProject(ctx context.Context, projectName string, groupID, groupAccess int) error
95+
ShareProject(projectName string, groupID, groupAccess int) error
9696
// UnshareProject is a wrapper for ""
9797
// This function handles HTTP error wrapping, and validates the server result.
98-
UnshareProject(ctx context.Context, projectName string, groupID int) error
98+
UnshareProject(projectName string, groupID int) error
9999

100100
// Commits
101101

102102
// ListCommitsPage is a wrapper for "GET /projects/{project}/repository/commits".
103103
// This function handles pagination, HTTP error wrapping.
104-
ListCommitsPage(ctx context.Context, projectName, branch string, perPage int, page int) ([]*gitlab.Commit, error)
104+
ListCommitsPage(projectName, branch string, perPage int, page int) ([]*gitlab.Commit, error)
105105
}
106106

107107
// 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
329329
return err
330330
}
331331

332-
func (c *gitlabClientImpl) ListKeys(ctx context.Context, projectName string) ([]*gitlab.DeployKey, error) {
332+
func (c *gitlabClientImpl) ListKeys(projectName string) ([]*gitlab.DeployKey, error) {
333333
apiObjs := []*gitlab.DeployKey{}
334334
opts := &gitlab.ListProjectDeployKeysOptions{}
335335
err := allDeployKeyPages(opts, func() (*gitlab.Response, error) {
@@ -350,7 +350,7 @@ func (c *gitlabClientImpl) ListKeys(ctx context.Context, projectName string) ([]
350350
return apiObjs, nil
351351
}
352352

353-
func (c *gitlabClientImpl) CreateKey(ctx context.Context, projectName string, req *gitlab.DeployKey) (*gitlab.DeployKey, error) {
353+
func (c *gitlabClientImpl) CreateKey(projectName string, req *gitlab.DeployKey) (*gitlab.DeployKey, error) {
354354
opts := &gitlab.AddDeployKeyOptions{
355355
Title: &req.Title,
356356
Key: &req.Key,
@@ -367,13 +367,13 @@ func (c *gitlabClientImpl) CreateKey(ctx context.Context, projectName string, re
367367
return apiObj, nil
368368
}
369369

370-
func (c *gitlabClientImpl) DeleteKey(ctx context.Context, projectName string, keyID int) error {
370+
func (c *gitlabClientImpl) DeleteKey(projectName string, keyID int) error {
371371
// DELETE /projects/{project}/deploy_keys
372372
_, err := c.c.DeployKeys.DeleteDeployKey(projectName, keyID)
373373
return handleHTTPError(err)
374374
}
375375

376-
func (c *gitlabClientImpl) ShareProject(ctx context.Context, projectName string, groupIDObj, groupAccessObj int) error {
376+
func (c *gitlabClientImpl) ShareProject(projectName string, groupIDObj, groupAccessObj int) error {
377377
groupAccess := gitlab.AccessLevel(gitlab.AccessLevelValue(groupAccessObj))
378378
groupID := &groupIDObj
379379
opt := &gitlab.ShareWithGroupOptions{
@@ -385,12 +385,12 @@ func (c *gitlabClientImpl) ShareProject(ctx context.Context, projectName string,
385385
return handleHTTPError(err)
386386
}
387387

388-
func (c *gitlabClientImpl) UnshareProject(ctx context.Context, projectName string, groupID int) error {
388+
func (c *gitlabClientImpl) UnshareProject(projectName string, groupID int) error {
389389
_, err := c.c.Projects.DeleteSharedProjectFromGroup(projectName, groupID)
390390
return handleHTTPError(err)
391391
}
392392

393-
func (c *gitlabClientImpl) ListCommitsPage(ctx context.Context, projectName string, branch string, perPage int, page int) ([]*gitlab.Commit, error) {
393+
func (c *gitlabClientImpl) ListCommitsPage(projectName string, branch string, perPage int, page int) ([]*gitlab.Commit, error) {
394394
apiObjs := make([]*gitlab.Commit, 0)
395395

396396
opts := gitlab.ListCommitsOptions{

gitlab/integration_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ var _ = Describe("GitLab Provider", func() {
433433
AutoInit: gitprovider.BoolVar(true),
434434
LicenseTemplate: gitprovider.LicenseTemplateVar(gitprovider.LicenseTemplateMIT),
435435
})
436-
return retryOp.Retry(err, fmt.Sprintf("reconcile org repository: %s", repoRef.RepositoryName))
436+
return retryOp.IsRetryable(err, fmt.Sprintf("reconcile org repository: %s", repoRef.RepositoryName))
437437
}, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue())
438438

439439
Expect(actionTaken).To(BeTrue())
@@ -722,7 +722,7 @@ var _ = Describe("GitLab Provider", func() {
722722
AutoInit: gitprovider.BoolVar(true),
723723
LicenseTemplate: gitprovider.LicenseTemplateVar(gitprovider.LicenseTemplateMIT),
724724
})
725-
return retryOp.Retry(err, fmt.Sprintf("new user repository: %s", repoRef.RepositoryName))
725+
return retryOp.IsRetryable(err, fmt.Sprintf("new user repository: %s", repoRef.RepositoryName))
726726
}, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue())
727727

728728
// Expect the create to succeed, and have modified the state. Also validate the newRepo data
@@ -757,7 +757,7 @@ var _ = Describe("GitLab Provider", func() {
757757
if err == nil && len(commits) == 0 {
758758
err = errors.New("empty commits list")
759759
}
760-
return retryOp.Retry(err, fmt.Sprintf("get commits, repository: %s", userRepo.Repository().GetRepository()))
760+
return retryOp.IsRetryable(err, fmt.Sprintf("get commits, repository: %s", userRepo.Repository().GetRepository()))
761761
}, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue())
762762

763763
latestCommit := commits[0]

gitlab/resource_deploykey.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,20 @@ func (dk *deployKey) Update(ctx context.Context) error {
7878
if err := dk.Delete(ctx); err != nil {
7979
return err
8080
}
81-
return dk.createIntoSelf(ctx)
81+
return dk.createIntoSelf()
8282
}
8383

8484
// Delete deletes a deploy key from the repository.
8585
//
8686
// ErrNotFound is returned if the resource does not exist.
87-
func (dk *deployKey) Delete(ctx context.Context) error {
87+
func (dk *deployKey) Delete(_ context.Context) error {
8888
// We can use the same DeployKey ID that we got from the GET calls. Make sure it's non-nil.
8989
// This _should never_ happen, but just check for it anyways to avoid panicing.
9090
if dk.k.ID == 0 {
9191
return fmt.Errorf("didn't expect ID to be 0: %w", gitprovider.ErrUnexpectedEvent)
9292
}
9393

94-
return dk.c.c.DeleteKey(ctx, getRepoPath(dk.c.ref), dk.k.ID)
94+
return dk.c.c.DeleteKey(getRepoPath(dk.c.ref), dk.k.ID)
9595
}
9696

9797
// 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 {
103103
//
104104
// The internal API object will be overridden with the received server data if actionTaken == true.
105105
func (dk *deployKey) Reconcile(ctx context.Context) (bool, error) {
106-
actual, err := dk.c.get(ctx, dk.k.Title)
106+
actual, err := dk.c.get(dk.k.Title)
107107
if err != nil {
108108
// Create if not found
109109
if errors.Is(err, gitprovider.ErrNotFound) {
110-
return true, dk.createIntoSelf(ctx)
110+
return true, dk.createIntoSelf()
111111
}
112112

113113
// Unexpected path, Get should succeed or return NotFound
@@ -126,9 +126,9 @@ func (dk *deployKey) Reconcile(ctx context.Context) (bool, error) {
126126
return true, dk.Update(ctx)
127127
}
128128

129-
func (dk *deployKey) createIntoSelf(ctx context.Context) error {
129+
func (dk *deployKey) createIntoSelf() error {
130130
// POST /repos/{owner}/{repo}/keys
131-
apiObj, err := dk.c.c.CreateKey(ctx, getRepoPath(dk.c.ref), &dk.k)
131+
apiObj, err := dk.c.c.CreateKey(getRepoPath(dk.c.ref), &dk.k)
132132
if err != nil {
133133
return err
134134
}

gitlab/resource_teamaccess.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (ta *teamAccess) Delete(ctx context.Context) error {
6363
if err != nil {
6464
return err
6565
}
66-
return ta.c.c.UnshareProject(ctx, getRepoPath(ta.c.ref), group.ID)
66+
return ta.c.c.UnshareProject(getRepoPath(ta.c.ref), group.ID)
6767
}
6868

6969
func (ta *teamAccess) Update(ctx context.Context) error {
@@ -74,7 +74,7 @@ func (ta *teamAccess) Update(ctx context.Context) error {
7474
if err != nil {
7575
return err
7676
}
77-
err = ta.c.c.UnshareProject(ctx, getRepoPath(ta.c.ref), group.ID)
77+
err = ta.c.c.UnshareProject(getRepoPath(ta.c.ref), group.ID)
7878
if err != nil {
7979
return err
8080
}

0 commit comments

Comments
 (0)