Skip to content

Commit 96db451

Browse files
vdemeestertekton-robot
authored andcommitted
Fix golangci-lint issues
Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
1 parent 82d2fe8 commit 96db451

File tree

7 files changed

+16
-19
lines changed

7 files changed

+16
-19
lines changed

cmd/entrypoint/subcommands/subcommands.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ func Process(args []string) error {
9898
return OK{message: "Decoded script " + src}
9999
}
100100
case StepInitCommand:
101-
//nolint: gosec
102101
if err := stepInit(args[1:]); err != nil {
103102
return SubcommandError{subcommand: StepInitCommand, message: err.Error()}
104103
}

pkg/apis/config/feature_flags_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ func TestNewFeatureFlagsConfigMapErrors(t *testing.T) {
332332
}
333333

334334
func TestGetVerificationNoMatchPolicy(t *testing.T) {
335-
ctx := context.Background()
336335
tcs := []struct {
337336
name, noMatchPolicy, expected string
338337
}{{
@@ -351,6 +350,7 @@ func TestGetVerificationNoMatchPolicy(t *testing.T) {
351350

352351
for _, tc := range tcs {
353352
t.Run(tc.name, func(t *testing.T) {
353+
ctx := context.Background()
354354
store := config.NewStore(logging.FromContext(ctx).Named("config-store"))
355355
featureflags := &corev1.ConfigMap{
356356
ObjectMeta: metav1.ObjectMeta{

pkg/pod/creds_init_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ func TestCredsInit(t *testing.T) {
335335
eventObj := &corev1.Event{}
336336
kubeclient := fakek8s.NewSimpleClientset(c.objs...)
337337
recorder := record.NewFakeRecorder(1000)
338-
c.ctx = controller.WithEventRecorder(c.ctx, recorder)
339-
args, volumes, volumeMounts, err := credsInit(c.ctx, eventObj, serviceAccountName, namespace, kubeclient)
338+
ctx := controller.WithEventRecorder(c.ctx, recorder)
339+
args, volumes, volumeMounts, err := credsInit(ctx, eventObj, serviceAccountName, namespace, kubeclient)
340340
if err != nil {
341341
t.Fatalf("credsInit: %v", err)
342342
}

pkg/pod/pod.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1.TaskRun, taskSpec v1.Ta
336336
// Each step should only mount their own volume as RW,
337337
// all other steps should be mounted RO.
338338
volumes = append(volumes, runVolume(i))
339-
for j := range len(stepContainers) {
339+
for j := range stepContainers {
340340
s.VolumeMounts = append(s.VolumeMounts, runMount(j, i != j))
341341
}
342342

@@ -362,7 +362,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1.TaskRun, taskSpec v1.Ta
362362
if s.Name != pipeline.ReservedResultsSidecarName {
363363
continue
364364
}
365-
for j := range len(stepContainers) {
365+
for j := range stepContainers {
366366
s.VolumeMounts = append(s.VolumeMounts, runMount(j, true))
367367
}
368368
requestedVolumeMounts := map[string]bool{}

pkg/reconciler/events/k8sevent/events.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func eventsFromChannel(c chan string, wantEvents []string) error {
4646
// on the channel forever if fewer than expected events are received
4747
timer := time.After(wait.ForeverTestTimeout)
4848
foundEvents := []string{}
49-
for ii := range len(wantEvents) {
49+
for ii := range wantEvents {
5050
// We loop over all the events that we expect. Once they are all received
5151
// we exit the loop. If we never receive enough events, the timeout takes us
5252
// out of the loop.

pkg/reconciler/pipelinerun/resources/pipelineref_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ func TestGetPipelineFunc_V1beta1Pipeline_VerifyNoError(t *testing.T) {
741741
}
742742
for _, tc := range testcases {
743743
t.Run(tc.name, func(t *testing.T) {
744-
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
744+
ctx := test.SetupTrustedResourceConfig(context.Background(), tc.verificationNoMatchPolicy)
745745
fn := resources.GetPipelineFunc(ctx, k8sclient, tektonclient, tc.requester, &tc.pipelinerun, tc.policies)
746746

747747
gotResolvedPipeline, gotSource, gotVerificationResult, err := fn(ctx, pipelineRef.Name)
@@ -768,7 +768,6 @@ func TestGetPipelineFunc_V1beta1Pipeline_VerifyNoError(t *testing.T) {
768768
}
769769

770770
func TestGetPipelineFunc_V1beta1Pipeline_VerifyError(t *testing.T) {
771-
ctx := context.Background()
772771
tektonclient := fake.NewSimpleClientset()
773772
signer, _, k8sclient, vps := test.SetupVerificationPolicies(t)
774773

@@ -863,7 +862,7 @@ func TestGetPipelineFunc_V1beta1Pipeline_VerifyError(t *testing.T) {
863862
}
864863
for _, tc := range testcases {
865864
t.Run(tc.name, func(t *testing.T) {
866-
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
865+
ctx := test.SetupTrustedResourceConfig(context.Background(), tc.verificationNoMatchPolicy)
867866
pr := &v1.PipelineRun{
868867
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
869868
Spec: v1.PipelineRunSpec{
@@ -1072,7 +1071,7 @@ func TestGetPipelineFunc_V1Pipeline_VerifyNoError(t *testing.T) {
10721071
}
10731072
for _, tc := range testcases {
10741073
t.Run(tc.name, func(t *testing.T) {
1075-
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
1074+
ctx := test.SetupTrustedResourceConfig(context.Background(), tc.verificationNoMatchPolicy)
10761075
fn := resources.GetPipelineFunc(ctx, k8sclient, tektonclient, tc.requester, &tc.pipelinerun, tc.policies)
10771076

10781077
gotResolvedPipeline, gotSource, gotVerificationResult, err := fn(ctx, pipelineRef.Name)
@@ -1099,7 +1098,6 @@ func TestGetPipelineFunc_V1Pipeline_VerifyNoError(t *testing.T) {
10991098
}
11001099

11011100
func TestGetPipelineFunc_V1Pipeline_VerifyError(t *testing.T) {
1102-
ctx := context.Background()
11031101
tektonclient := fake.NewSimpleClientset()
11041102
signer, _, k8sclient, vps := test.SetupVerificationPolicies(t)
11051103

@@ -1193,7 +1191,7 @@ func TestGetPipelineFunc_V1Pipeline_VerifyError(t *testing.T) {
11931191
}
11941192
for _, tc := range testcases {
11951193
t.Run(tc.name, func(t *testing.T) {
1196-
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
1194+
ctx := test.SetupTrustedResourceConfig(context.Background(), tc.verificationNoMatchPolicy)
11971195
pr := &v1.PipelineRun{
11981196
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
11991197
Spec: v1.PipelineRunSpec{
@@ -1215,7 +1213,6 @@ func TestGetPipelineFunc_V1Pipeline_VerifyError(t *testing.T) {
12151213
}
12161214

12171215
func TestGetPipelineFunc_GetFuncError(t *testing.T) {
1218-
ctx := context.Background()
12191216
tektonclient := fake.NewSimpleClientset()
12201217
_, k8sclient, vps := test.SetupMatchAllVerificationPolicies(t, "trusted-resources")
12211218

@@ -1259,6 +1256,7 @@ func TestGetPipelineFunc_GetFuncError(t *testing.T) {
12591256
}
12601257
for _, tc := range testcases {
12611258
t.Run(tc.name, func(t *testing.T) {
1259+
ctx := context.Background()
12621260
store := config.NewStore(logging.FromContext(ctx).Named("config-store"))
12631261
featureflags := &corev1.ConfigMap{
12641262
ObjectMeta: metav1.ObjectMeta{

pkg/reconciler/taskrun/resources/taskref_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ func TestGetTaskFunc_V1beta1Task_VerifyNoError(t *testing.T) {
14301430
}
14311431
for _, tc := range testcases {
14321432
t.Run(tc.name, func(t *testing.T) {
1433-
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
1433+
ctx := test.SetupTrustedResourceConfig(context.Background(), tc.verificationNoMatchPolicy)
14341434
tr := &v1.TaskRun{
14351435
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
14361436
Spec: v1.TaskRunSpec{
@@ -1558,7 +1558,7 @@ func TestGetTaskFunc_V1beta1Task_VerifyError(t *testing.T) {
15581558
}
15591559
for _, tc := range testcases {
15601560
t.Run(tc.name, func(t *testing.T) {
1561-
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
1561+
ctx := test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
15621562
tr := &v1.TaskRun{
15631563
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
15641564
Spec: v1.TaskRunSpec{
@@ -1694,7 +1694,7 @@ func TestGetTaskFunc_V1Task_VerifyNoError(t *testing.T) {
16941694
}
16951695
for _, tc := range testcases {
16961696
t.Run(tc.name, func(t *testing.T) {
1697-
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
1697+
ctx := test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
16981698
tr := &v1.TaskRun{
16991699
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
17001700
Spec: v1.TaskRunSpec{
@@ -1820,7 +1820,7 @@ func TestGetTaskFunc_V1Task_VerifyError(t *testing.T) {
18201820
}
18211821
for _, tc := range testcases {
18221822
t.Run(tc.name, func(t *testing.T) {
1823-
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
1823+
ctx := test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
18241824
tr := &v1.TaskRun{
18251825
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
18261826
Spec: v1.TaskRunSpec{
@@ -1892,7 +1892,7 @@ func TestGetTaskFunc_GetFuncError(t *testing.T) {
18921892
},
18931893
}
18941894
store.OnConfigChanged(featureflags)
1895-
ctx = store.ToContext(ctx)
1895+
ctx := store.ToContext(ctx)
18961896

18971897
fn := resources.GetTaskFunc(ctx, k8sclient, tektonclient, tc.requester, &tc.taskrun, tc.taskrun.Spec.TaskRef, "", "default", "default", vps)
18981898

0 commit comments

Comments
 (0)