From 276626bd85f64435736de385c9af82f31707a9c0 Mon Sep 17 00:00:00 2001 From: ecrupper Date: Wed, 14 Sep 2022 11:29:15 -0500 Subject: [PATCH 1/3] chore(lint): fix linter errors in worker codebase --- api/doc.go | 2 +- cmd/vela-worker/exec.go | 3 ++- cmd/vela-worker/operate.go | 4 ++- cmd/vela-worker/start.go | 6 +++-- executor/context.go | 2 +- executor/context_test.go | 6 ++--- executor/doc.go | 2 +- executor/executor.go | 3 +-- executor/linux/api.go | 7 ++--- executor/linux/build.go | 6 +++-- executor/linux/doc.go | 2 +- executor/linux/linux.go | 4 +-- executor/linux/secret.go | 4 ++- executor/linux/secret_test.go | 4 +-- executor/linux/service.go | 10 ++++--- executor/linux/step.go | 10 ++++--- executor/linux/step_test.go | 4 +-- executor/local/api.go | 7 ++--- executor/local/build.go | 2 +- executor/local/doc.go | 2 +- executor/local/local.go | 2 +- go.mod | 2 +- go.sum | 3 ++- internal/build/doc.go | 2 +- internal/doc.go | 6 ++--- internal/image/doc.go | 2 +- internal/message/doc.go | 2 +- internal/service/doc.go | 2 +- internal/step/doc.go | 2 +- internal/volume/doc.go | 2 +- mock/doc.go | 2 +- mock/docker/config.go | 2 +- mock/docker/container.go | 27 +++++++++---------- mock/docker/doc.go | 2 +- mock/docker/docker.go | 6 ++--- mock/docker/image.go | 9 +++---- mock/docker/network.go | 8 +++--- mock/docker/secret.go | 2 +- mock/docker/volume.go | 12 ++++----- mock/worker/doc.go | 2 +- router/build.go | 3 +-- router/doc.go | 2 +- router/executor.go | 3 +-- router/middleware/doc.go | 2 +- router/middleware/logger.go | 4 +-- router/middleware/logger_test.go | 2 +- router/middleware/payload.go | 4 +-- router/middleware/perm/doc.go | 2 +- router/middleware/token/doc.go | 2 +- router/middleware/token/token.go | 3 +-- router/middleware/user/doc.go | 2 +- router/pipeline.go | 3 +-- router/repo.go | 3 +-- router/router.go | 26 +++++++++--------- runtime/context.go | 2 +- runtime/context_test.go | 6 ++--- runtime/doc.go | 2 +- runtime/docker/doc.go | 2 +- runtime/docker/docker.go | 7 +++-- runtime/docker/image.go | 3 +-- runtime/kubernetes/apis/doc.go | 2 +- runtime/kubernetes/apis/vela/v1alpha1/doc.go | 2 +- runtime/kubernetes/container.go | 5 ++-- runtime/kubernetes/container_test.go | 2 +- runtime/kubernetes/doc.go | 2 +- .../clientset/versioned/fake/register.go | 14 +++++----- .../clientset/versioned/scheme/register.go | 14 +++++----- runtime/kubernetes/kubernetes.go | 4 +-- runtime/kubernetes/opts.go | 4 +-- runtime/kubernetes/volume.go | 3 ++- runtime/runtime.go | 3 +-- 71 files changed, 167 insertions(+), 158 deletions(-) diff --git a/api/doc.go b/api/doc.go index aacdede7..bba5c985 100644 --- a/api/doc.go +++ b/api/doc.go @@ -6,5 +6,5 @@ // // Usage: // -// import "github.com/go-vela/worker/api" +// import "github.com/go-vela/worker/api" package api diff --git a/cmd/vela-worker/exec.go b/cmd/vela-worker/exec.go index dc2e3602..0e05264c 100644 --- a/cmd/vela-worker/exec.go +++ b/cmd/vela-worker/exec.go @@ -17,7 +17,8 @@ import ( // exec is a helper function to poll the queue // and execute Vela pipelines for the Worker. -// nolint: nilerr // ignore returning nil - don't want to crash worker +// +//nolint:nilerr // ignore returning nil - don't want to crash worker func (w *Worker) exec(index int) error { var err error diff --git a/cmd/vela-worker/operate.go b/cmd/vela-worker/operate.go index ac625353..da223970 100644 --- a/cmd/vela-worker/operate.go +++ b/cmd/vela-worker/operate.go @@ -55,6 +55,7 @@ func (w *Worker) operate(ctx context.Context) error { registryWorker.SetLastCheckedIn(time.Now().UTC().Unix()) // register or update the worker + //nolint:contextcheck // ignore passing context err = w.checkIn(registryWorker) if err != nil { logrus.Error(err) @@ -74,6 +75,7 @@ func (w *Worker) operate(ctx context.Context) error { // setup the queue // // https://pkg.go.dev/github.com/go-vela/server/queue?tab=doc#New + //nolint:contextcheck // ignore passing context w.Queue, err = queue.New(w.Config.Queue) if err != nil { return err @@ -107,7 +109,7 @@ func (w *Worker) operate(ctx context.Context) error { // exec operator subprocess to poll and execute builds // (do not pass the context to avoid errors in one // executor+build inadvertently canceling other builds) - // nolint: contextcheck // ignore passing context + //nolint:contextcheck // ignore passing context err = w.exec(id) if err != nil { // log the error received from the executor diff --git a/cmd/vela-worker/start.go b/cmd/vela-worker/start.go index 45422423..46193317 100644 --- a/cmd/vela-worker/start.go +++ b/cmd/vela-worker/start.go @@ -12,6 +12,7 @@ import ( "os" "os/signal" "syscall" + "time" "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" @@ -34,8 +35,9 @@ func (w *Worker) Start() error { httpHandler, tls := w.server() server := &http.Server{ - Addr: fmt.Sprintf(":%s", w.Config.API.Address.Port()), - Handler: httpHandler, + Addr: fmt.Sprintf(":%s", w.Config.API.Address.Port()), + Handler: httpHandler, + ReadHeaderTimeout: 60 * time.Second, } // goroutine to check for signals to gracefully finish all functions diff --git a/executor/context.go b/executor/context.go index 0ee583ab..f6c5acf9 100644 --- a/executor/context.go +++ b/executor/context.go @@ -54,7 +54,7 @@ func FromGinContext(c *gin.Context) Engine { func WithContext(c context.Context, e Engine) context.Context { // set the executor Engine in the context.Context // - // nolint: revive,staticcheck // ignore using string with context value + //nolint:revive,staticcheck // ignore using string with context value return context.WithValue(c, key, e) } diff --git a/executor/context_test.go b/executor/context_test.go index fc645ae4..280ee973 100644 --- a/executor/context_test.go +++ b/executor/context_test.go @@ -57,7 +57,7 @@ func TestExecutor_FromContext(t *testing.T) { }{ { name: "valid executor in context", - // nolint: staticcheck,revive // ignore using string with context value + //nolint:staticcheck,revive // ignore using string with context value context: context.WithValue(context.Background(), key, _engine), want: _engine, }, @@ -68,7 +68,7 @@ func TestExecutor_FromContext(t *testing.T) { }, { name: "invalid executor in context", - // nolint: staticcheck,revive // ignore using string with context value + //nolint:staticcheck,revive // ignore using string with context value context: context.WithValue(context.Background(), key, "foo"), want: nil, }, @@ -185,7 +185,7 @@ func TestExecutor_WithContext(t *testing.T) { t.Errorf("unable to create linux engine: %v", err) } - // nolint: staticcheck,revive // ignore using string with context value + //nolint:staticcheck,revive // ignore using string with context value want := context.WithValue(context.Background(), key, _engine) // run test diff --git a/executor/doc.go b/executor/doc.go index c3dc5a64..b5a194f5 100644 --- a/executor/doc.go +++ b/executor/doc.go @@ -8,5 +8,5 @@ // // Usage: // -// import "github.com/go-vela/worker/executor" +// import "github.com/go-vela/worker/executor" package executor diff --git a/executor/executor.go b/executor/executor.go index 031ca6cf..b13fae91 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -12,8 +12,6 @@ import ( "github.com/sirupsen/logrus" ) -// nolint: godot // ignore period at end for comment ending in a list -// // New creates and returns a Vela engine capable of // integrating with the configured executor. // @@ -21,6 +19,7 @@ import ( // // * linux // * local +// . func New(s *Setup) (Engine, error) { // validate the setup being provided // diff --git a/executor/linux/api.go b/executor/linux/api.go index 9ee2150a..c47da637 100644 --- a/executor/linux/api.go +++ b/executor/linux/api.go @@ -47,7 +47,8 @@ func (c *client) GetRepo() (*library.Repo, error) { } // CancelBuild cancels the current build in execution. -// nolint: funlen // process of going through steps/services/stages is verbose and could be funcitonalized +// +//nolint:funlen // process of going through steps/services/stages is verbose and could be funcitonalized func (c *client) CancelBuild() (*library.Build, error) { // get the current build from the client b, err := c.GetBuild() @@ -65,7 +66,7 @@ func (c *client) CancelBuild() (*library.Build, error) { } // cancel non successful services - // nolint: dupl // false positive, steps/services are different + //nolint:dupl // false positive, steps/services are different for _, _service := range pipeline.Services { // load the service from the client // @@ -106,7 +107,7 @@ func (c *client) CancelBuild() (*library.Build, error) { } // cancel non successful steps - // nolint: dupl // false positive, steps/services are different + //nolint:dupl // false positive, steps/services are different for _, _step := range pipeline.Steps { // load the step from the client // diff --git a/executor/linux/build.go b/executor/linux/build.go index d59d5700..8f01fe5d 100644 --- a/executor/linux/build.go +++ b/executor/linux/build.go @@ -36,6 +36,7 @@ func (c *client) CreateBuild(ctx context.Context) error { // send API call to update the build // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#BuildService.Update + //nolint:contextcheck // ignore passing context c.build, _, c.err = c.Vela.Build.Update(c.repo.GetOrg(), c.repo.GetName(), c.build) if c.err != nil { return fmt.Errorf("unable to upload build state: %w", c.err) @@ -162,6 +163,7 @@ func (c *client) PlanBuild(ctx context.Context) error { c.Logger.Infof("pulling %s %s secret %s", secret.Engine, secret.Type, secret.Name) + //nolint:contextcheck // ignore passing context s, err := c.secret.pull(secret) if err != nil { c.err = err @@ -189,7 +191,7 @@ func (c *client) PlanBuild(ctx context.Context) error { // AssembleBuild prepares the containers within a build for execution. // -// nolint: funlen // ignore function length due to comments and logging messages +//nolint:funlen // ignore function length due to comments and logging messages func (c *client) AssembleBuild(ctx context.Context) error { // defer taking a snapshot of the build // @@ -268,7 +270,7 @@ func (c *client) AssembleBuild(ctx context.Context) error { for _, s := range c.pipeline.Stages { // TODO: remove hardcoded reference // - // nolint: goconst // ignore making a constant for now + //nolint:goconst // ignore making a constant for now if s.Name == "init" { continue } diff --git a/executor/linux/doc.go b/executor/linux/doc.go index f26b67fd..fa22e227 100644 --- a/executor/linux/doc.go +++ b/executor/linux/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/executor/linux" +// import "github.com/go-vela/worker/executor/linux" package linux diff --git a/executor/linux/linux.go b/executor/linux/linux.go index fe388cd0..2924f43a 100644 --- a/executor/linux/linux.go +++ b/executor/linux/linux.go @@ -49,7 +49,7 @@ type ( err error } - // nolint: structcheck // ignore false positive + //nolint:structcheck // ignore false positive svc struct { client *client } @@ -86,7 +86,7 @@ func Equal(a, b *client) bool { // New returns an Executor implementation that integrates with a Linux instance. // -// nolint: revive // ignore unexported type as it is intentional +//nolint:revive // ignore unexported type as it is intentional func New(opts ...Opt) (*client, error) { // create new Linux client c := new(client) diff --git a/executor/linux/secret.go b/executor/linux/secret.go index 6417070d..137a7aca 100644 --- a/executor/linux/secret.go +++ b/executor/linux/secret.go @@ -175,6 +175,7 @@ func (s *secretSvc) exec(ctx context.Context, p *pipeline.SecretSlice) error { // send API call to update the build // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#StepService.Update + //nolint:contextcheck // ignore passing context _, _, err = s.client.Vela.Step.Update(s.client.repo.GetOrg(), s.client.repo.GetName(), s.client.build.GetNumber(), _init) if err != nil { s.client.Logger.Errorf("unable to upload init state: %v", err) @@ -186,7 +187,7 @@ func (s *secretSvc) exec(ctx context.Context, p *pipeline.SecretSlice) error { // pull defines a function that pulls the secrets from the server for a given pipeline. func (s *secretSvc) pull(secret *pipeline.Secret) (*library.Secret, error) { - // nolint: staticcheck // reports the value is never used but we return it + //nolint:staticcheck // reports the value is never used but we return it _secret := new(library.Secret) switch secret.Type { @@ -314,6 +315,7 @@ func (s *secretSvc) stream(ctx context.Context, ctn *pipeline.Container) error { // send API call to append the logs for the init step // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#LogService.UpdateStep + //nolint:contextcheck // ignore passing context _log, _, err = s.client.Vela.Log.UpdateStep(s.client.repo.GetOrg(), s.client.repo.GetName(), s.client.build.GetNumber(), s.client.init.Number, _log) if err != nil { return err diff --git a/executor/linux/secret_test.go b/executor/linux/secret_test.go index ccd1c69d..ac9bfd06 100644 --- a/executor/linux/secret_test.go +++ b/executor/linux/secret_test.go @@ -7,8 +7,8 @@ package linux import ( "context" "flag" - "io/ioutil" "net/http/httptest" + "os" "testing" "github.com/gin-gonic/gin" @@ -290,7 +290,7 @@ func TestLinux_Secret_exec(t *testing.T) { // run tests for _, test := range tests { t.Run(test.name, func(t *testing.T) { - file, _ := ioutil.ReadFile(test.pipeline) + file, _ := os.ReadFile(test.pipeline) p, _, err := compiler. Duplicate(). diff --git a/executor/linux/service.go b/executor/linux/service.go index b20cc22e..a79cd2ea 100644 --- a/executor/linux/service.go +++ b/executor/linux/service.go @@ -9,7 +9,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "io" "time" "github.com/go-vela/types/constants" @@ -84,6 +84,7 @@ func (c *client) PlanService(ctx context.Context, ctn *pipeline.Container) error // send API call to update the service // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#SvcService.Update + //nolint:contextcheck // ignore passing context _service, _, err = c.Vela.Svc.Update(c.repo.GetOrg(), c.repo.GetName(), c.build.GetNumber(), _service) if err != nil { return err @@ -105,6 +106,7 @@ func (c *client) PlanService(ctx context.Context, ctn *pipeline.Container) error // send API call to capture the service log // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#LogService.GetService + //nolint:contextcheck // ignore passing context _log, _, err := c.Vela.Log.GetService(c.repo.GetOrg(), c.repo.GetName(), c.build.GetNumber(), _service.GetNumber()) if err != nil { return err @@ -155,7 +157,7 @@ func (c *client) ExecService(ctx context.Context, ctn *pipeline.Container) error // StreamService tails the output for a service. // -// nolint: funlen // ignore function length +//nolint:funlen // ignore function length func (c *client) StreamService(ctx context.Context, ctn *pipeline.Container) error { // update engine logger with service metadata // @@ -181,7 +183,7 @@ func (c *client) StreamService(ctx context.Context, ctn *pipeline.Container) err defer rc.Close() // read all output from the runtime container - data, err := ioutil.ReadAll(rc) + data, err := io.ReadAll(rc) if err != nil { logger.Errorf("unable to read container output for upload: %v", err) @@ -204,6 +206,7 @@ func (c *client) StreamService(ctx context.Context, ctn *pipeline.Container) err // send API call to update the logs for the service // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#LogService.UpdateService + //nolint:contextcheck // ignore passing context _, _, err = c.Vela.Log.UpdateService(c.repo.GetOrg(), c.repo.GetName(), c.build.GetNumber(), ctn.Number, _log) if err != nil { logger.Errorf("unable to upload container logs: %v", err) @@ -323,6 +326,7 @@ func (c *client) StreamService(ctx context.Context, ctn *pipeline.Container) err // send API call to append the logs for the service // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#LogService.UpdateService + //nolint:contextcheck // ignore passing context _log, _, err = c.Vela.Log.UpdateService(c.repo.GetOrg(), c.repo.GetName(), c.build.GetNumber(), ctn.Number, _log) if err != nil { return err diff --git a/executor/linux/step.go b/executor/linux/step.go index 49c755e1..70d5d64d 100644 --- a/executor/linux/step.go +++ b/executor/linux/step.go @@ -9,7 +9,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "io" "strings" "time" @@ -91,6 +91,7 @@ func (c *client) PlanStep(ctx context.Context, ctn *pipeline.Container) error { // send API call to update the step // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#StepService.Update + //nolint:contextcheck // ignore passing context _step, _, err = c.Vela.Step.Update(c.repo.GetOrg(), c.repo.GetName(), c.build.GetNumber(), _step) if err != nil { return err @@ -112,6 +113,7 @@ func (c *client) PlanStep(ctx context.Context, ctn *pipeline.Container) error { // send API call to capture the step log // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#LogService.GetStep + //nolint:contextcheck // ignore passing context _log, _, err := c.Vela.Log.GetStep(c.repo.GetOrg(), c.repo.GetName(), c.build.GetNumber(), _step.GetNumber()) if err != nil { return err @@ -186,7 +188,7 @@ func (c *client) ExecStep(ctx context.Context, ctn *pipeline.Container) error { // StreamStep tails the output for a step. // -// nolint: funlen // ignore function length +//nolint:funlen // ignore function length func (c *client) StreamStep(ctx context.Context, ctn *pipeline.Container) error { // TODO: remove hardcoded reference if ctn.Name == "init" { @@ -219,7 +221,7 @@ func (c *client) StreamStep(ctx context.Context, ctn *pipeline.Container) error defer rc.Close() // read all output from the runtime container - data, err := ioutil.ReadAll(rc) + data, err := io.ReadAll(rc) if err != nil { logger.Errorf("unable to read container output for upload: %v", err) @@ -247,6 +249,7 @@ func (c *client) StreamStep(ctx context.Context, ctn *pipeline.Container) error // send API call to update the logs for the step // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#LogService.UpdateStep + //nolint:contextcheck // ignore passing context _, _, err = c.Vela.Log.UpdateStep(c.repo.GetOrg(), c.repo.GetName(), c.build.GetNumber(), ctn.Number, _log) if err != nil { logger.Errorf("unable to upload container logs: %v", err) @@ -376,6 +379,7 @@ func (c *client) StreamStep(ctx context.Context, ctn *pipeline.Container) error // send API call to append the logs for the step // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#LogStep.UpdateStep + //nolint:contextcheck // ignore passing context _log, _, err = c.Vela.Log.UpdateStep(c.repo.GetOrg(), c.repo.GetName(), c.build.GetNumber(), ctn.Number, _log) if err != nil { return err diff --git a/executor/linux/step_test.go b/executor/linux/step_test.go index 078dce96..7c283acc 100644 --- a/executor/linux/step_test.go +++ b/executor/linux/step_test.go @@ -6,8 +6,8 @@ package linux import ( "context" - "io/ioutil" "net/http/httptest" + "os" "reflect" "testing" @@ -566,7 +566,7 @@ func TestLinux_DestroyStep(t *testing.T) { } func TestLinux_getSecretValues(t *testing.T) { - fileSecret, err := ioutil.ReadFile("./testdata/step/secret_text.txt") + fileSecret, err := os.ReadFile("./testdata/step/secret_text.txt") if err != nil { t.Errorf("unable to read from test data file secret. Err: %v", err) } diff --git a/executor/local/api.go b/executor/local/api.go index 3f67a5de..671ff79c 100644 --- a/executor/local/api.go +++ b/executor/local/api.go @@ -47,7 +47,8 @@ func (c *client) GetRepo() (*library.Repo, error) { } // CancelBuild cancels the current build in execution. -// nolint: funlen // process of going through steps/services/stages is verbose and could be funcitonalized +// +//nolint:funlen // process of going through steps/services/stages is verbose and could be funcitonalized func (c *client) CancelBuild() (*library.Build, error) { // get the current build from the client b, err := c.GetBuild() @@ -65,7 +66,7 @@ func (c *client) CancelBuild() (*library.Build, error) { } // cancel non successful services - // nolint: dupl // false positive, steps/services are different + //nolint:dupl // false positive, steps/services are different for _, _service := range pipeline.Services { // load the service from the client // @@ -106,7 +107,7 @@ func (c *client) CancelBuild() (*library.Build, error) { } // cancel non successful steps - // nolint: dupl // false positive, steps/services are different + //nolint:dupl // false positive, steps/services are different for _, _step := range pipeline.Steps { // load the step from the client // diff --git a/executor/local/build.go b/executor/local/build.go index 8c1f0168..2fa79ff8 100644 --- a/executor/local/build.go +++ b/executor/local/build.go @@ -192,7 +192,7 @@ func (c *client) AssembleBuild(ctx context.Context) error { for _, _stage := range c.pipeline.Stages { // TODO: remove hardcoded reference // - // nolint: goconst // ignore making a constant for now + //nolint:goconst // ignore making a constant for now if _stage.Name == "init" { continue } diff --git a/executor/local/doc.go b/executor/local/doc.go index be55b775..33dc2532 100644 --- a/executor/local/doc.go +++ b/executor/local/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/executor/local" +// import "github.com/go-vela/worker/executor/local" package local diff --git a/executor/local/local.go b/executor/local/local.go index c974d9e7..db589f84 100644 --- a/executor/local/local.go +++ b/executor/local/local.go @@ -75,7 +75,7 @@ func Equal(a, b *client) bool { // New returns an Executor implementation that integrates with the local system. // -// nolint: revive // ignore unexported type as it is intentional +//nolint:revive // ignore unexported type as it is intentional func New(opts ...Opt) (*client, error) { // create new local client c := new(client) diff --git a/go.mod b/go.mod index ee585cfd..f223fe76 100644 --- a/go.mod +++ b/go.mod @@ -57,7 +57,7 @@ require ( github.com/go-redis/redis/v8 v8.11.5 // indirect github.com/goccy/go-json v0.9.7 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang-jwt/jwt/v4 v4.4.1 // indirect + github.com/golang-jwt/jwt/v4 v4.4.2 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/go-github/v44 v44.1.0 // indirect diff --git a/go.sum b/go.sum index 9372f960..08720c31 100644 --- a/go.sum +++ b/go.sum @@ -224,8 +224,9 @@ github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRx github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.4.1 h1:pC5DB52sCeK48Wlb9oPcdhnjkz1TKt1D/P7WKJ0kUcQ= github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= +github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= diff --git a/internal/build/doc.go b/internal/build/doc.go index e1870f2c..5c15988e 100644 --- a/internal/build/doc.go +++ b/internal/build/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/internal/build" +// import "github.com/go-vela/worker/internal/build" package build diff --git a/internal/doc.go b/internal/doc.go index 7f15e7d5..7aaad1f6 100644 --- a/internal/doc.go +++ b/internal/doc.go @@ -7,10 +7,10 @@ // // More information: // -// * https://golang.org/doc/go1.4#internalpackages -// * https://docs.google.com/document/d/1e8kOo3r51b2BWtTs_1uADIA5djfXhPT36s6eHVRIvaU/edit +// - https://golang.org/doc/go1.4#internalpackages +// - https://docs.google.com/document/d/1e8kOo3r51b2BWtTs_1uADIA5djfXhPT36s6eHVRIvaU/edit // // Usage: // -// import "github.com/go-vela/worker/internal" +// import "github.com/go-vela/worker/internal" package internal diff --git a/internal/image/doc.go b/internal/image/doc.go index 8277eab6..fa21f0c0 100644 --- a/internal/image/doc.go +++ b/internal/image/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/internal/image" +// import "github.com/go-vela/worker/internal/image" package image diff --git a/internal/message/doc.go b/internal/message/doc.go index 10bad174..84920b80 100644 --- a/internal/message/doc.go +++ b/internal/message/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/internal/message" +// import "github.com/go-vela/worker/internal/message" package message diff --git a/internal/service/doc.go b/internal/service/doc.go index 93b428e3..34a0aa0f 100644 --- a/internal/service/doc.go +++ b/internal/service/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/internal/service" +// import "github.com/go-vela/worker/internal/service" package service diff --git a/internal/step/doc.go b/internal/step/doc.go index 333ebe65..7209e373 100644 --- a/internal/step/doc.go +++ b/internal/step/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/internal/step" +// import "github.com/go-vela/worker/internal/step" package step diff --git a/internal/volume/doc.go b/internal/volume/doc.go index 1d433f7b..f5b36a01 100644 --- a/internal/volume/doc.go +++ b/internal/volume/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/internal/volume" +// import "github.com/go-vela/worker/internal/volume" package volume diff --git a/mock/doc.go b/mock/doc.go index fa9536ea..9e9203b5 100644 --- a/mock/doc.go +++ b/mock/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/mock" +// import "github.com/go-vela/worker/mock" package mock diff --git a/mock/docker/config.go b/mock/docker/config.go index e1d2878e..ebf385cb 100644 --- a/mock/docker/config.go +++ b/mock/docker/config.go @@ -2,7 +2,7 @@ // // Use of this source code is governed by the LICENSE file in this repository. -// nolint: dupl // ignore similar code +//nolint:dupl // ignore similar code package docker import ( diff --git a/mock/docker/container.go b/mock/docker/container.go index d17c1ab7..a39cf3f3 100644 --- a/mock/docker/container.go +++ b/mock/docker/container.go @@ -11,7 +11,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "strings" "time" @@ -63,7 +62,7 @@ func (c *ContainerService) ContainerCreate(ctx context.Context, config *containe if strings.Contains(ctn, "notfound") && !strings.Contains(ctn, "ignorenotfound") { return container.ContainerCreateCreatedBody{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such container: %s", ctn)) } @@ -72,7 +71,7 @@ func (c *ContainerService) ContainerCreate(ctx context.Context, config *containe if strings.Contains(ctn, "not-found") && !strings.Contains(ctn, "ignore-not-found") { return container.ContainerCreateCreatedBody{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such container: %s", ctn)) } @@ -81,7 +80,7 @@ func (c *ContainerService) ContainerCreate(ctx context.Context, config *containe strings.Contains(config.Image, "not-found") { return container.ContainerCreateCreatedBody{}, errdefs.NotFound( - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages fmt.Errorf("Error response from daemon: manifest for %s not found: manifest unknown", config.Image), ) } @@ -172,7 +171,7 @@ func (c *ContainerService) ContainerInspect(ctx context.Context, ctn string) (ty if strings.Contains(ctn, "notfound") && !strings.Contains(ctn, "ignorenotfound") { return types.ContainerJSON{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such container: %s", ctn)) } @@ -181,7 +180,7 @@ func (c *ContainerService) ContainerInspect(ctx context.Context, ctn string) (ty if strings.Contains(ctn, "not-found") && !strings.Contains(ctn, "ignore-not-found") { return types.ContainerJSON{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such container: %s", ctn)) } @@ -217,7 +216,7 @@ func (c *ContainerService) ContainerInspectWithRaw(ctx context.Context, ctn stri strings.Contains(ctn, "not-found") { return types.ContainerJSON{}, nil, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such container: %s", ctn)) } @@ -256,7 +255,7 @@ func (c *ContainerService) ContainerKill(ctx context.Context, ctn, signal string // check if the container is not found if strings.Contains(ctn, "notfound") || strings.Contains(ctn, "not-found") { - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages return errdefs.NotFound(fmt.Errorf("Error: No such container: %s", ctn)) } @@ -285,7 +284,7 @@ func (c *ContainerService) ContainerLogs(ctx context.Context, ctn string, option // check if the container is not found if strings.Contains(ctn, "notfound") || strings.Contains(ctn, "not-found") { - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages return nil, errdefs.NotFound(fmt.Errorf("Error: No such container: %s", ctn)) } @@ -308,7 +307,7 @@ func (c *ContainerService) ContainerLogs(ctx context.Context, ctn string, option return nil, err } - return ioutil.NopCloser(response), nil + return io.NopCloser(response), nil } // ContainerPause is a helper function to simulate @@ -331,7 +330,7 @@ func (c *ContainerService) ContainerRemove(ctx context.Context, ctn string, opti // check if the container is not found if strings.Contains(ctn, "notfound") || strings.Contains(ctn, "not-found") { - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages return errdefs.NotFound(fmt.Errorf("Error: No such container: %s", ctn)) } @@ -375,7 +374,7 @@ func (c *ContainerService) ContainerStart(ctx context.Context, ctn string, optio // check if the container is not found if strings.Contains(ctn, "notfound") || strings.Contains(ctn, "not-found") { - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages return errdefs.NotFound(fmt.Errorf("Error: No such container: %s", ctn)) } @@ -412,7 +411,7 @@ func (c *ContainerService) ContainerStop(ctx context.Context, ctn string, timeou // check if the container is not found if strings.Contains(ctn, "notfound") || strings.Contains(ctn, "not-found") { - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages return errdefs.NotFound(fmt.Errorf("Error: No such container: %s", ctn)) } @@ -464,7 +463,7 @@ func (c *ContainerService) ContainerWait(ctx context.Context, ctn string, condit // check if the container is not found if strings.Contains(ctn, "notfound") || strings.Contains(ctn, "not-found") { // propagate the error to the error channel - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errCh <- errdefs.NotFound(fmt.Errorf("Error: No such container: %s", ctn)) return ctnCh, errCh diff --git a/mock/docker/doc.go b/mock/docker/doc.go index bf56572d..24fa2ed8 100644 --- a/mock/docker/doc.go +++ b/mock/docker/doc.go @@ -8,5 +8,5 @@ // // Usage: // -// import "github.com/go-vela/worker/mock/docker" +// import "github.com/go-vela/worker/mock/docker" package docker diff --git a/mock/docker/docker.go b/mock/docker/docker.go index eab1fb7b..58752c18 100644 --- a/mock/docker/docker.go +++ b/mock/docker/docker.go @@ -4,8 +4,6 @@ package docker -// nolint: godot // ignore comment ending in a list -// // Version represents the supported Docker API version for the mock. // // The Docker API version is pinned to ensure compatibility between the @@ -19,11 +17,13 @@ package docker // // * the Docker version of v20.10 has a maximum API version of v1.41 // * to maintain n-1, the API version is pinned to v1.40 +// . const Version = "v1.40" // New returns a client that is capable of handling // Docker client calls and returning stub responses. -// nolint:revive // ignore unexported type as it is intentional +// +//nolint:revive // ignore unexported type as it is intentional func New() (*mock, error) { return &mock{ ConfigService: ConfigService{}, diff --git a/mock/docker/image.go b/mock/docker/image.go index 887d399a..d3cb7dd4 100644 --- a/mock/docker/image.go +++ b/mock/docker/image.go @@ -11,7 +11,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "strings" "time" @@ -90,7 +89,7 @@ func (i *ImageService) ImageInspectWithRaw(ctx context.Context, image string) (t return types.ImageInspect{}, nil, errdefs.NotFound( - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages fmt.Errorf("Error response from daemon: manifest for %s not found: manifest unknown", image), ) } @@ -165,7 +164,7 @@ func (i *ImageService) ImagePull(ctx context.Context, image string, options type !strings.Contains(image, "ignorenotfound") { return nil, errdefs.NotFound( - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages fmt.Errorf("Error response from daemon: manifest for %s not found: manifest unknown", image), ) } @@ -176,13 +175,13 @@ func (i *ImageService) ImagePull(ctx context.Context, image string, options type !strings.Contains(image, "ignore-not-found") { return nil, errdefs.NotFound( - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages fmt.Errorf("Error response from daemon: manifest for %s not found: manifest unknown", image), ) } // create response object to return - response := ioutil.NopCloser( + response := io.NopCloser( bytes.NewReader( []byte( fmt.Sprintf("%s\n%s\n%s\n%s\n", diff --git a/mock/docker/network.go b/mock/docker/network.go index a82b8ef7..d00b1a7b 100644 --- a/mock/docker/network.go +++ b/mock/docker/network.go @@ -47,7 +47,7 @@ func (n *NetworkService) NetworkCreate(ctx context.Context, name string, options if strings.Contains(name, "notfound") && !strings.Contains(name, "ignorenotfound") { return types.NetworkCreateResponse{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such network: %s", name)) } @@ -56,7 +56,7 @@ func (n *NetworkService) NetworkCreate(ctx context.Context, name string, options if strings.Contains(name, "not-found") && !strings.Contains(name, "ignore-not-found") { return types.NetworkCreateResponse{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such network: %s", name)) } @@ -89,14 +89,14 @@ func (n *NetworkService) NetworkInspect(ctx context.Context, network string, opt // check if the network is notfound if strings.Contains(network, "notfound") { return types.NetworkResource{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such network: %s", network)) } // check if the network is not-found if strings.Contains(network, "not-found") { return types.NetworkResource{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such network: %s", network)) } diff --git a/mock/docker/secret.go b/mock/docker/secret.go index ca5286c0..add60b1f 100644 --- a/mock/docker/secret.go +++ b/mock/docker/secret.go @@ -2,7 +2,7 @@ // // Use of this source code is governed by the LICENSE file in this repository. -// nolint: dupl // ignore similar code +//nolint:dupl // ignore similar code package docker import ( diff --git a/mock/docker/volume.go b/mock/docker/volume.go index 18bb14e8..952471d6 100644 --- a/mock/docker/volume.go +++ b/mock/docker/volume.go @@ -39,7 +39,7 @@ func (v *VolumeService) VolumeCreate(ctx context.Context, options volume.VolumeC if strings.Contains(options.Name, "notfound") && !strings.Contains(options.Name, "ignorenotfound") { return types.Volume{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such volume: %s", options.Name)) } @@ -48,7 +48,7 @@ func (v *VolumeService) VolumeCreate(ctx context.Context, options volume.VolumeC if strings.Contains(options.Name, "not-found") && !strings.Contains(options.Name, "ignore-not-found") { return types.Volume{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such volume: %s", options.Name)) } @@ -79,14 +79,14 @@ func (v *VolumeService) VolumeInspect(ctx context.Context, volumeID string) (typ // check if the volume is notfound if strings.Contains(volumeID, "notfound") { return types.Volume{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such volume: %s", volumeID)) } // check if the volume is not-found if strings.Contains(volumeID, "not-found") { return types.Volume{}, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such volume: %s", volumeID)) } @@ -116,14 +116,14 @@ func (v *VolumeService) VolumeInspectWithRaw(ctx context.Context, volumeID strin // check if the volume is notfound if strings.Contains(volumeID, "notfound") { return types.Volume{}, nil, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such volume: %s", volumeID)) } // check if the volume is not-found if strings.Contains(volumeID, "not-found") { return types.Volume{}, nil, - // nolint:stylecheck // messsage is capitalized to match Docker messages + //nolint:stylecheck // messsage is capitalized to match Docker messages errdefs.NotFound(fmt.Errorf("Error: No such volume: %s", volumeID)) } diff --git a/mock/worker/doc.go b/mock/worker/doc.go index 281bb581..4f30620b 100644 --- a/mock/worker/doc.go +++ b/mock/worker/doc.go @@ -6,5 +6,5 @@ // // Usage: // -// import "github.com/go-vela/worker/mock/worker" +// import "github.com/go-vela/worker/mock/worker" package worker diff --git a/router/build.go b/router/build.go index 9035840f..8f0f05c3 100644 --- a/router/build.go +++ b/router/build.go @@ -10,14 +10,13 @@ import ( "github.com/go-vela/worker/api" ) -// nolint: godot // ignore comment ending in period -// // BuildHandlers extends the provided base router group // by adding a collection of endpoints for handling // build related requests. // // GET /api/v1/executors/:executor/build // DELETE /api/v1/executors/:executor/build/cancel +// . func BuildHandlers(base *gin.RouterGroup) { // add a collection of endpoints for handling build related requests // diff --git a/router/doc.go b/router/doc.go index e43cf3f4..8ce29ea8 100644 --- a/router/doc.go +++ b/router/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/router" +// import "github.com/go-vela/worker/router" package router diff --git a/router/executor.go b/router/executor.go index a5c572b5..522fa197 100644 --- a/router/executor.go +++ b/router/executor.go @@ -10,8 +10,6 @@ import ( "github.com/go-vela/worker/router/middleware/executor" ) -// nolint: godot // ignore comment ending in period -// // ExecutorHandlers extends the provided base router group // by adding a collection of endpoints for handling // executor related requests. @@ -22,6 +20,7 @@ import ( // DELETE /api/v1/executors/:executor/build/cancel // GET /api/v1/executors/:executor/pipeline // GET /api/v1/executors/:executor/repo +// . func ExecutorHandlers(base *gin.RouterGroup) { // add a collection of endpoints for handling executors related requests // diff --git a/router/middleware/doc.go b/router/middleware/doc.go index 8fb02358..09d15234 100644 --- a/router/middleware/doc.go +++ b/router/middleware/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/router/middleware" +// import "github.com/go-vela/worker/router/middleware" package middleware diff --git a/router/middleware/logger.go b/router/middleware/logger.go index b9431515..3c610141 100644 --- a/router/middleware/logger.go +++ b/router/middleware/logger.go @@ -17,8 +17,8 @@ import ( // Requests without errors are logged using logrus.Info(). // // It receives: -// 1. A time package format string (e.g. time.RFC3339). -// 2. A boolean stating whether to use UTC time zone or local. +// 1. A time package format string (e.g. time.RFC3339). +// 2. A boolean stating whether to use UTC time zone or local. func Logger(logger *logrus.Logger, timeFormat string, utc bool) gin.HandlerFunc { return func(c *gin.Context) { start := time.Now() diff --git a/router/middleware/logger_test.go b/router/middleware/logger_test.go index d20b400d..71553472 100644 --- a/router/middleware/logger_test.go +++ b/router/middleware/logger_test.go @@ -80,7 +80,7 @@ func TestMiddleware_Logger_Error(t *testing.T) { // setup mock server engine.Use(Logger(logger, time.RFC3339, true)) engine.GET("/foobar", func(c *gin.Context) { - // nolint: errcheck // ignore checking error + //nolint:errcheck // ignore checking error c.Error(fmt.Errorf("test error")) c.Status(http.StatusOK) }) diff --git a/router/middleware/payload.go b/router/middleware/payload.go index 2ef7e5e2..c2241fa9 100644 --- a/router/middleware/payload.go +++ b/router/middleware/payload.go @@ -7,7 +7,7 @@ package middleware import ( "bytes" "encoding/json" - "io/ioutil" + "io" "github.com/gin-gonic/gin" ) @@ -24,7 +24,7 @@ func Payload() gin.HandlerFunc { c.Set("payload", payload) - c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(body)) + c.Request.Body = io.NopCloser(bytes.NewBuffer(body)) c.Next() } diff --git a/router/middleware/perm/doc.go b/router/middleware/perm/doc.go index e68e1c71..0f42c133 100644 --- a/router/middleware/perm/doc.go +++ b/router/middleware/perm/doc.go @@ -8,5 +8,5 @@ // // Usage: // -// import "github.com/go-vela/worker/router/middleware/perm" +// import "github.com/go-vela/worker/router/middleware/perm" package perm diff --git a/router/middleware/token/doc.go b/router/middleware/token/doc.go index 63e877fe..a13ef8cf 100644 --- a/router/middleware/token/doc.go +++ b/router/middleware/token/doc.go @@ -8,5 +8,5 @@ // // Usage: // -// import "github.com/go-vela/worker/router/middleware/token" +// import "github.com/go-vela/worker/router/middleware/token" package token diff --git a/router/middleware/token/token.go b/router/middleware/token/token.go index 0327c607..5e437e99 100644 --- a/router/middleware/token/token.go +++ b/router/middleware/token/token.go @@ -10,8 +10,6 @@ import ( "strings" ) -// nolint: godot // ignore comment ending in period -// // Retrieve gets the token from the provided request http.Request // to be parsed and validated. This is called on every request // to enable capturing the user making the request and validating @@ -19,6 +17,7 @@ import ( // authentication to Vela are supported: // // * Bearer token in `Authorization` header +// . func Retrieve(r *http.Request) (string, error) { // get the token from the `Authorization` header token := r.Header.Get("Authorization") diff --git a/router/middleware/user/doc.go b/router/middleware/user/doc.go index b476b5e2..7ba0a485 100644 --- a/router/middleware/user/doc.go +++ b/router/middleware/user/doc.go @@ -8,5 +8,5 @@ // // Usage: // -// import "github.com/go-vela/worker/router/middleware/user" +// import "github.com/go-vela/worker/router/middleware/user" package user diff --git a/router/pipeline.go b/router/pipeline.go index 59b406ee..42868bf2 100644 --- a/router/pipeline.go +++ b/router/pipeline.go @@ -10,13 +10,12 @@ import ( "github.com/go-vela/worker/api" ) -// nolint: godot // ignore comment ending in period -// // PipelineHandlers extends the provided base router group // by adding a collection of endpoints for handling // pipeline related requests. // // GET /api/v1/executors/:executor/pipeline +// . func PipelineHandlers(base *gin.RouterGroup) { // add a collection of endpoints for handling pipeline related requests // diff --git a/router/repo.go b/router/repo.go index ca27b3f6..0f011451 100644 --- a/router/repo.go +++ b/router/repo.go @@ -10,13 +10,12 @@ import ( "github.com/go-vela/worker/api" ) -// nolint: godot // ignore comment ending in period -// // RepoHandlers extends the provided base router group // by adding a collection of endpoints for handling // repo related requests. // // GET /api/v1/executors/:executor/repo +// . func RepoHandlers(base *gin.RouterGroup) { // add a collection of endpoints for handling repo related requests // diff --git a/router/router.go b/router/router.go index c515f5c9..222029df 100644 --- a/router/router.go +++ b/router/router.go @@ -6,22 +6,22 @@ // // API for a Vela worker // -// Version: 0.0.0-dev -// Schemes: http, https -// Host: localhost +// Version: 0.0.0-dev +// Schemes: http, https +// Host: localhost // -// Consumes: -// - application/json +// Consumes: +// - application/json // -// Produces: -// - application/json +// Produces: +// - application/json // -// SecurityDefinitions: -// ApiKeyAuth: -// description: Bearer token -// type: apiKey -// in: header -// name: Authorization +// SecurityDefinitions: +// ApiKeyAuth: +// description: Bearer token +// type: apiKey +// in: header +// name: Authorization // // swagger:meta package router diff --git a/runtime/context.go b/runtime/context.go index 0579fe60..47487716 100644 --- a/runtime/context.go +++ b/runtime/context.go @@ -54,7 +54,7 @@ func FromGinContext(c *gin.Context) Engine { func WithContext(c context.Context, e Engine) context.Context { // set the runtime Engine in the context.Context // - // nolint: revive,staticcheck // ignore using string with context value + //nolint:revive,staticcheck // ignore using string with context value return context.WithValue(c, key, e) } diff --git a/runtime/context_test.go b/runtime/context_test.go index f7e45310..ddac5db8 100644 --- a/runtime/context_test.go +++ b/runtime/context_test.go @@ -31,7 +31,7 @@ func TestRuntime_FromContext(t *testing.T) { }{ { name: "valid runtime in context", - // nolint: staticcheck,revive // ignore using string with context value + //nolint:staticcheck,revive // ignore using string with context value context: context.WithValue(context.Background(), key, _engine), want: _engine, }, @@ -42,7 +42,7 @@ func TestRuntime_FromContext(t *testing.T) { }, { name: "invalid runtime in context", - // nolint: staticcheck,revive // ignore using string with context value + //nolint:staticcheck,revive // ignore using string with context value context: context.WithValue(context.Background(), key, "foo"), want: nil, }, @@ -121,7 +121,7 @@ func TestRuntime_WithContext(t *testing.T) { t.Errorf("unable to create runtime engine: %v", err) } - // nolint: staticcheck,revive // ignore using string with context value + //nolint:staticcheck,revive // ignore using string with context value want := context.WithValue(context.Background(), key, _engine) // run test diff --git a/runtime/doc.go b/runtime/doc.go index 78ea790f..46169ce4 100644 --- a/runtime/doc.go +++ b/runtime/doc.go @@ -13,5 +13,5 @@ // // Usage: // -// import "github.com/go-vela/worker/runtime" +// import "github.com/go-vela/worker/runtime" package runtime diff --git a/runtime/docker/doc.go b/runtime/docker/doc.go index 9edb7dc0..93a977a5 100644 --- a/runtime/docker/doc.go +++ b/runtime/docker/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/runtime/docker" +// import "github.com/go-vela/worker/runtime/docker" package docker diff --git a/runtime/docker/docker.go b/runtime/docker/docker.go index c286c31f..ba0de3b0 100644 --- a/runtime/docker/docker.go +++ b/runtime/docker/docker.go @@ -10,8 +10,6 @@ import ( "github.com/sirupsen/logrus" ) -// nolint: godot // ignore period at end for comment ending in a list -// // Version represents the supported Docker API version for the mock. // // The Docker API version is pinned to ensure compatibility between the @@ -25,6 +23,7 @@ import ( // // * the Docker version of v20.10 has a maximum API version of v1.41 // * to maintain n-1, the API version is pinned to v1.40 +// . const Version = "v1.40" type config struct { @@ -45,7 +44,7 @@ type client struct { // New returns an Engine implementation that // integrates with a Docker runtime. // -// nolint: revive // ignore returning unexported client +//nolint:revive // ignore returning unexported client func New(opts ...ClientOpt) (*client, error) { // create new Docker client c := new(client) @@ -98,7 +97,7 @@ func New(opts ...ClientOpt) (*client, error) { // // This function is intended for running tests only. // -// nolint: revive // ignore returning unexported client +//nolint:revive // ignore returning unexported client func NewMock(opts ...ClientOpt) (*client, error) { // create new Docker runtime client c, err := New(opts...) diff --git a/runtime/docker/image.go b/runtime/docker/image.go index e53f7be3..8aa45f01 100644 --- a/runtime/docker/image.go +++ b/runtime/docker/image.go @@ -8,7 +8,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "os" "strings" @@ -54,7 +53,7 @@ func (c *client) CreateImage(ctx context.Context, ctn *pipeline.Container) error } } else { // discard output from image pull - _, err = io.Copy(ioutil.Discard, reader) + _, err = io.Copy(io.Discard, reader) if err != nil { return err } diff --git a/runtime/kubernetes/apis/doc.go b/runtime/kubernetes/apis/doc.go index e45ff9ac..12ffd8cb 100644 --- a/runtime/kubernetes/apis/doc.go +++ b/runtime/kubernetes/apis/doc.go @@ -6,5 +6,5 @@ // // Usage: // -// import "github.com/go-vela/worker/runtime/kubernetes/apis" +// import "github.com/go-vela/worker/runtime/kubernetes/apis" package apis diff --git a/runtime/kubernetes/apis/vela/v1alpha1/doc.go b/runtime/kubernetes/apis/vela/v1alpha1/doc.go index b0a6f8d1..44ad049d 100644 --- a/runtime/kubernetes/apis/vela/v1alpha1/doc.go +++ b/runtime/kubernetes/apis/vela/v1alpha1/doc.go @@ -11,5 +11,5 @@ // // Usage: // -// import "github.com/go-vela/worker/runtime/kubernetes/apis/v1alpha1" +// import "github.com/go-vela/worker/runtime/kubernetes/apis/v1alpha1" package v1alpha1 diff --git a/runtime/kubernetes/container.go b/runtime/kubernetes/container.go index ab6914c1..e7118de3 100644 --- a/runtime/kubernetes/container.go +++ b/runtime/kubernetes/container.go @@ -9,7 +9,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "strings" "time" @@ -267,7 +266,7 @@ func (c *client) TailContainer(ctx context.Context, ctn *pipeline.Container) (io // peek at container logs from the stream bytes, err := reader.Peek(5) if err != nil { - // nolint: nilerr // ignore nil return + //nolint:nilerr // ignore nil return // skip so we resend API call to capture stream return false, nil } @@ -275,7 +274,7 @@ func (c *client) TailContainer(ctx context.Context, ctn *pipeline.Container) (io // check if we have container logs from the stream if len(bytes) > 0 { // set the logs to the reader - logs = ioutil.NopCloser(reader) + logs = io.NopCloser(reader) return true, nil } diff --git a/runtime/kubernetes/container_test.go b/runtime/kubernetes/container_test.go index 74369658..cb190171 100644 --- a/runtime/kubernetes/container_test.go +++ b/runtime/kubernetes/container_test.go @@ -646,7 +646,7 @@ func Test_podTracker_inspectContainerStatuses(t *testing.T) { func() { defer func() { - // nolint: errcheck // repeat close() panics (otherwise it won't) + //nolint:errcheck // repeat close() panics (otherwise it won't) recover() }() diff --git a/runtime/kubernetes/doc.go b/runtime/kubernetes/doc.go index 76f0ff73..75582084 100644 --- a/runtime/kubernetes/doc.go +++ b/runtime/kubernetes/doc.go @@ -7,5 +7,5 @@ // // Usage: // -// import "github.com/go-vela/worker/runtime/kubernetes" +// import "github.com/go-vela/worker/runtime/kubernetes" package kubernetes diff --git a/runtime/kubernetes/generated/clientset/versioned/fake/register.go b/runtime/kubernetes/generated/clientset/versioned/fake/register.go index c8a5f06d..7ce53f3e 100644 --- a/runtime/kubernetes/generated/clientset/versioned/fake/register.go +++ b/runtime/kubernetes/generated/clientset/versioned/fake/register.go @@ -25,14 +25,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/runtime/kubernetes/generated/clientset/versioned/scheme/register.go b/runtime/kubernetes/generated/clientset/versioned/scheme/register.go index 38f25139..bab57b34 100644 --- a/runtime/kubernetes/generated/clientset/versioned/scheme/register.go +++ b/runtime/kubernetes/generated/clientset/versioned/scheme/register.go @@ -25,14 +25,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/runtime/kubernetes/kubernetes.go b/runtime/kubernetes/kubernetes.go index 5532bafb..aabc2a28 100644 --- a/runtime/kubernetes/kubernetes.go +++ b/runtime/kubernetes/kubernetes.go @@ -57,7 +57,7 @@ type client struct { // New returns an Engine implementation that // integrates with a Kubernetes runtime. // -// nolint: revive // ignore returning unexported client +//nolint:revive // ignore returning unexported client func New(opts ...ClientOpt) (*client, error) { // create new Kubernetes client c := new(client) @@ -137,7 +137,7 @@ func New(opts ...ClientOpt) (*client, error) { // // This function is intended for running tests only. // -// nolint: revive // ignore returning unexported client +//nolint:revive // ignore returning unexported client func NewMock(_pod *v1.Pod, opts ...ClientOpt) (*client, error) { // create new Kubernetes client c := new(client) diff --git a/runtime/kubernetes/opts.go b/runtime/kubernetes/opts.go index c562d9f1..81076406 100644 --- a/runtime/kubernetes/opts.go +++ b/runtime/kubernetes/opts.go @@ -6,7 +6,7 @@ package kubernetes import ( "fmt" - "io/ioutil" + "os" "github.com/sirupsen/logrus" @@ -91,7 +91,7 @@ func WithPodsTemplate(name string, path string) ClientOpt { if len(name) == 0 { // load the PodsTemplate from the path (must restart Worker to reload the local file) - if data, err := ioutil.ReadFile(path); err == nil { + if data, err := os.ReadFile(path); err == nil { pipelinePodsTemplate := velav1alpha1.PipelinePodsTemplate{} err := yaml.UnmarshalStrict(data, &pipelinePodsTemplate) diff --git a/runtime/kubernetes/volume.go b/runtime/kubernetes/volume.go index a786d193..c22bab7f 100644 --- a/runtime/kubernetes/volume.go +++ b/runtime/kubernetes/volume.go @@ -128,7 +128,8 @@ func (c *client) RemoveVolume(ctx context.Context, b *pipeline.Build) error { } // setupVolumeMounts generates the VolumeMounts for a given container. -// nolint:unparam // keep signature similar to Engine interface methods despite unused ctx and err +// +//nolint:unparam // keep signature similar to Engine interface methods despite unused ctx and err func (c *client) setupVolumeMounts(ctx context.Context, ctn *pipeline.Container) ( volumeMounts []v1.VolumeMount, err error, diff --git a/runtime/runtime.go b/runtime/runtime.go index 4ec77e21..d4c25acc 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -11,8 +11,6 @@ import ( "github.com/sirupsen/logrus" ) -// nolint: godot // ignore period at end for comment ending in a list -// // New creates and returns a Vela engine capable of // integrating with the configured runtime. // @@ -20,6 +18,7 @@ import ( // // * docker // * kubernetes +// . func New(s *Setup) (Engine, error) { // validate the setup being provided // From 1f446b1da4c870d8d08deb38259131c89d58e4eb Mon Sep 17 00:00:00 2001 From: ecrupper Date: Wed, 14 Sep 2022 14:57:46 -0500 Subject: [PATCH 2/3] go mod tidy --- go.sum | 1 - 1 file changed, 1 deletion(-) diff --git a/go.sum b/go.sum index 2223fecb..b3f00a71 100644 --- a/go.sum +++ b/go.sum @@ -190,7 +190,6 @@ github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGF github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= From 5aed965808856393a04fa848b0ebf226052eb548 Mon Sep 17 00:00:00 2001 From: ecrupper Date: Wed, 14 Sep 2022 15:04:28 -0500 Subject: [PATCH 3/3] fixing struct check --- executor/linux/linux.go | 1 - 1 file changed, 1 deletion(-) diff --git a/executor/linux/linux.go b/executor/linux/linux.go index 2924f43a..d8650cdc 100644 --- a/executor/linux/linux.go +++ b/executor/linux/linux.go @@ -49,7 +49,6 @@ type ( err error } - //nolint:structcheck // ignore false positive svc struct { client *client }