From 3c3137c26f7524c7e26c3e82b4286b5b67de6168 Mon Sep 17 00:00:00 2001 From: Dan Lorenc Date: Tue, 31 Aug 2021 21:31:59 -0500 Subject: [PATCH] Bump golangci-lint to v1.42.0 from v1.30.0. Also fix the resulting lint errors, and a few of the resulting lint warnings. One of the main linters we use (golint) is now deprecated. The replacement is known as revive, and golangci-lint displays a warning about this now. Unfortunately quite a few lint warnings appear during that update, so I'm doing it in a few pieces. Signed-off-by: Dan Lorenc --- Makefile | 2 +- pkg/apis/pipeline/v1beta1/version_validation.go | 3 +-- pkg/apis/pipeline/v1beta1/workspace_validation.go | 2 +- pkg/pod/pod.go | 6 +++--- pkg/pod/pod_test.go | 4 ++-- pkg/reconciler/pipelinerun/pipelinerun_test.go | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 2560208f697..58fa5c6e184 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ TESTPKGS = $(shell env GO111MODULE=on $(GO) list -f \ $(PKGS)) BIN = $(CURDIR)/.bin -GOLANGCI_VERSION = v1.30.0 +GOLANGCI_VERSION = v1.42.0 GOSEC_VERSION = v2.4.0 GO = go diff --git a/pkg/apis/pipeline/v1beta1/version_validation.go b/pkg/apis/pipeline/v1beta1/version_validation.go index e4b1bcba705..4d58eeb755e 100644 --- a/pkg/apis/pipeline/v1beta1/version_validation.go +++ b/pkg/apis/pipeline/v1beta1/version_validation.go @@ -34,6 +34,5 @@ func ValidateEnabledAPIFields(ctx context.Context, featureName, wantVersion stri message := fmt.Sprintf(`%s requires "enable-api-fields" feature gate to be %q but it is %q`, featureName, wantVersion, currentVersion) return errs.Also(apis.ErrGeneric(message)) } - var errs *apis.FieldError = nil - return errs + return nil } diff --git a/pkg/apis/pipeline/v1beta1/workspace_validation.go b/pkg/apis/pipeline/v1beta1/workspace_validation.go index 01ef7ede0e9..1aff7f04409 100644 --- a/pkg/apis/pipeline/v1beta1/workspace_validation.go +++ b/pkg/apis/pipeline/v1beta1/workspace_validation.go @@ -25,7 +25,7 @@ import ( // allVolumeSourceFields is a list of all the volume source field paths that a // WorkspaceBinding may include. -var allVolumeSourceFields []string = []string{ +var allVolumeSourceFields = []string{ "persistentvolumeclaim", "volumeclaimtemplate", "emptydir", diff --git a/pkg/pod/pod.go b/pkg/pod/pod.go index 53b9c69e7ec..8f57b3b04f6 100644 --- a/pkg/pod/pod.go +++ b/pkg/pod/pod.go @@ -189,7 +189,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec // themselves their value takes precedence. if len(implicitEnvVars) > 0 { for i, s := range stepContainers { - env := append(implicitEnvVars, s.Env...) + env := append(implicitEnvVars, s.Env...) //nolint stepContainers[i].Env = env } } @@ -198,7 +198,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec if taskRun.Annotations[ExecutionModeAnnotation] == ExecutionModeHermetic && alphaAPIEnabled { for i, s := range stepContainers { // Add it at the end so it overrides - env := append(s.Env, corev1.EnvVar{Name: TektonHermeticEnvVar, Value: "1"}) + env := append(s.Env, corev1.EnvVar{Name: TektonHermeticEnvVar, Value: "1"}) //nolint stepContainers[i].Env = env } } @@ -227,7 +227,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec toAdd = append(toAdd, imp) } } - vms := append(s.VolumeMounts, toAdd...) + vms := append(s.VolumeMounts, toAdd...) //nolint stepContainers[i].VolumeMounts = vms } diff --git a/pkg/pod/pod_test.go b/pkg/pod/pod_test.go index 95165f3ff22..fc93f085c81 100644 --- a/pkg/pod/pod_test.go +++ b/pkg/pod/pod_test.go @@ -1604,7 +1604,7 @@ _EOF_ overrideHomeEnv := false if s, ok := c.featureFlags[featureFlagDisableHomeEnvKey]; ok { - var err error = nil + var err error if overrideHomeEnv, err = strconv.ParseBool(s); err != nil { t.Fatalf("error parsing bool from %s feature flag: %v", featureFlagDisableHomeEnvKey, err) } @@ -1762,7 +1762,7 @@ func TestPodBuildwithAlphaAPIEnabled(t *testing.T) { overrideHomeEnv := false if s, ok := c.featureFlags[featureFlagDisableHomeEnvKey]; ok { - var err error = nil + var err error if overrideHomeEnv, err = strconv.ParseBool(s); err != nil { t.Fatalf("error parsing bool from %s feature flag: %v", featureFlagDisableHomeEnvKey, err) } diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index 5b36c3c1bc0..dee66dbd98f 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -1003,7 +1003,7 @@ func TestReconcile_InvalidPipelineRuns(t *testing.T) { prt := newPipelineRunTest(d, t) defer prt.Cancel() - wantEvents := append(tc.wantEvents, "Warning InternalError 1 error occurred") + wantEvents := append(tc.wantEvents, "Warning InternalError 1 error occurred") //nolint reconciledRun, _ := prt.reconcileRun("foo", tc.pipelineRun.Name, wantEvents, tc.permanentError) if reconciledRun.Status.CompletionTime == nil {