From f47f6ad3ec5da688345dafbc9121133cfd93f208 Mon Sep 17 00:00:00 2001 From: Dario Tranchitella Date: Sun, 1 Dec 2024 15:48:32 +0100 Subject: [PATCH] chore(golangci-lint): bumping up to v1.62.2 Signed-off-by: Dario Tranchitella --- .github/workflows/ci.yaml | 2 +- .golangci.yml | 23 +++++++++---------- Makefile | 2 +- api/v1alpha1/suite_test.go | 1 + api/v1alpha1/tenantcontrolplane_interfaces.go | 2 +- .../tenantcontrolplane_kubeadmphase_funcs.go | 2 +- api/v1alpha1/tenantcontrolplane_types_test.go | 2 +- cmd/manager/cmd.go | 4 ++-- cmd/migrate/cmd.go | 2 +- cmd/root.go | 2 +- controllers/datastore_controller.go | 2 +- controllers/soot/manager.go | 2 +- e2e/tcp_additional_resources_ready_test.go | 1 + .../datastore_storage_config_test.go | 2 +- .../konnectivity/service_resource.go | 4 ++-- internal/resources/kubeadm_phases.go | 2 +- internal/resources/resource.go | 22 +++++++++--------- internal/webhook/handlers/ds_secrets.go | 2 +- internal/webhook/handlers/ds_validate.go | 6 ++--- internal/webhook/handlers/handler.go | 4 ++-- internal/webhook/handlers/tcp_datastore.go | 4 ++-- internal/webhook/handlers/tcp_defaults.go | 2 +- .../webhook/handlers/tcp_defaults_test.go | 2 +- internal/webhook/handlers/tcp_deployment.go | 2 +- .../webhook/handlers/tcp_kubeletaddresses.go | 4 ++-- .../webhook/handlers/tcp_lb_src_ranges.go | 2 +- .../handlers/tcp_lb_src_ranges_test.go | 2 +- internal/webhook/handlers/tcp_name.go | 2 +- internal/webhook/handlers/tcp_service_cidr.go | 2 +- internal/webhook/handlers/tcp_version.go | 4 ++-- 30 files changed, 58 insertions(+), 57 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1f08dc1c..e05f1691 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: - name: Run golangci-lint uses: golangci/golangci-lint-action@v6.1.1 with: - version: v1.54.2 + version: v1.62.2 only-new-issues: false args: --timeout 5m --config .golangci.yml diff: diff --git a/.golangci.yml b/.golangci.yml index 08ae0c5c..1034f256 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,4 +1,11 @@ linters-settings: + revive: + rules: + - name: dot-imports + arguments: + - allowedPackages: + - "github.com/onsi/ginkgo/v2" + - "github.com/onsi/gomega" gci: sections: - standard @@ -13,16 +20,14 @@ linters: disable: - depguard - wrapcheck - - gomnd - - scopelint + - mnd - varnamelen - testpackage - tagliatelle - paralleltest - ireturn - - goerr113 + - err113 - gochecknoglobals - - exhaustivestruct - wsl - exhaustive - nosprintfhostport @@ -39,13 +44,7 @@ linters: - cyclop - gocognit - nestif + - perfsprint # deprecated linters - - deadcode - - golint - - interfacer - - structcheck - - varcheck - - nosnakecase - - ifshort - - maligned + - exportloopref enable-all: true diff --git a/Makefile b/Makefile index ccb78e76..c1c58f47 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,7 @@ $(CONTROLLER_GEN): $(LOCALBIN) .PHONY: golangci-lint golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. $(GOLANGCI_LINT): $(LOCALBIN) - test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2 + test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2 .PHONY: apidocs-gen apidocs-gen: $(APIDOCS_GEN) ## Download crdoc locally if necessary. diff --git a/api/v1alpha1/suite_test.go b/api/v1alpha1/suite_test.go index 34f19b9d..b882a0c4 100644 --- a/api/v1alpha1/suite_test.go +++ b/api/v1alpha1/suite_test.go @@ -1,5 +1,6 @@ // Copyright 2022 Clastix Labs // SPDX-License-Identifier: Apache-2.0 + package v1alpha1 import ( diff --git a/api/v1alpha1/tenantcontrolplane_interfaces.go b/api/v1alpha1/tenantcontrolplane_interfaces.go index e70b5505..e5f250c3 100644 --- a/api/v1alpha1/tenantcontrolplane_interfaces.go +++ b/api/v1alpha1/tenantcontrolplane_interfaces.go @@ -8,5 +8,5 @@ package v1alpha1 // +kubebuilder:object:generate=false type KubeadmConfigChecksumDependant interface { GetChecksum() string - SetChecksum(string) + SetChecksum(checksum string) } diff --git a/api/v1alpha1/tenantcontrolplane_kubeadmphase_funcs.go b/api/v1alpha1/tenantcontrolplane_kubeadmphase_funcs.go index f12d35d6..3fa764af 100644 --- a/api/v1alpha1/tenantcontrolplane_kubeadmphase_funcs.go +++ b/api/v1alpha1/tenantcontrolplane_kubeadmphase_funcs.go @@ -7,7 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func (in KubeadmPhaseStatus) GetChecksum() string { +func (in *KubeadmPhaseStatus) GetChecksum() string { return in.Checksum } diff --git a/api/v1alpha1/tenantcontrolplane_types_test.go b/api/v1alpha1/tenantcontrolplane_types_test.go index e48f75d4..2f6b83fc 100644 --- a/api/v1alpha1/tenantcontrolplane_types_test.go +++ b/api/v1alpha1/tenantcontrolplane_types_test.go @@ -19,7 +19,7 @@ var _ = Describe("Cluster controller", func() { ) BeforeEach(func() { - ctx = context.Background() + ctx = context.Background() //nolint:fatcontext tcp = &TenantControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "tcp", diff --git a/cmd/manager/cmd.go b/cmd/manager/cmd.go index be55973a..0df03a65 100644 --- a/cmd/manager/cmd.go +++ b/cmd/manager/cmd.go @@ -68,7 +68,7 @@ func NewCmd(scheme *runtime.Scheme) *cobra.Command { Short: "Start the Kamaji Kubernetes Operator", SilenceErrors: false, SilenceUsage: true, - PreRunE: func(cmd *cobra.Command, args []string) (err error) { + PreRunE: func(cmd *cobra.Command, _ []string) (err error) { // Avoid to pollute Kamaji stdout with useless details by the underlying klog implementations klog.SetOutput(io.Discard) klog.LogToStderr(false) @@ -95,7 +95,7 @@ func NewCmd(scheme *runtime.Scheme) *cobra.Command { return nil }, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(*cobra.Command, []string) error { setupLog := ctrl.Log.WithName("setup") setupLog.Info(fmt.Sprintf("Kamaji version %s %s%s", internal.GitTag, internal.GitCommit, internal.GitDirty)) diff --git a/cmd/migrate/cmd.go b/cmd/migrate/cmd.go index 1999fbf3..a508b8a0 100644 --- a/cmd/migrate/cmd.go +++ b/cmd/migrate/cmd.go @@ -31,7 +31,7 @@ func NewCmd(scheme *runtime.Scheme) *cobra.Command { Use: "migrate", Short: "Migrate the data of a TenantControlPlane to another compatible DataStore", SilenceUsage: true, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(*cobra.Command, []string) error { ctx, cancelFn := context.WithTimeout(context.Background(), timeout) defer cancelFn() diff --git a/cmd/root.go b/cmd/root.go index d137a0c7..e24e1ee3 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -18,7 +18,7 @@ func NewCmd(scheme *runtime.Scheme) *cobra.Command { return &cobra.Command{ Use: "kamaji", Short: "Build and operate Kubernetes at scale with a fraction of operational burden.", - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(*cobra.Command, []string) { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(kamajiv1alpha1.AddToScheme(scheme)) utilruntime.Must(appsv1.RegisterDefaults(scheme)) diff --git a/controllers/datastore_controller.go b/controllers/datastore_controller.go index 835ffb5d..95bd66ad 100644 --- a/controllers/datastore_controller.go +++ b/controllers/datastore_controller.go @@ -101,7 +101,7 @@ func (r *DataStore) SetupWithManager(mgr controllerruntime.Manager) error { CreateFunc: func(_ context.Context, createEvent event.TypedCreateEvent[client.Object], w workqueue.TypedRateLimitingInterface[reconcile.Request]) { enqueueFn(createEvent.Object.(*kamajiv1alpha1.TenantControlPlane), w) }, - UpdateFunc: func(ctx context.Context, updateEvent event.TypedUpdateEvent[client.Object], w workqueue.TypedRateLimitingInterface[reconcile.Request]) { + UpdateFunc: func(_ context.Context, updateEvent event.TypedUpdateEvent[client.Object], w workqueue.TypedRateLimitingInterface[reconcile.Request]) { enqueueFn(updateEvent.ObjectOld.(*kamajiv1alpha1.TenantControlPlane), w) enqueueFn(updateEvent.ObjectNew.(*kamajiv1alpha1.TenantControlPlane), w) }, diff --git a/controllers/soot/manager.go b/controllers/soot/manager.go index 971e4bae..e4576979 100644 --- a/controllers/soot/manager.go +++ b/controllers/soot/manager.go @@ -182,7 +182,7 @@ func (m *Manager) Reconcile(ctx context.Context, request reconcile.Request) (res Metrics: metricsserver.Options{ BindAddress: "0", }, - NewClient: func(config *rest.Config, options client.Options) (client.Client, error) { + NewClient: func(config *rest.Config, _ client.Options) (client.Client, error) { return client.New(config, client.Options{ Scheme: m.client.Scheme(), }) diff --git a/e2e/tcp_additional_resources_ready_test.go b/e2e/tcp_additional_resources_ready_test.go index e836324b..774001b0 100644 --- a/e2e/tcp_additional_resources_ready_test.go +++ b/e2e/tcp_additional_resources_ready_test.go @@ -1,6 +1,7 @@ // Copyright 2022 Clastix Labs // SPDX-License-Identifier: Apache-2.0 +//nolint:ginkgolinter package e2e import ( diff --git a/internal/resources/datastore/datastore_storage_config_test.go b/internal/resources/datastore/datastore_storage_config_test.go index 84754c08..266839fd 100644 --- a/internal/resources/datastore/datastore_storage_config_test.go +++ b/internal/resources/datastore/datastore_storage_config_test.go @@ -28,7 +28,7 @@ var _ = Describe("DatastoreStorageConfig", func() { ) BeforeEach(func() { - ctx = context.Background() + ctx = context.Background() //nolint:fatcontext tcp = &kamajiv1alpha1.TenantControlPlane{ ObjectMeta: metav1.ObjectMeta{ diff --git a/internal/resources/konnectivity/service_resource.go b/internal/resources/konnectivity/service_resource.go index e5fefecb..390d171e 100644 --- a/internal/resources/konnectivity/service_resource.go +++ b/internal/resources/konnectivity/service_resource.go @@ -46,7 +46,7 @@ func (r *ServiceResource) ShouldStatusBeUpdated(_ context.Context, tenantControl return true } - for i := 0; i < len(resourceIngresses); i++ { + for i := range resourceIngresses { if resourceIngresses[i].Hostname != statusIngresses[i].Hostname || resourceIngresses[i].IP != statusIngresses[i].IP || len(resourceIngresses[i].Ports) != len(statusIngresses[i].Ports) { @@ -55,7 +55,7 @@ func (r *ServiceResource) ShouldStatusBeUpdated(_ context.Context, tenantControl resourcePorts := resourceIngresses[i].Ports statusPorts := statusIngresses[i].Ports - for j := 0; j < len(resourcePorts); j++ { + for j := range resourcePorts { if resourcePorts[j].Port != statusPorts[j].Port || resourcePorts[j].Protocol != statusPorts[j].Protocol { return true diff --git a/internal/resources/kubeadm_phases.go b/internal/resources/kubeadm_phases.go index caa7d7e8..2de4d970 100644 --- a/internal/resources/kubeadm_phases.go +++ b/internal/resources/kubeadm_phases.go @@ -229,7 +229,7 @@ func (r *KubeadmPhase) UpdateTenantControlPlaneStatus(ctx context.Context, tenan func (r *KubeadmPhase) GetStatus(tenantControlPlane *kamajiv1alpha1.TenantControlPlane) (kamajiv1alpha1.KubeadmConfigChecksumDependant, error) { switch r.Phase { case PhaseUploadConfigKubeadm, PhaseUploadConfigKubelet, PhaseClusterAdminRBAC: - return nil, nil + return nil, nil //nolint:nilnil case PhaseBootstrapToken: return &tenantControlPlane.Status.KubeadmPhase.BootstrapToken, nil default: diff --git a/internal/resources/resource.go b/internal/resources/resource.go index a8c0a004..b92ecb32 100644 --- a/internal/resources/resource.go +++ b/internal/resources/resource.go @@ -21,19 +21,19 @@ const ( ) type Resource interface { - Define(context.Context, *kamajiv1alpha1.TenantControlPlane) error - ShouldCleanup(*kamajiv1alpha1.TenantControlPlane) bool - CleanUp(context.Context, *kamajiv1alpha1.TenantControlPlane) (bool, error) - CreateOrUpdate(context.Context, *kamajiv1alpha1.TenantControlPlane) (controllerutil.OperationResult, error) + Define(ctx context.Context, tcp *kamajiv1alpha1.TenantControlPlane) error + ShouldCleanup(tcp *kamajiv1alpha1.TenantControlPlane) bool + CleanUp(ctx context.Context, tcp *kamajiv1alpha1.TenantControlPlane) (bool, error) + CreateOrUpdate(ctx context.Context, tcp *kamajiv1alpha1.TenantControlPlane) (controllerutil.OperationResult, error) GetName() string - ShouldStatusBeUpdated(context.Context, *kamajiv1alpha1.TenantControlPlane) bool - UpdateTenantControlPlaneStatus(context.Context, *kamajiv1alpha1.TenantControlPlane) error + ShouldStatusBeUpdated(ctx context.Context, tcp *kamajiv1alpha1.TenantControlPlane) bool + UpdateTenantControlPlaneStatus(ctx context.Context, tcp *kamajiv1alpha1.TenantControlPlane) error } type DeletableResource interface { GetName() string - Define(context.Context, *kamajiv1alpha1.TenantControlPlane) error - Delete(context.Context, *kamajiv1alpha1.TenantControlPlane) error + Define(ctx context.Context, tcp *kamajiv1alpha1.TenantControlPlane) error + Delete(ctx context.Context, tcp *kamajiv1alpha1.TenantControlPlane) error } type KubeadmResource interface { @@ -45,9 +45,9 @@ type KubeadmPhaseResource interface { Resource KubeadmResource GetClient() client.Client - GetKubeadmFunction(context.Context, *kamajiv1alpha1.TenantControlPlane) (func(clientset.Interface, *kubeadm.Configuration) ([]byte, error), error) - GetStatus(*kamajiv1alpha1.TenantControlPlane) (kamajiv1alpha1.KubeadmConfigChecksumDependant, error) - SetKubeadmConfigChecksum(string) + GetKubeadmFunction(ctx context.Context, tcp *kamajiv1alpha1.TenantControlPlane) (func(clientset.Interface, *kubeadm.Configuration) ([]byte, error), error) + GetStatus(tcp *kamajiv1alpha1.TenantControlPlane) (kamajiv1alpha1.KubeadmConfigChecksumDependant, error) + SetKubeadmConfigChecksum(checksum string) GetWatchedObject() client.Object GetPredicateFunc() func(obj client.Object) bool } diff --git a/internal/webhook/handlers/ds_secrets.go b/internal/webhook/handlers/ds_secrets.go index a446fe8a..c3cba4be 100644 --- a/internal/webhook/handlers/ds_secrets.go +++ b/internal/webhook/handlers/ds_secrets.go @@ -33,7 +33,7 @@ func (d DataStoreSecretValidation) OnDelete(runtime.Object) AdmissionResponse { } func (d DataStoreSecretValidation) OnUpdate(object runtime.Object, _ runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(ctx context.Context, _ admission.Request) ([]jsonpatch.JsonPatchOperation, error) { secret := object.(*corev1.Secret) //nolint:forcetypeassert dsList := &kamajiv1alpha1.DataStoreList{} diff --git a/internal/webhook/handlers/ds_validate.go b/internal/webhook/handlers/ds_validate.go index 6bd98aa6..e7d77479 100644 --- a/internal/webhook/handlers/ds_validate.go +++ b/internal/webhook/handlers/ds_validate.go @@ -25,7 +25,7 @@ type DataStoreValidation struct { } func (d DataStoreValidation) OnCreate(object runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(ctx context.Context, _ admission.Request) ([]jsonpatch.JsonPatchOperation, error) { ds := object.(*kamajiv1alpha1.DataStore) //nolint:forcetypeassert return nil, d.validate(ctx, *ds) @@ -33,7 +33,7 @@ func (d DataStoreValidation) OnCreate(object runtime.Object) AdmissionResponse { } func (d DataStoreValidation) OnDelete(object runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(ctx context.Context, _ admission.Request) ([]jsonpatch.JsonPatchOperation, error) { ds := object.(*kamajiv1alpha1.DataStore) //nolint:forcetypeassert tcpList := &kamajiv1alpha1.TenantControlPlaneList{} @@ -50,7 +50,7 @@ func (d DataStoreValidation) OnDelete(object runtime.Object) AdmissionResponse { } func (d DataStoreValidation) OnUpdate(object runtime.Object, oldObj runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(ctx context.Context, _ admission.Request) ([]jsonpatch.JsonPatchOperation, error) { newDs, oldDs := object.(*kamajiv1alpha1.DataStore), oldObj.(*kamajiv1alpha1.DataStore) //nolint:forcetypeassert if oldDs.Spec.Driver != newDs.Spec.Driver { diff --git a/internal/webhook/handlers/handler.go b/internal/webhook/handlers/handler.go index c1238e9c..c53476d8 100644 --- a/internal/webhook/handlers/handler.go +++ b/internal/webhook/handlers/handler.go @@ -14,7 +14,7 @@ import ( type AdmissionResponse func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) type Handler interface { - OnCreate(runtime.Object) AdmissionResponse - OnDelete(runtime.Object) AdmissionResponse + OnCreate(obj runtime.Object) AdmissionResponse + OnDelete(obj runtime.Object) AdmissionResponse OnUpdate(newObject runtime.Object, prevObject runtime.Object) AdmissionResponse } diff --git a/internal/webhook/handlers/tcp_datastore.go b/internal/webhook/handlers/tcp_datastore.go index 8708326c..c049bdb6 100644 --- a/internal/webhook/handlers/tcp_datastore.go +++ b/internal/webhook/handlers/tcp_datastore.go @@ -23,7 +23,7 @@ type TenantControlPlaneDataStore struct { } func (t TenantControlPlaneDataStore) OnCreate(object runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(ctx context.Context, _ admission.Request) ([]jsonpatch.JsonPatchOperation, error) { tcp := object.(*kamajiv1alpha1.TenantControlPlane) //nolint:forcetypeassert if tcp.Spec.DataStore != "" { @@ -39,7 +39,7 @@ func (t TenantControlPlaneDataStore) OnDelete(runtime.Object) AdmissionResponse } func (t TenantControlPlaneDataStore) OnUpdate(object runtime.Object, _ runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(ctx context.Context, _ admission.Request) ([]jsonpatch.JsonPatchOperation, error) { tcp := object.(*kamajiv1alpha1.TenantControlPlane) //nolint:forcetypeassert if tcp.Spec.DataStore != "" { diff --git a/internal/webhook/handlers/tcp_defaults.go b/internal/webhook/handlers/tcp_defaults.go index 3ac329fc..5d71f1e4 100644 --- a/internal/webhook/handlers/tcp_defaults.go +++ b/internal/webhook/handlers/tcp_defaults.go @@ -24,7 +24,7 @@ type TenantControlPlaneDefaults struct { } func (t TenantControlPlaneDefaults) OnCreate(object runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(context.Context, admission.Request) ([]jsonpatch.JsonPatchOperation, error) { original := object.(*kamajiv1alpha1.TenantControlPlane) //nolint:forcetypeassert defaulted := original.DeepCopy() diff --git a/internal/webhook/handlers/tcp_defaults_test.go b/internal/webhook/handlers/tcp_defaults_test.go index 4bc62e0c..5a37e53a 100644 --- a/internal/webhook/handlers/tcp_defaults_test.go +++ b/internal/webhook/handlers/tcp_defaults_test.go @@ -35,7 +35,7 @@ var _ = Describe("TCP Defaulting Webhook", func() { }, Spec: kamajiv1alpha1.TenantControlPlaneSpec{}, } - ctx = context.Background() + ctx = context.Background() //nolint:fatcontext }) Describe("fields missing", func() { diff --git a/internal/webhook/handlers/tcp_deployment.go b/internal/webhook/handlers/tcp_deployment.go index 3a460c18..bca7016c 100644 --- a/internal/webhook/handlers/tcp_deployment.go +++ b/internal/webhook/handlers/tcp_deployment.go @@ -54,7 +54,7 @@ func (t TenantControlPlaneDeployment) shouldTriggerCheck(newTCP, oldTCP kamajiv1 } func (t TenantControlPlaneDeployment) OnUpdate(newObject runtime.Object, oldObject runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(ctx context.Context, _ admission.Request) ([]jsonpatch.JsonPatchOperation, error) { tcp, previousTCP := newObject.(*kamajiv1alpha1.TenantControlPlane), oldObject.(*kamajiv1alpha1.TenantControlPlane) //nolint:forcetypeassert if !t.shouldTriggerCheck(*tcp, *previousTCP) { diff --git a/internal/webhook/handlers/tcp_kubeletaddresses.go b/internal/webhook/handlers/tcp_kubeletaddresses.go index 4445d123..a0f03a63 100644 --- a/internal/webhook/handlers/tcp_kubeletaddresses.go +++ b/internal/webhook/handlers/tcp_kubeletaddresses.go @@ -19,7 +19,7 @@ import ( type TenantControlPlaneKubeletAddresses struct{} func (t TenantControlPlaneKubeletAddresses) OnCreate(object runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(context.Context, admission.Request) ([]jsonpatch.JsonPatchOperation, error) { tcp := object.(*kamajiv1alpha1.TenantControlPlane) //nolint:forcetypeassert return nil, t.validatePreferredKubeletAddressTypes(tcp.Spec.Kubernetes.Kubelet.PreferredAddressTypes) @@ -31,7 +31,7 @@ func (t TenantControlPlaneKubeletAddresses) OnDelete(runtime.Object) AdmissionRe } func (t TenantControlPlaneKubeletAddresses) OnUpdate(object runtime.Object, _ runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(context.Context, admission.Request) ([]jsonpatch.JsonPatchOperation, error) { tcp := object.(*kamajiv1alpha1.TenantControlPlane) //nolint:forcetypeassert return nil, t.validatePreferredKubeletAddressTypes(tcp.Spec.Kubernetes.Kubelet.PreferredAddressTypes) diff --git a/internal/webhook/handlers/tcp_lb_src_ranges.go b/internal/webhook/handlers/tcp_lb_src_ranges.go index ce698be3..c0e03ff1 100644 --- a/internal/webhook/handlers/tcp_lb_src_ranges.go +++ b/internal/webhook/handlers/tcp_lb_src_ranges.go @@ -46,7 +46,7 @@ func (t TenantControlPlaneLoadBalancerSourceRanges) OnDelete(runtime.Object) Adm } func (t TenantControlPlaneLoadBalancerSourceRanges) OnUpdate(object runtime.Object, _ runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(context.Context, admission.Request) ([]jsonpatch.JsonPatchOperation, error) { tcp := object.(*kamajiv1alpha1.TenantControlPlane) //nolint:forcetypeassert if err := t.handle(tcp); err != nil { diff --git a/internal/webhook/handlers/tcp_lb_src_ranges_test.go b/internal/webhook/handlers/tcp_lb_src_ranges_test.go index 7c86d364..4c4d6750 100644 --- a/internal/webhook/handlers/tcp_lb_src_ranges_test.go +++ b/internal/webhook/handlers/tcp_lb_src_ranges_test.go @@ -31,7 +31,7 @@ var _ = Describe("TCP LoadBalancer Source Ranges Webhook", func() { }, Spec: kamajiv1alpha1.TenantControlPlaneSpec{}, } - ctx = context.Background() + ctx = context.Background() //nolint:fatcontext }) It("allows creation when valid CIDR ranges are provided", func() { diff --git a/internal/webhook/handlers/tcp_name.go b/internal/webhook/handlers/tcp_name.go index 2660f0f4..1752663e 100644 --- a/internal/webhook/handlers/tcp_name.go +++ b/internal/webhook/handlers/tcp_name.go @@ -20,7 +20,7 @@ import ( type TenantControlPlaneName struct{} func (t TenantControlPlaneName) OnCreate(object runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(context.Context, admission.Request) ([]jsonpatch.JsonPatchOperation, error) { tcp := object.(*kamajiv1alpha1.TenantControlPlane) //nolint:forcetypeassert if errs := validation.IsDNS1035Label(tcp.Name); len(errs) > 0 { diff --git a/internal/webhook/handlers/tcp_service_cidr.go b/internal/webhook/handlers/tcp_service_cidr.go index e6daee37..4e19b32f 100644 --- a/internal/webhook/handlers/tcp_service_cidr.go +++ b/internal/webhook/handlers/tcp_service_cidr.go @@ -59,7 +59,7 @@ func (t TenantControlPlaneServiceCIDR) OnDelete(runtime.Object) AdmissionRespons } func (t TenantControlPlaneServiceCIDR) OnUpdate(object runtime.Object, _ runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(context.Context, admission.Request) ([]jsonpatch.JsonPatchOperation, error) { tcp := object.(*kamajiv1alpha1.TenantControlPlane) //nolint:forcetypeassert if err := t.handle(tcp); err != nil { diff --git a/internal/webhook/handlers/tcp_version.go b/internal/webhook/handlers/tcp_version.go index 11e6164f..8369611a 100644 --- a/internal/webhook/handlers/tcp_version.go +++ b/internal/webhook/handlers/tcp_version.go @@ -22,7 +22,7 @@ import ( type TenantControlPlaneVersion struct{} func (t TenantControlPlaneVersion) OnCreate(object runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(context.Context, admission.Request) ([]jsonpatch.JsonPatchOperation, error) { tcp := object.(*kamajiv1alpha1.TenantControlPlane) //nolint:forcetypeassert ver, err := semver.New(t.normalizeKubernetesVersion(tcp.Spec.Kubernetes.Version)) @@ -56,7 +56,7 @@ func (t TenantControlPlaneVersion) OnDelete(runtime.Object) AdmissionResponse { } func (t TenantControlPlaneVersion) OnUpdate(object runtime.Object, oldObject runtime.Object) AdmissionResponse { - return func(ctx context.Context, req admission.Request) ([]jsonpatch.JsonPatchOperation, error) { + return func(context.Context, admission.Request) ([]jsonpatch.JsonPatchOperation, error) { newTCP, oldTCP := object.(*kamajiv1alpha1.TenantControlPlane), oldObject.(*kamajiv1alpha1.TenantControlPlane) //nolint:forcetypeassert oldVer, oldErr := semver.Make(t.normalizeKubernetesVersion(oldTCP.Spec.Kubernetes.Version))