diff --git a/.golangci.yml b/.golangci.yml index a9b8c88c..93bcf414 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ run: timeout: 30m - go: '1.19' + go: '1.21' skip-files: - "^zz_generated.*" @@ -30,5 +30,13 @@ linters-settings: "-SA2002" ] + revive: + rules: + - name: unused-parameter + severity: warning + disabled: false + arguments: + - allowRegex: "^_" + unused: go: "1.19" diff --git a/Makefile b/Makefile index 2b901fd9..5221ac72 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,7 @@ license-eye: ## Download license-eye locally if necessary GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint golangci-lint: - $(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.1) + $(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2) # go-get-tool will 'go get' any package $2 and install it to $1. PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/pkg/controllers/common/selector.go b/pkg/controllers/common/selector.go index ae890d27..67e0e403 100644 --- a/pkg/controllers/common/selector.go +++ b/pkg/controllers/common/selector.go @@ -41,7 +41,7 @@ func MustAsSelector(ps *metav1.LabelSelector) labels.Selector { return ls } -func MustNewRequirement(key string, op selection.Operator, vals []string, opts ...field.PathOption) labels.Requirement { +func MustNewRequirement(key string, op selection.Operator, vals []string, _ ...field.PathOption) labels.Requirement { r, err := labels.NewRequirement(key, op, vals) if err != nil { panic(errors.Wrap(err, "impossible path: new requirement failed")) diff --git a/pkg/controllers/common/template.go b/pkg/controllers/common/template.go index 2f777181..dd299809 100644 --- a/pkg/controllers/common/template.go +++ b/pkg/controllers/common/template.go @@ -162,7 +162,7 @@ func DeploymentTemplate(obj client.Object, name string) *appsv1.Deployment { func PersistentVolumeClaimTemplate(size resource.Quantity, sc *string, name string) corev1.PersistentVolumeClaim { return corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ - Name: DataVolume, + Name: name, }, Spec: corev1.PersistentVolumeClaimSpec{ AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}, diff --git a/pkg/hook/cnclaim.go b/pkg/hook/cnclaim.go index e99935ce..c974042e 100644 --- a/pkg/hook/cnclaim.go +++ b/pkg/hook/cnclaim.go @@ -39,11 +39,11 @@ func NewCNClaimHook(cli client.Client, logger logr.Logger) *CNClaimHook { } } -func (h *CNClaimHook) ValidateCreate(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) { +func (h *CNClaimHook) ValidateCreate(_ context.Context, _ runtime.Object) (warnings admission.Warnings, err error) { return nil, nil } -func (h *CNClaimHook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (warnings admission.Warnings, err error) { +func (h *CNClaimHook) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (warnings admission.Warnings, err error) { var errs field.ErrorList oldClaim, ok := oldObj.(*v1alpha1.CNClaim) if !ok { @@ -59,7 +59,7 @@ func (h *CNClaimHook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime return nil, invalidOrNil(errs, newClaim) } -func (h *CNClaimHook) ValidateDelete(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) { +func (h *CNClaimHook) ValidateDelete(_ context.Context, _ runtime.Object) (warnings admission.Warnings, err error) { return nil, nil } diff --git a/pkg/hook/cnclaimset.go b/pkg/hook/cnclaimset.go index dca2a28c..00b9d928 100644 --- a/pkg/hook/cnclaimset.go +++ b/pkg/hook/cnclaimset.go @@ -37,15 +37,15 @@ func NewCNClaimSetHook(cli client.Client, logger logr.Logger) *CNClaimSetHook { } } -func (h *CNClaimSetHook) Default(ctx context.Context, obj runtime.Object) error { +func (h *CNClaimSetHook) Default(_ context.Context, _ runtime.Object) error { return nil } -func (h *CNClaimSetHook) ValidateCreate(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) { +func (h *CNClaimSetHook) ValidateCreate(_ context.Context, _ runtime.Object) (warnings admission.Warnings, err error) { return nil, nil } -func (h *CNClaimSetHook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (warnings admission.Warnings, err error) { +func (h *CNClaimSetHook) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (warnings admission.Warnings, err error) { oldCS, ok := oldObj.(*v1alpha1.CNClaimSet) if !ok { return nil, nil @@ -62,7 +62,7 @@ func (h *CNClaimSetHook) ValidateUpdate(ctx context.Context, oldObj, newObj runt return nil, nil } -func (h *CNClaimSetHook) ValidateDelete(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) { +func (h *CNClaimSetHook) ValidateDelete(_ context.Context, _ runtime.Object) (warnings admission.Warnings, err error) { return nil, nil } diff --git a/pkg/mosql/fake.go b/pkg/mosql/fake.go index 0bdc36d6..1e61dba1 100644 --- a/pkg/mosql/fake.go +++ b/pkg/mosql/fake.go @@ -27,10 +27,10 @@ func NewFakeClient(_ string, _ client.Client, _ types.NamespacedName) Client { type fakeClient struct{} -func (c *fakeClient) GetServerConnection(ctx context.Context, uid string) (int, error) { +func (c *fakeClient) GetServerConnection(_ context.Context, _ string) (int, error) { return 0, nil } -func (c *fakeClient) Query(ctx context.Context, query string, args ...any) (*sql.Rows, error) { +func (c *fakeClient) Query(_ context.Context, _ string, _ ...any) (*sql.Rows, error) { return nil, nil }