Skip to content

Commit

Permalink
Fix golangci-lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester committed Sep 30, 2024
1 parent a1b071d commit 676c48a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 19 deletions.
1 change: 0 additions & 1 deletion cmd/entrypoint/subcommands/subcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func Process(args []string) error {
return OK{message: "Decoded script " + src}
}
case StepInitCommand:
//nolint: gosec
if err := stepInit(args[1:]); err != nil {
return SubcommandError{subcommand: StepInitCommand, message: err.Error()}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/config/feature_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ func TestNewFeatureFlagsConfigMapErrors(t *testing.T) {
}

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

for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
ctx := context.Background()
store := config.NewStore(logging.FromContext(ctx).Named("config-store"))
featureflags := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand Down
4 changes: 2 additions & 2 deletions pkg/pod/creds_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ func TestCredsInit(t *testing.T) {
eventObj := &corev1.Event{}
kubeclient := fakek8s.NewSimpleClientset(c.objs...)
recorder := record.NewFakeRecorder(1000)
c.ctx = controller.WithEventRecorder(c.ctx, recorder)
args, volumes, volumeMounts, err := credsInit(c.ctx, eventObj, serviceAccountName, namespace, kubeclient)
ctx := controller.WithEventRecorder(c.ctx, recorder)
args, volumes, volumeMounts, err := credsInit(ctx, eventObj, serviceAccountName, namespace, kubeclient)
if err != nil {
t.Fatalf("credsInit: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1.TaskRun, taskSpec v1.Ta
// Each step should only mount their own volume as RW,
// all other steps should be mounted RO.
volumes = append(volumes, runVolume(i))
for j := range len(stepContainers) {
for j := range stepContainers {
s.VolumeMounts = append(s.VolumeMounts, runMount(j, i != j))
}

Expand All @@ -362,7 +362,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1.TaskRun, taskSpec v1.Ta
if s.Name != pipeline.ReservedResultsSidecarName {
continue
}
for j := range len(stepContainers) {
for j := range stepContainers {
s.VolumeMounts = append(s.VolumeMounts, runMount(j, true))
}
requestedVolumeMounts := map[string]bool{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/events/k8sevent/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func eventsFromChannel(c chan string, wantEvents []string) error {
// on the channel forever if fewer than expected events are received
timer := time.After(wait.ForeverTestTimeout)
foundEvents := []string{}
for ii := range len(wantEvents) {
for ii := range wantEvents {
// We loop over all the events that we expect. Once they are all received
// we exit the loop. If we never receive enough events, the timeout takes us
// out of the loop.
Expand Down
12 changes: 5 additions & 7 deletions pkg/reconciler/pipelinerun/resources/pipelineref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ func TestGetPipelineFunc_V1beta1Pipeline_VerifyNoError(t *testing.T) {
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
ctx := test.SetupTrustedResourceConfig(context.Background(), tc.verificationNoMatchPolicy)
fn := resources.GetPipelineFunc(ctx, k8sclient, tektonclient, tc.requester, &tc.pipelinerun, tc.policies)

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

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

Expand Down Expand Up @@ -863,7 +862,7 @@ func TestGetPipelineFunc_V1beta1Pipeline_VerifyError(t *testing.T) {
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
ctx := test.SetupTrustedResourceConfig(context.Background(), tc.verificationNoMatchPolicy)
pr := &v1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
Spec: v1.PipelineRunSpec{
Expand Down Expand Up @@ -1072,7 +1071,7 @@ func TestGetPipelineFunc_V1Pipeline_VerifyNoError(t *testing.T) {
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
ctx := test.SetupTrustedResourceConfig(context.Background(), tc.verificationNoMatchPolicy)
fn := resources.GetPipelineFunc(ctx, k8sclient, tektonclient, tc.requester, &tc.pipelinerun, tc.policies)

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

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

Expand Down Expand Up @@ -1193,7 +1191,7 @@ func TestGetPipelineFunc_V1Pipeline_VerifyError(t *testing.T) {
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
ctx := test.SetupTrustedResourceConfig(context.Background(), tc.verificationNoMatchPolicy)
pr := &v1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
Spec: v1.PipelineRunSpec{
Expand All @@ -1215,7 +1213,6 @@ func TestGetPipelineFunc_V1Pipeline_VerifyError(t *testing.T) {
}

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

Expand Down Expand Up @@ -1259,6 +1256,7 @@ func TestGetPipelineFunc_GetFuncError(t *testing.T) {
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
ctx := context.Background()
store := config.NewStore(logging.FromContext(ctx).Named("config-store"))
featureflags := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand Down
10 changes: 5 additions & 5 deletions pkg/reconciler/taskrun/resources/taskref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ func TestGetTaskFunc_V1beta1Task_VerifyNoError(t *testing.T) {
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
ctx := test.SetupTrustedResourceConfig(context.Background(), tc.verificationNoMatchPolicy)
tr := &v1.TaskRun{
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
Spec: v1.TaskRunSpec{
Expand Down Expand Up @@ -1558,7 +1558,7 @@ func TestGetTaskFunc_V1beta1Task_VerifyError(t *testing.T) {
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
ctx := test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
tr := &v1.TaskRun{
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
Spec: v1.TaskRunSpec{
Expand Down Expand Up @@ -1694,7 +1694,7 @@ func TestGetTaskFunc_V1Task_VerifyNoError(t *testing.T) {
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
ctx := test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
tr := &v1.TaskRun{
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
Spec: v1.TaskRunSpec{
Expand Down Expand Up @@ -1820,7 +1820,7 @@ func TestGetTaskFunc_V1Task_VerifyError(t *testing.T) {
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
ctx = test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
ctx := test.SetupTrustedResourceConfig(ctx, tc.verificationNoMatchPolicy)
tr := &v1.TaskRun{
ObjectMeta: metav1.ObjectMeta{Namespace: "trusted-resources"},
Spec: v1.TaskRunSpec{
Expand Down Expand Up @@ -1892,7 +1892,7 @@ func TestGetTaskFunc_GetFuncError(t *testing.T) {
},
}
store.OnConfigChanged(featureflags)
ctx = store.ToContext(ctx)
ctx := store.ToContext(ctx)

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

Expand Down

0 comments on commit 676c48a

Please sign in to comment.