Skip to content

Commit 5aa85ad

Browse files
(Follow up of : kubernetes-sigs#4752 - Upgrade GolangCI) - fix staticcheck linter issues in the scaffolds and tutorials
Co-Author: dongjiang <[email protected]>
1 parent 8876c45 commit 5aa85ad

File tree

22 files changed

+20
-62
lines changed

22 files changed

+20
-62
lines changed

docs/book/src/cronjob-tutorial/testdata/project/.golangci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ linters:
3939
- linters:
4040
- staticcheck
4141
text: "ST1019"
42-
- linters:
43-
- staticcheck
44-
text: "ST1005"
45-
- linters:
46-
- staticcheck
47-
text: "QF1008"
4842
paths:
4943
- third_party$
5044
- builtin$

docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func (r *CronJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
354354
if cronJob.Status.LastScheduleTime != nil {
355355
earliestTime = cronJob.Status.LastScheduleTime.Time
356356
} else {
357-
earliestTime = cronJob.ObjectMeta.CreationTimestamp.Time
357+
earliestTime = cronJob.CreationTimestamp.Time
358358
}
359359
if cronJob.Spec.StartingDeadlineSeconds != nil {
360360
// controller is not going to schedule anything below this point

docs/book/src/cronjob-tutorial/testdata/project/internal/webhook/v1/cronjob_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,14 @@ the validation schema.
265265
*/
266266

267267
func validateCronJobName(cronjob *batchv1.CronJob) *field.Error {
268-
if len(cronjob.ObjectMeta.Name) > validationutils.DNS1035LabelMaxLength-11 {
268+
if len(cronjob.Name) > validationutils.DNS1035LabelMaxLength-11 {
269269
// The job name length is 63 characters like all Kubernetes objects
270270
// (which must fit in a DNS subdomain). The cronjob controller appends
271271
// a 11-character suffix to the cronjob (`-$TIMESTAMP`) when creating
272272
// a job. The job name length limit is 63 characters. Therefore cronjob
273273
// names must have length <= 63-11=52. If we don't validate this here,
274274
// then job creation will fail later.
275-
return field.Invalid(field.NewPath("metadata").Child("name"), cronjob.ObjectMeta.Name, "must be no more than 52 characters")
275+
return field.Invalid(field.NewPath("metadata").Child("name"), cronjob.Name, "must be no more than 52 characters")
276276
}
277277
return nil
278278
}

docs/book/src/cronjob-tutorial/testdata/project/test/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"os/exec"
2525
"strings"
2626

27-
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive,staticcheck
27+
. "github.com/onsi/ginkgo/v2" // revive,staticcheck
2828
)
2929

3030
const (

docs/book/src/getting-started/testdata/project/.golangci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ linters:
3939
- linters:
4040
- staticcheck
4141
text: "ST1019"
42-
- linters:
43-
- staticcheck
44-
text: "ST1005"
45-
- linters:
46-
- staticcheck
47-
text: "QF1008"
4842
paths:
4943
- third_party$
5044
- builtin$

docs/book/src/getting-started/testdata/project/test/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"os/exec"
2525
"strings"
2626

27-
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive,staticcheck
27+
. "github.com/onsi/ginkgo/v2" // revive,staticcheck
2828
)
2929

3030
const (

docs/book/src/multiversion-tutorial/testdata/project/.golangci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ linters:
3939
- linters:
4040
- staticcheck
4141
text: "ST1019"
42-
- linters:
43-
- staticcheck
44-
text: "ST1005"
45-
- linters:
46-
- staticcheck
47-
text: "QF1008"
4842
paths:
4943
- third_party$
5044
- builtin$

docs/book/src/multiversion-tutorial/testdata/project/internal/controller/cronjob_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func (r *CronJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
354354
if cronJob.Status.LastScheduleTime != nil {
355355
earliestTime = cronJob.Status.LastScheduleTime.Time
356356
} else {
357-
earliestTime = cronJob.ObjectMeta.CreationTimestamp.Time
357+
earliestTime = cronJob.CreationTimestamp.Time
358358
}
359359
if cronJob.Spec.StartingDeadlineSeconds != nil {
360360
// controller is not going to schedule anything below this point

docs/book/src/multiversion-tutorial/testdata/project/internal/webhook/v1/cronjob_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,14 @@ the validation schema.
270270
*/
271271

272272
func validateCronJobName(cronjob *batchv1.CronJob) *field.Error {
273-
if len(cronjob.ObjectMeta.Name) > validationutils.DNS1035LabelMaxLength-11 {
273+
if len(cronjob.Name) > validationutils.DNS1035LabelMaxLength-11 {
274274
// The job name length is 63 characters like all Kubernetes objects
275275
// (which must fit in a DNS subdomain). The cronjob controller appends
276276
// a 11-character suffix to the cronjob (`-$TIMESTAMP`) when creating
277277
// a job. The job name length limit is 63 characters. Therefore cronjob
278278
// names must have length <= 63-11=52. If we don't validate this here,
279279
// then job creation will fail later.
280-
return field.Invalid(field.NewPath("metadata").Child("name"), cronjob.ObjectMeta.Name, "must be no more than 52 characters")
280+
return field.Invalid(field.NewPath("metadata").Child("name"), cronjob.Name, "must be no more than 52 characters")
281281
}
282282
return nil
283283
}

docs/book/src/multiversion-tutorial/testdata/project/internal/webhook/v2/cronjob_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ func validateCronJob(cronjob *batchv2.CronJob) error {
173173
}
174174

175175
func validateCronJobName(cronjob *batchv2.CronJob) *field.Error {
176-
if len(cronjob.ObjectMeta.Name) > validationutils.DNS1035LabelMaxLength-11 {
177-
return field.Invalid(field.NewPath("metadata").Child("name"), cronjob.ObjectMeta.Name, "must be no more than 52 characters")
176+
if len(cronjob.Name) > validationutils.DNS1035LabelMaxLength-11 {
177+
return field.Invalid(field.NewPath("metadata").Child("name"), cronjob.Name, "must be no more than 52 characters")
178178
}
179179
return nil
180180
}

docs/book/src/multiversion-tutorial/testdata/project/test/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"os/exec"
2525
"strings"
2626

27-
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive,staticcheck
27+
. "github.com/onsi/ginkgo/v2" // revive,staticcheck
2828
)
2929

3030
const (

hack/docs/internal/cronjob-tutorial/controller_implementation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ const controllerReconcileLogic = `log := logf.FromContext(ctx)
343343
if cronJob.Status.LastScheduleTime != nil {
344344
earliestTime = cronJob.Status.LastScheduleTime.Time
345345
} else {
346-
earliestTime = cronJob.ObjectMeta.CreationTimestamp.Time
346+
earliestTime = cronJob.CreationTimestamp.Time
347347
}
348348
if cronJob.Spec.StartingDeadlineSeconds != nil {
349349
// controller is not going to schedule anything below this point

hack/docs/internal/cronjob-tutorial/webhook_implementation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ the validation schema.
164164
*/
165165
166166
func validateCronJobName(cronjob *batchv1.CronJob) *field.Error {
167-
if len(cronjob.ObjectMeta.Name) > validationutils.DNS1035LabelMaxLength-11 {
167+
if len(cronjob.Name) > validationutils.DNS1035LabelMaxLength-11 {
168168
// The job name length is 63 characters like all Kubernetes objects
169169
// (which must fit in a DNS subdomain). The cronjob controller appends
170170
// a 11-character suffix to the cronjob (` + "`" + `-$TIMESTAMP` + "`" + `) when creating
171171
// a job. The job name length limit is 63 characters. Therefore cronjob
172172
// names must have length <= 63-11=52. If we don't validate this here,
173173
// then job creation will fail later.
174-
return field.Invalid(field.NewPath("metadata").Child("name"), cronjob.ObjectMeta.Name, "must be no more than 52 characters")
174+
return field.Invalid(field.NewPath("metadata").Child("name"), cronjob.Name, "must be no more than 52 characters")
175175
}
176176
return nil
177177
}

hack/docs/internal/multiversion-tutorial/webhook_v2_implementaton.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ func validateCronJob(cronjob *batchv2.CronJob) error {
6666
}
6767
6868
func validateCronJobName(cronjob *batchv2.CronJob) *field.Error {
69-
if len(cronjob.ObjectMeta.Name) > validationutils.DNS1035LabelMaxLength-11 {
70-
return field.Invalid(field.NewPath("metadata").Child("name"), cronjob.ObjectMeta.Name, "must be no more than 52 characters")
69+
if len(cronjob.Name) > validationutils.DNS1035LabelMaxLength-11 {
70+
return field.Invalid(field.NewPath("metadata").Child("name"), cronjob.Name, "must be no more than 52 characters")
7171
}
7272
return nil
7373
}

pkg/plugins/golang/v4/scaffolds/internal/templates/golangci.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ linters:
8282
- linters:
8383
- staticcheck
8484
text: "ST1019"
85-
- linters:
86-
- staticcheck
87-
text: "ST1005"
88-
- linters:
89-
- staticcheck
90-
text: "QF1008"
9185
paths:
9286
- third_party$
9387
- builtin$

pkg/plugins/golang/v4/scaffolds/internal/templates/test/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import (
5252
"os/exec"
5353
"strings"
5454
55-
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive,staticcheck
55+
. "github.com/onsi/ginkgo/v2" // revive,staticcheck
5656
)
5757
5858
const (

testdata/project-v4-multigroup/.golangci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ linters:
3939
- linters:
4040
- staticcheck
4141
text: "ST1019"
42-
- linters:
43-
- staticcheck
44-
text: "ST1005"
45-
- linters:
46-
- staticcheck
47-
text: "QF1008"
4842
paths:
4943
- third_party$
5044
- builtin$

testdata/project-v4-multigroup/test/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"os/exec"
2525
"strings"
2626

27-
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive,staticcheck
27+
. "github.com/onsi/ginkgo/v2" // revive,staticcheck
2828
)
2929

3030
const (

testdata/project-v4-with-plugins/.golangci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ linters:
3939
- linters:
4040
- staticcheck
4141
text: "ST1019"
42-
- linters:
43-
- staticcheck
44-
text: "ST1005"
45-
- linters:
46-
- staticcheck
47-
text: "QF1008"
4842
paths:
4943
- third_party$
5044
- builtin$

testdata/project-v4-with-plugins/test/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"os/exec"
2525
"strings"
2626

27-
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive,staticcheck
27+
. "github.com/onsi/ginkgo/v2" // revive,staticcheck
2828
)
2929

3030
const (

testdata/project-v4/.golangci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ linters:
3939
- linters:
4040
- staticcheck
4141
text: "ST1019"
42-
- linters:
43-
- staticcheck
44-
text: "ST1005"
45-
- linters:
46-
- staticcheck
47-
text: "QF1008"
4842
paths:
4943
- third_party$
5044
- builtin$

testdata/project-v4/test/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"os/exec"
2525
"strings"
2626

27-
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive,staticcheck
27+
. "github.com/onsi/ginkgo/v2" // revive,staticcheck
2828
)
2929

3030
const (

0 commit comments

Comments
 (0)