Skip to content
This repository was archived by the owner on Jun 14, 2023. It is now read-only.

Commit e58fc0e

Browse files
fix: fix lint errors
1 parent 96014da commit e58fc0e

5 files changed

Lines changed: 9 additions & 11 deletions

File tree

api/v1/gitopsapi_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type GitopsAPISpec struct {
3030
GitUser string `json:"gitUser,omitempty"`
3131
GitEmail string `json:"gitEmail,omitempty"`
3232
// The branch to use as a baseline for the new branch, defaults to master
33-
Base string `json:"branch,omitempty"`
33+
Base string `json:"base,omitempty"`
3434
// The branch to push updates back to, defaults to master
3535
Branch string `json:"branch,omitempty"`
3636

connectors/github.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func (g *Github) Clone(ctx context.Context, branch, local string) (billy.Filesys
129129
return nil, nil, err
130130
}
131131
if branch != local {
132+
// nolint: errcheck
132133
work.Checkout(&git.CheckoutOptions{
133134
Branch: plumbing.NewBranchReferenceName(local),
134135
Create: true,

controllers/gitopsapi_controller.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ func serve(c echo.Context, r *GitopsAPIReconciler) error {
9999
return c.String(http.StatusInternalServerError, err.Error())
100100
}
101101

102-
if hash, pr, err := HandleGitopsAPI(ctx, r.Log, git, api, c.Request().Body); err != nil {
102+
hash, pr, err := HandleGitopsAPI(ctx, r.Log, git, api, c.Request().Body)
103+
104+
if err != nil {
103105
r.Log.Error(err, "error pushing to git")
104106
return c.String(http.StatusInternalServerError, err.Error())
105-
} else {
106-
107-
return c.String(http.StatusAccepted, fmt.Sprintf("Committed %s, PR: %d ", hash, pr))
108107
}
108+
return c.String(http.StatusAccepted, fmt.Sprintf("Committed %s, PR: %d ", hash, pr))
109109
}
110110

111111
func GetKustomizaton(fs billy.Filesystem, path string) (*types.Kustomization, error) {
@@ -123,8 +123,8 @@ func GetKustomizaton(fs billy.Filesystem, path string) (*types.Kustomization, er
123123
return nil, err
124124
}
125125
return &kustomization, nil
126-
127126
}
127+
128128
func HandleGitopsAPI(ctx context.Context, logger logr.Logger, git connectors.Connector, api gitv1.GitopsAPI, contents io.Reader) (hash string, pr int, err error) {
129129
if api.Spec.Base == "" {
130130
api.Spec.Base = "master"
@@ -187,7 +187,6 @@ func HandleGitopsAPI(ctx context.Context, logger logr.Logger, git connectors.Con
187187

188188
if err = copy(existingKustomization, kustomizationPath, fs, work); err != nil {
189189
return
190-
191190
}
192191
author := &object.Signature{
193192
Name: api.Spec.GitUser,
@@ -230,7 +229,7 @@ func HandleGitopsAPI(ctx context.Context, logger logr.Logger, git connectors.Con
230229

231230
pr, err = git.OpenPullRequest(ctx, api.Spec.Base, branch, api.Spec.PullRequest)
232231
}
233-
return
232+
return // nolint: nakedret
234233
}
235234

236235
func (r *GitopsAPIReconciler) SetupWithManager(mgr ctrl.Manager) error {

controllers/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func copy(data []byte, path string, fs billy.Filesystem, work *gitv5.Worktree) e
1414
if err != nil {
1515
return errors.Wrap(err, "failed to open")
1616
}
17-
src := bytes.NewBuffer([]byte(data))
17+
src := bytes.NewBuffer(data)
1818
if _, err := io.Copy(dst, src); err != nil {
1919
return errors.Wrap(err, "failed to copy")
2020
}

test/e2e.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2929
"k8s.io/client-go/kubernetes"
3030
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
31-
"k8s.io/client-go/rest"
3231
"k8s.io/client-go/tools/clientcmd"
3332
ctrl "sigs.k8s.io/controller-runtime"
3433
crdclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -55,7 +54,6 @@ var (
5554
}
5655
scheme = runtime.NewScheme()
5756
log = ctrl.Log.WithName("e2e")
58-
restConfig *rest.Config
5957
pullRequestUsername string
6058
)
6159

0 commit comments

Comments
 (0)