From acd5eb3e2db80cb0e769aa4a6e3552f890c0f1b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20B=C3=A4hler?= Date: Tue, 20 Feb 2024 15:13:21 +0100 Subject: [PATCH] chore(controller): fix linter issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Oliver Bähler --- .github/workflows/diff.yml | 2 +- .github/workflows/e2e.yml | 2 +- .github/workflows/lint.yml | 5 ++++- .golangci.yml | 21 +++++++++++++++++-- Makefile | 5 +++-- controllers/rbac/manager.go | 1 + controllers/resources/processor.go | 7 ++++++- controllers/tenant/limitranges.go | 1 + controllers/tenant/manager.go | 1 + controllers/tenant/namespaces.go | 7 +++++-- controllers/tenant/resourcequotas.go | 12 ++++++++++- controllers/tenant/rolebindings.go | 1 + controllers/tls/manager.go | 5 +++++ go.mod | 2 +- pkg/api/forbidden_list.go | 2 +- pkg/cert/ca.go | 8 +++---- pkg/webhook/defaults/handler.go | 4 ++-- pkg/webhook/ingress/errors.go | 2 +- pkg/webhook/ingress/utils.go | 1 - pkg/webhook/ingress/validate_class.go | 2 +- pkg/webhook/ingress/validate_collision.go | 2 +- pkg/webhook/ingress/validate_hostnames.go | 2 +- pkg/webhook/ingress/validate_wildcard.go | 4 ++-- pkg/webhook/namespace/patch.go | 4 ++-- pkg/webhook/namespace/prefix.go | 4 ++-- pkg/webhook/namespace/quota.go | 4 ++-- pkg/webhook/namespace/user_metadata.go | 4 ++-- pkg/webhook/node/errors.go | 2 +- pkg/webhook/node/user_metadata.go | 12 +++++------ pkg/webhook/ownerreference/patching.go | 8 +++---- pkg/webhook/pod/containerregistry.go | 2 +- pkg/webhook/pod/imagepullpolicy.go | 4 ++-- pkg/webhook/pod/priorityclass.go | 4 ++-- pkg/webhook/pod/runtimeclass.go | 4 ++-- pkg/webhook/pvc/pv.go | 2 +- pkg/webhook/pvc/validating.go | 4 ++-- pkg/webhook/service/validating.go | 2 +- pkg/webhook/tenant/containerregistry_regex.go | 6 +++--- pkg/webhook/tenant/custom_resource_quota.go | 10 ++++----- .../tenant/forbidden_annotations_regex.go | 6 +++--- pkg/webhook/tenant/freezed_emitter.go | 4 ++-- pkg/webhook/tenant/hostname_regex.go | 4 ++-- pkg/webhook/tenant/ingressclass_regex.go | 4 ++-- pkg/webhook/tenant/metadata.go | 6 +++--- pkg/webhook/tenant/name.go | 4 ++-- pkg/webhook/tenant/protected.go | 2 +- pkg/webhook/tenant/storageclass_regex.go | 4 ++-- pkg/webhook/tenantresource/objects.go | 2 +- 48 files changed, 129 insertions(+), 82 deletions(-) diff --git a/.github/workflows/diff.yml b/.github/workflows/diff.yml index 98d2b940c..cae5266f2 100644 --- a/.github/workflows/diff.yml +++ b/.github/workflows/diff.yml @@ -21,7 +21,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: '1.20' + go-version: '1.21' - run: make installer - name: Checking if YAML installer file is not aligned run: if [[ $(git diff | wc -l) -gt 0 ]]; then echo ">>> Untracked generated files have not been committed" && git --no-pager diff && exit 1; fi diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 762813702..a858f131a 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -45,7 +45,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: '1.20' + go-version: '1.21' - run: make manifests - name: Checking if manifests are disaligned run: test -z "$(git diff 2> /dev/null)" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 891354ba7..b262b9069 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,9 +17,12 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version: '1.21' - name: Run golangci-lint uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0 with: - version: v1.51.2 + version: v1.56.2 only-new-issues: false args: --timeout 5m --config .golangci.yml diff --git a/.golangci.yml b/.golangci.yml index 88e151b97..7e5849c6c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,4 @@ + linters-settings: govet: check-shadowing: true @@ -19,10 +20,21 @@ linters-settings: template: |- Copyright 2020-2023 Project Capsule Authors. SPDX-License-Identifier: Apache-2.0 - + gofumpt: + module-path: github.com/projectcapsule/capsule + extra-rules: false + inamedparam: + # Skips check for interface methods with only a single parameter. + # Default: false + skip-single-param: true + nakedret: + # Make an issue if func has more lines of code than this setting, and it has naked returns. + max-func-lines: 50 linters: enable-all: true disable: + - depguard + - perfsprint - funlen - gochecknoinits - lll @@ -48,8 +60,13 @@ linters: - nonamedreturns service: - golangci-lint-version: 1.51.2 + golangci-lint-version: 1.56.x run: + timeout: 3m + go: '1.21' skip-files: - "zz_.*\\.go$" + - ".+\\.generated.go" + - ".+_test.go" + - ".+_test_.+.go" diff --git a/Makefile b/Makefile index c31b1fc1c..26e08db27 100644 --- a/Makefile +++ b/Makefile @@ -242,7 +242,7 @@ apidocs-gen: ## Download crdoc locally if necessary. $(call go-install-tool,$(APIDOCS_GEN),fybrik.io/crdoc@$(APIDOCS_GEN_VERSION)) GINKGO := $(shell pwd)/bin/ginkgo -GINGKO_VERSION := v2.13.2 +GINGKO_VERSION := v2.15.0 ginkgo: ## Download ginkgo locally if necessary. $(call go-install-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo@$(GINGKO_VERSION)) @@ -304,8 +304,9 @@ goimports: goimports -w -l -local "github.com/projectcapsule/capsule" . GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint +GOLANGCI_LINT_VERSION = v1.56.2 golangci-lint: ## Download golangci-lint locally if necessary. - $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2) + $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)) # Linting code as PR is expecting .PHONY: golint diff --git a/controllers/rbac/manager.go b/controllers/rbac/manager.go index 3a0f62f8f..ce4319153 100644 --- a/controllers/rbac/manager.go +++ b/controllers/rbac/manager.go @@ -31,6 +31,7 @@ type Manager struct { Configuration configuration.Configuration } +//nolint:revive func (r *Manager) SetupWithManager(ctx context.Context, mgr ctrl.Manager, configurationName string) (err error) { namesPredicate := utils.NamesMatchingPredicate(ProvisionerRoleName, DeleterRoleName) diff --git a/controllers/resources/processor.go b/controllers/resources/processor.go index 244aaa28a..8efb75d66 100644 --- a/controllers/resources/processor.go +++ b/controllers/resources/processor.go @@ -264,23 +264,28 @@ func (r *Processor) createOrUpdate(ctx context.Context, obj *unstructured.Unstru _, err = controllerutil.CreateOrUpdate(ctx, r.client, actual, func() error { UID := actual.GetUID() rv := actual.GetResourceVersion() - actual.SetUnstructuredContent(desired.Object) + combinedLabels := obj.GetLabels() if combinedLabels == nil { combinedLabels = make(map[string]string) } + for key, value := range labels { combinedLabels[key] = value } + actual.SetLabels(combinedLabels) + combinedAnnotations := obj.GetAnnotations() if combinedAnnotations == nil { combinedAnnotations = make(map[string]string) } + for key, value := range annotations { combinedAnnotations[key] = value } + actual.SetAnnotations(combinedAnnotations) actual.SetResourceVersion(rv) actual.SetUID(UID) diff --git a/controllers/tenant/limitranges.go b/controllers/tenant/limitranges.go index 661abcb2d..33b68cec5 100644 --- a/controllers/tenant/limitranges.go +++ b/controllers/tenant/limitranges.go @@ -69,6 +69,7 @@ func (r *Manager) syncLimitRange(ctx context.Context, tenant *capsulev1beta2.Ten if labels == nil { labels = map[string]string{} } + labels[tenantLabel] = tenant.Name labels[limitRangeLabel] = strconv.Itoa(i) diff --git a/controllers/tenant/manager.go b/controllers/tenant/manager.go index 5bc426c27..f797bfa54 100644 --- a/controllers/tenant/manager.go +++ b/controllers/tenant/manager.go @@ -39,6 +39,7 @@ func (r *Manager) SetupWithManager(mgr ctrl.Manager) error { Complete(r) } +//nolint:nakedret func (r Manager) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error) { r.Log = r.Log.WithValues("Request.Name", request.Name) // Fetch the Tenant instance diff --git a/controllers/tenant/namespaces.go b/controllers/tenant/namespaces.go index cfd96dcf0..e4bb46978 100644 --- a/controllers/tenant/namespaces.go +++ b/controllers/tenant/namespaces.go @@ -42,7 +42,7 @@ func (r *Manager) syncNamespaces(ctx context.Context, tenant *capsulev1beta2.Ten return } -//nolint:gocognit +//nolint:gocognit,nakedret func (r *Manager) syncNamespaceMetadata(ctx context.Context, namespace string, tnt *capsulev1beta2.Tenant) (err error) { var res controllerutil.OperationResult @@ -81,6 +81,7 @@ func (r *Manager) syncNamespaceMetadata(ctx context.Context, namespace string, t if len(tnt.Spec.IngressOptions.AllowedClasses.Exact) > 0 { annotations[AvailableIngressClassesAnnotation] = strings.Join(tnt.Spec.IngressOptions.AllowedClasses.Exact, ",") } + if len(tnt.Spec.IngressOptions.AllowedClasses.Regex) > 0 { annotations[AvailableIngressClassesRegexpAnnotation] = tnt.Spec.IngressOptions.AllowedClasses.Regex } @@ -90,6 +91,7 @@ func (r *Manager) syncNamespaceMetadata(ctx context.Context, namespace string, t if len(tnt.Spec.StorageClasses.Exact) > 0 { annotations[AvailableStorageClassesAnnotation] = strings.Join(tnt.Spec.StorageClasses.Exact, ",") } + if len(tnt.Spec.StorageClasses.Regex) > 0 { annotations[AvailableStorageClassesRegexpAnnotation] = tnt.Spec.StorageClasses.Regex } @@ -99,6 +101,7 @@ func (r *Manager) syncNamespaceMetadata(ctx context.Context, namespace string, t if len(tnt.Spec.ContainerRegistries.Exact) > 0 { annotations[AllowedRegistriesAnnotation] = strings.Join(tnt.Spec.ContainerRegistries.Exact, ",") } + if len(tnt.Spec.ContainerRegistries.Regex) > 0 { annotations[AllowedRegistriesRegexpAnnotation] = tnt.Spec.ContainerRegistries.Regex } @@ -165,10 +168,10 @@ func (r *Manager) ensureNamespaceCount(ctx context.Context, tenant *capsulev1bet func (r *Manager) collectNamespaces(ctx context.Context, tenant *capsulev1beta2.Tenant) error { return retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { list := &corev1.NamespaceList{} + err = r.Client.List(ctx, list, client.MatchingFieldsSelector{ Selector: fields.OneTermEqualSelector(".metadata.ownerReferences[*].capsule", tenant.GetName()), }) - if err != nil { return } diff --git a/controllers/tenant/resourcequotas.go b/controllers/tenant/resourcequotas.go index 4f556b6b9..e343d37a4 100644 --- a/controllers/tenant/resourcequotas.go +++ b/controllers/tenant/resourcequotas.go @@ -38,6 +38,8 @@ import ( // the mutateFn along with the CreateOrUpdate to don't perform the update since resources are identical. // // In case of Namespace-scoped Resource Budget, we're just replicating the resources across all registered Namespaces. + +//nolint:nakedret func (r *Manager) syncResourceQuotas(ctx context.Context, tenant *capsulev1beta2.Tenant) (err error) { //nolint:gocognit // getting ResourceQuota labels for the mutateFn var tenantLabel, typeLabel string @@ -65,11 +67,13 @@ func (r *Manager) syncResourceQuotas(ctx context.Context, tenant *capsulev1beta2 // Calculating the Resource Budget at Tenant scope just if this is put in place. // Requirement to list ResourceQuota of the current Tenant var tntRequirement *labels.Requirement + if tntRequirement, scopeErr = labels.NewRequirement(tenantLabel, selection.Equals, []string{tenant.Name}); scopeErr != nil { r.Log.Error(scopeErr, "Cannot build ResourceQuota Tenant requirement") } // Requirement to list ResourceQuota for the current index var indexRequirement *labels.Requirement + if indexRequirement, scopeErr = labels.NewRequirement(typeLabel, selection.Equals, []string{strconv.Itoa(index)}); scopeErr != nil { r.Log.Error(scopeErr, "Cannot build ResourceQuota index requirement") } @@ -80,7 +84,7 @@ func (r *Manager) syncResourceQuotas(ctx context.Context, tenant *capsulev1beta2 if scopeErr = r.List(ctx, list, &client.ListOptions{LabelSelector: labels.NewSelector().Add(*tntRequirement).Add(*indexRequirement)}); scopeErr != nil { r.Log.Error(scopeErr, "Cannot list ResourceQuota", "tenantFilter", tntRequirement.String(), "indexFilter", indexRequirement.String()) - return + return scopeErr } // Iterating over all the options declared for the ResourceQuota, // summing all the used quota across different Namespaces to determinate @@ -95,6 +99,7 @@ func (r *Manager) syncResourceQuotas(ctx context.Context, tenant *capsulev1beta2 for _, item := range list.Items { quantity.Add(item.Status.Used[name]) } + r.Log.Info("Computed " + name.String() + " quota for the whole Tenant is " + quantity.String()) switch quantity.Cmp(resourceQuota.Hard[name]) { @@ -124,6 +129,7 @@ func (r *Manager) syncResourceQuotas(ctx context.Context, tenant *capsulev1beta2 if list.Items[item].Spec.Hard == nil { list.Items[item].Spec.Hard = map[corev1.ResourceName]resource.Quantity{} } + list.Items[item].Spec.Hard[name] = resourceQuota.Hard[name] for k := range list.Items[item].Spec.Hard { @@ -133,6 +139,7 @@ func (r *Manager) syncResourceQuotas(ctx context.Context, tenant *capsulev1beta2 } } } + if scopeErr = r.resourceQuotasUpdate(ctx, name, quantity, toKeep, resourceQuota.Hard[name], list.Items...); scopeErr != nil { r.Log.Error(scopeErr, "cannot proceed with outer ResourceQuota") @@ -168,6 +175,7 @@ func (r *Manager) syncResourceQuotas(ctx context.Context, tenant *capsulev1beta2 return group.Wait() } +//nolint:nakedret func (r *Manager) syncResourceQuota(ctx context.Context, tenant *capsulev1beta2.Tenant, namespace string, keys []string) (err error) { // getting ResourceQuota labels for the mutateFn var tenantLabel, typeLabel string @@ -207,6 +215,7 @@ func (r *Manager) syncResourceQuota(ctx context.Context, tenant *capsulev1beta2. target.SetLabels(targetLabels) target.Spec.Scopes = resQuota.Scopes target.Spec.ScopeSelector = resQuota.ScopeSelector + // In case of Namespace scope for the ResourceQuota we can easily apply the bare specification if tenant.Spec.ResourceQuota.Scope == api.ResourceQuotaScopeNamespace { target.Spec.Hard = resQuota.Hard @@ -278,6 +287,7 @@ func (r *Manager) resourceQuotasUpdate(ctx context.Context, resourceName corev1. if actualKey, keyErr := capsulev1beta2.UsedQuotaFor(resourceName); keyErr == nil { found.Annotations[actualKey] = actual.String() } + if limitKey, keyErr := capsulev1beta2.HardQuotaFor(resourceName); keyErr == nil { found.Annotations[limitKey] = limit.String() } diff --git a/controllers/tenant/rolebindings.go b/controllers/tenant/rolebindings.go index 056106ff0..e811594d5 100644 --- a/controllers/tenant/rolebindings.go +++ b/controllers/tenant/rolebindings.go @@ -91,6 +91,7 @@ func (r *Manager) syncRoleBindings(ctx context.Context, tenant *capsulev1beta2.T return group.Wait() } +//nolint:nakedret func (r *Manager) syncAdditionalRoleBinding(ctx context.Context, tenant *capsulev1beta2.Tenant, ns string, keys []string, hashFn func(binding api.AdditionalRoleBindingsSpec) string) (err error) { var tenantLabel, roleBindingLabel string diff --git a/controllers/tls/manager.go b/controllers/tls/manager.go index 558af16aa..cfb544234 100644 --- a/controllers/tls/manager.go +++ b/controllers/tls/manager.go @@ -219,6 +219,7 @@ func (r Reconciler) shouldUpdateCertificate(secret *corev1.Secret) bool { func (r *Reconciler) updateTenantCustomResourceDefinition(ctx context.Context, name string, caBundle []byte) error { return retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { crd := &apiextensionsv1.CustomResourceDefinition{} + err = r.Get(ctx, types.NamespacedName{Name: name}, crd) if err != nil { r.Log.Error(err, "cannot retrieve CustomResourceDefinition") @@ -254,12 +255,14 @@ func (r *Reconciler) updateTenantCustomResourceDefinition(ctx context.Context, n func (r Reconciler) updateValidatingWebhookConfiguration(ctx context.Context, caBundle []byte) error { return retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { vw := &admissionregistrationv1.ValidatingWebhookConfiguration{} + err = r.Get(ctx, types.NamespacedName{Name: r.Configuration.ValidatingWebhookConfigurationName()}, vw) if err != nil { r.Log.Error(err, "cannot retrieve ValidatingWebhookConfiguration") return err } + for i, w := range vw.Webhooks { // Updating CABundle only in case of an internal service reference if w.ClientConfig.Service != nil { @@ -275,12 +278,14 @@ func (r Reconciler) updateValidatingWebhookConfiguration(ctx context.Context, ca func (r Reconciler) updateMutatingWebhookConfiguration(ctx context.Context, caBundle []byte) error { return retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { mw := &admissionregistrationv1.MutatingWebhookConfiguration{} + err = r.Get(ctx, types.NamespacedName{Name: r.Configuration.MutatingWebhookConfigurationName()}, mw) if err != nil { r.Log.Error(err, "cannot retrieve MutatingWebhookConfiguration") return err } + for i, w := range mw.Webhooks { // Updating CABundle only in case of an internal service reference if w.ClientConfig.Service != nil { diff --git a/go.mod b/go.mod index 236ac7544..ecba86084 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/projectcapsule/capsule -go 1.20 +go 1.21 require ( github.com/go-logr/logr v1.4.1 diff --git a/pkg/api/forbidden_list.go b/pkg/api/forbidden_list.go index 77de462fd..a43b589a7 100644 --- a/pkg/api/forbidden_list.go +++ b/pkg/api/forbidden_list.go @@ -58,7 +58,7 @@ func NewForbiddenError(key string, forbiddenSpec ForbiddenListSpec) error { } } -//nolint:predeclared +//nolint:predeclared,revive func (f *ForbiddenError) appendForbiddenError() (append string) { append += "Forbidden are " if len(f.spec.Exact) > 0 { diff --git a/pkg/cert/ca.go b/pkg/cert/ca.go index b4b37a41a..c2e3c69d7 100644 --- a/pkg/cert/ca.go +++ b/pkg/cert/ca.go @@ -31,8 +31,8 @@ type CapsuleCA struct { func (c CapsuleCA) CACertificatePem() (b *bytes.Buffer, err error) { var crtBytes []byte - crtBytes, err = x509.CreateCertificate(rand.Reader, c.certificate, c.certificate, &c.key.PublicKey, c.key) + crtBytes, err = x509.CreateCertificate(rand.Reader, c.certificate, c.certificate, &c.key.PublicKey, c.key) if err != nil { return } @@ -147,8 +147,8 @@ func NewCertificateAuthorityFromBytes(certBytes, keyBytes []byte) (*CapsuleCA, e //nolint:nakedret func (c *CapsuleCA) GenerateCertificate(opts CertificateOptions) (certificatePem *bytes.Buffer, certificateKey *bytes.Buffer, err error) { var certPrivKey *rsa.PrivateKey - certPrivKey, err = rsa.GenerateKey(rand.Reader, 4096) + certPrivKey, err = rsa.GenerateKey(rand.Reader, 4096) if err != nil { return nil, nil, err } @@ -172,18 +172,18 @@ func (c *CapsuleCA) GenerateCertificate(opts CertificateOptions) (certificatePem } var certBytes []byte - certBytes, err = x509.CreateCertificate(rand.Reader, cert, c.certificate, &certPrivKey.PublicKey, c.key) + certBytes, err = x509.CreateCertificate(rand.Reader, cert, c.certificate, &certPrivKey.PublicKey, c.key) if err != nil { return nil, nil, err } certificatePem = new(bytes.Buffer) + err = pem.Encode(certificatePem, &pem.Block{ Type: "CERTIFICATE", Bytes: certBytes, }) - if err != nil { return } diff --git a/pkg/webhook/defaults/handler.go b/pkg/webhook/defaults/handler.go index 44d8dfbcb..b0c103848 100644 --- a/pkg/webhook/defaults/handler.go +++ b/pkg/webhook/defaults/handler.go @@ -34,8 +34,8 @@ func (h *handler) OnCreate(client client.Client, decoder *admission.Decoder, rec } } -func (h *handler) OnDelete(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (h *handler) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/ingress/errors.go b/pkg/webhook/ingress/errors.go index dead54a09..75ad4882c 100644 --- a/pkg/webhook/ingress/errors.go +++ b/pkg/webhook/ingress/errors.go @@ -102,7 +102,7 @@ func (i ingressClassNotValidError) Error() string { return utils.DefaultAllowedValuesErrorMessage(i.spec, err) } -//nolint:predeclared +//nolint:predeclared,revive func appendHostnameError(spec api.AllowedListSpec) (append string) { if len(spec.Exact) > 0 { append = fmt.Sprintf(", specify one of the following (%s)", strings.Join(spec.Exact, ", ")) diff --git a/pkg/webhook/ingress/utils.go b/pkg/webhook/ingress/utils.go index 3d35db991..52eb301c7 100644 --- a/pkg/webhook/ingress/utils.go +++ b/pkg/webhook/ingress/utils.go @@ -32,7 +32,6 @@ func TenantFromIngress(ctx context.Context, c client.Client, ingress Ingress) (* return &tenantList.Items[0], nil } -//nolint:nakedret func FromRequest(req admission.Request, decoder *admission.Decoder) (ingress Ingress, err error) { switch req.Kind.Group { case "networking.k8s.io": diff --git a/pkg/webhook/ingress/validate_class.go b/pkg/webhook/ingress/validate_class.go index 4df54b9a4..009979ce0 100644 --- a/pkg/webhook/ingress/validate_class.go +++ b/pkg/webhook/ingress/validate_class.go @@ -45,7 +45,7 @@ func (r *class) OnUpdate(client client.Client, decoder *admission.Decoder, recor } func (r *class) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/ingress/validate_collision.go b/pkg/webhook/ingress/validate_collision.go index a366295d0..7f74d342a 100644 --- a/pkg/webhook/ingress/validate_collision.go +++ b/pkg/webhook/ingress/validate_collision.go @@ -47,7 +47,7 @@ func (r *collision) OnUpdate(client client.Client, decoder *admission.Decoder, r } func (r *collision) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/ingress/validate_hostnames.go b/pkg/webhook/ingress/validate_hostnames.go index 6f11dcf5a..b79a5da33 100644 --- a/pkg/webhook/ingress/validate_hostnames.go +++ b/pkg/webhook/ingress/validate_hostnames.go @@ -41,7 +41,7 @@ func (r *hostnames) OnUpdate(c client.Client, decoder *admission.Decoder, record } func (r *hostnames) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/ingress/validate_wildcard.go b/pkg/webhook/ingress/validate_wildcard.go index 0341b43a3..205ef0f3f 100644 --- a/pkg/webhook/ingress/validate_wildcard.go +++ b/pkg/webhook/ingress/validate_wildcard.go @@ -31,8 +31,8 @@ func (h *wildcard) OnCreate(client client.Client, decoder *admission.Decoder, re } } -func (h *wildcard) OnDelete(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (h *wildcard) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/namespace/patch.go b/pkg/webhook/namespace/patch.go index aa359e3ba..f435e87aa 100644 --- a/pkg/webhook/namespace/patch.go +++ b/pkg/webhook/namespace/patch.go @@ -27,13 +27,13 @@ func PatchHandler() capsulewebhook.Handler { } func (r *patchHandler) OnCreate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } func (r *patchHandler) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/namespace/prefix.go b/pkg/webhook/namespace/prefix.go index bc7ff2709..8e9614627 100644 --- a/pkg/webhook/namespace/prefix.go +++ b/pkg/webhook/namespace/prefix.go @@ -69,13 +69,13 @@ func (r *prefixHandler) OnCreate(clt client.Client, decoder *admission.Decoder, } func (r *prefixHandler) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } func (r *prefixHandler) OnUpdate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/namespace/quota.go b/pkg/webhook/namespace/quota.go index c85a643a0..360de1e82 100644 --- a/pkg/webhook/namespace/quota.go +++ b/pkg/webhook/namespace/quota.go @@ -59,13 +59,13 @@ func (r *quotaHandler) OnCreate(client client.Client, decoder *admission.Decoder } func (r *quotaHandler) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } func (r *quotaHandler) OnUpdate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/namespace/user_metadata.go b/pkg/webhook/namespace/user_metadata.go index b667567e2..c5917dcde 100644 --- a/pkg/webhook/namespace/user_metadata.go +++ b/pkg/webhook/namespace/user_metadata.go @@ -64,8 +64,8 @@ func (r *userMetadataHandler) OnCreate(client client.Client, decoder *admission. } } -func (r *userMetadataHandler) OnDelete(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (r *userMetadataHandler) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/node/errors.go b/pkg/webhook/node/errors.go index 1ac0053ef..3c76207ef 100644 --- a/pkg/webhook/node/errors.go +++ b/pkg/webhook/node/errors.go @@ -10,7 +10,7 @@ import ( capsulev1beta2 "github.com/projectcapsule/capsule/pkg/api" ) -//nolint:predeclared +//nolint:predeclared,revive func appendForbiddenError(spec *capsulev1beta2.ForbiddenListSpec) (append string) { append += "Forbidden are " if len(spec.Exact) > 0 { diff --git a/pkg/webhook/node/user_metadata.go b/pkg/webhook/node/user_metadata.go index 7cf1a3a76..eb48befec 100644 --- a/pkg/webhook/node/user_metadata.go +++ b/pkg/webhook/node/user_metadata.go @@ -30,14 +30,14 @@ func UserMetadataHandler(configuration configuration.Configuration, ver *version } } -func (r *userMetadataHandler) OnCreate(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (r *userMetadataHandler) OnCreate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { + return func(context.Context, admission.Request) *admission.Response { return nil } } -func (r *userMetadataHandler) OnDelete(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (r *userMetadataHandler) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { + return func(context.Context, admission.Request) *admission.Response { return nil } } @@ -78,8 +78,8 @@ func (r *userMetadataHandler) getForbiddenNodeAnnotations(node *corev1.Node) map return forbiddenNodeAnnotations } -func (r *userMetadataHandler) OnUpdate(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (r *userMetadataHandler) OnUpdate(_ client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { + return func(_ context.Context, req admission.Request) *admission.Response { nodeWebhookSupported, _ := utils.NodeWebhookSupported(r.version) if !nodeWebhookSupported { diff --git a/pkg/webhook/ownerreference/patching.go b/pkg/webhook/ownerreference/patching.go index 989068654..451c92c36 100644 --- a/pkg/webhook/ownerreference/patching.go +++ b/pkg/webhook/ownerreference/patching.go @@ -42,14 +42,14 @@ func (h *handler) OnCreate(client client.Client, decoder *admission.Decoder, rec } } -func (h *handler) OnDelete(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (h *handler) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { + return func(context.Context, admission.Request) *admission.Response { return nil } } -func (h *handler) OnUpdate(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (h *handler) OnUpdate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { + return func(_ context.Context, req admission.Request) *admission.Response { oldNs := &corev1.Namespace{} if err := decoder.DecodeRaw(req.OldObject, oldNs); err != nil { return utils.ErroredResponse(err) diff --git a/pkg/webhook/pod/containerregistry.go b/pkg/webhook/pod/containerregistry.go index a559f26b8..1909571b4 100644 --- a/pkg/webhook/pod/containerregistry.go +++ b/pkg/webhook/pod/containerregistry.go @@ -30,7 +30,7 @@ func (h *containerRegistryHandler) OnCreate(c client.Client, decoder *admission. } func (h *containerRegistryHandler) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/pod/imagepullpolicy.go b/pkg/webhook/pod/imagepullpolicy.go index e4c43714a..1f1c2191b 100644 --- a/pkg/webhook/pod/imagepullpolicy.go +++ b/pkg/webhook/pod/imagepullpolicy.go @@ -66,13 +66,13 @@ func (r *imagePullPolicy) OnCreate(c client.Client, decoder *admission.Decoder, } func (r *imagePullPolicy) OnUpdate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } func (r *imagePullPolicy) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/pod/priorityclass.go b/pkg/webhook/pod/priorityclass.go index 4d5534d81..c38628c72 100644 --- a/pkg/webhook/pod/priorityclass.go +++ b/pkg/webhook/pod/priorityclass.go @@ -85,13 +85,13 @@ func (h *priorityClass) OnCreate(c client.Client, decoder *admission.Decoder, re } func (h *priorityClass) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } func (h *priorityClass) OnUpdate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/pod/runtimeclass.go b/pkg/webhook/pod/runtimeclass.go index b0bee2bbc..e2603bc11 100644 --- a/pkg/webhook/pod/runtimeclass.go +++ b/pkg/webhook/pod/runtimeclass.go @@ -44,13 +44,13 @@ func (h *runtimeClass) OnCreate(c client.Client, decoder *admission.Decoder, rec } func (h *runtimeClass) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } func (h *runtimeClass) OnUpdate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/pvc/pv.go b/pkg/webhook/pvc/pv.go index 5c4b278f1..8973bb674 100644 --- a/pkg/webhook/pvc/pv.go +++ b/pkg/webhook/pvc/pv.go @@ -34,7 +34,7 @@ func PersistentVolumeReuse() capsulewebhook.Handler { } } -func (p PV) OnCreate(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { +func (p PV) OnCreate(client client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { return func(ctx context.Context, req admission.Request) *admission.Response { pvc := corev1.PersistentVolumeClaim{} if err := decoder.Decode(req, &pvc); err != nil { diff --git a/pkg/webhook/pvc/validating.go b/pkg/webhook/pvc/validating.go index 1c58e4353..d94d4a412 100644 --- a/pkg/webhook/pvc/validating.go +++ b/pkg/webhook/pvc/validating.go @@ -88,13 +88,13 @@ func (h *validating) OnCreate(c client.Client, decoder *admission.Decoder, recor } func (h *validating) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } func (h *validating) OnUpdate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/service/validating.go b/pkg/webhook/service/validating.go index 904aa1db3..43c1aa1ac 100644 --- a/pkg/webhook/service/validating.go +++ b/pkg/webhook/service/validating.go @@ -138,7 +138,7 @@ func (r *handler) OnUpdate(client client.Client, decoder *admission.Decoder, rec } func (r *handler) OnDelete(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/tenant/containerregistry_regex.go b/pkg/webhook/tenant/containerregistry_regex.go index 7127d6dd9..86f673f7e 100644 --- a/pkg/webhook/tenant/containerregistry_regex.go +++ b/pkg/webhook/tenant/containerregistry_regex.go @@ -41,7 +41,7 @@ func (h *containerRegistryRegexHandler) validate(decoder *admission.Decoder, req } func (h *containerRegistryRegexHandler) OnCreate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(_ context.Context, req admission.Request) *admission.Response { if err := h.validate(decoder, req); err != nil { return err } @@ -56,8 +56,8 @@ func (h *containerRegistryRegexHandler) OnDelete(client.Client, *admission.Decod } } -func (h *containerRegistryRegexHandler) OnUpdate(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (h *containerRegistryRegexHandler) OnUpdate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { + return func(_ context.Context, req admission.Request) *admission.Response { if response := h.validate(decoder, req); response != nil { return response } diff --git a/pkg/webhook/tenant/custom_resource_quota.go b/pkg/webhook/tenant/custom_resource_quota.go index 31578ab1c..7ebeb14f1 100644 --- a/pkg/webhook/tenant/custom_resource_quota.go +++ b/pkg/webhook/tenant/custom_resource_quota.go @@ -47,7 +47,7 @@ func (r *resourceCounterHandler) getTenantName(ctx context.Context, clt client.C return tntList.Items[0].GetName(), nil } -func (r *resourceCounterHandler) OnCreate(clt client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { +func (r *resourceCounterHandler) OnCreate(clt client.Client, _ *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { return func(ctx context.Context, req admission.Request) *admission.Response { var tntName string @@ -79,8 +79,8 @@ func (r *resourceCounterHandler) OnCreate(clt client.Client, decoder *admission. return err } - used, _ := capsulev1beta2.GetUsedResourceFromTenant(*tnt, kgv) + used, _ := capsulev1beta2.GetUsedResourceFromTenant(*tnt, kgv) if used >= limit { return NewCustomResourceQuotaError(kgv, limit) } @@ -101,7 +101,7 @@ func (r *resourceCounterHandler) OnCreate(clt client.Client, decoder *admission. } } -func (r *resourceCounterHandler) OnDelete(clt client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { +func (r *resourceCounterHandler) OnDelete(clt client.Client, _ *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { return func(ctx context.Context, req admission.Request) *admission.Response { var tntName string @@ -145,8 +145,8 @@ func (r *resourceCounterHandler) OnDelete(clt client.Client, decoder *admission. } } -func (r *resourceCounterHandler) OnUpdate(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (r *resourceCounterHandler) OnUpdate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/tenant/forbidden_annotations_regex.go b/pkg/webhook/tenant/forbidden_annotations_regex.go index 51cfc7a5f..2cb887988 100644 --- a/pkg/webhook/tenant/forbidden_annotations_regex.go +++ b/pkg/webhook/tenant/forbidden_annotations_regex.go @@ -50,7 +50,7 @@ func (h *forbiddenAnnotationsRegexHandler) validate(decoder *admission.Decoder, } func (h *forbiddenAnnotationsRegexHandler) OnCreate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(_ context.Context, req admission.Request) *admission.Response { if err := h.validate(decoder, req); err != nil { return err } @@ -65,8 +65,8 @@ func (h *forbiddenAnnotationsRegexHandler) OnDelete(client.Client, *admission.De } } -func (h *forbiddenAnnotationsRegexHandler) OnUpdate(client client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (h *forbiddenAnnotationsRegexHandler) OnUpdate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { + return func(_ context.Context, req admission.Request) *admission.Response { if response := h.validate(decoder, req); response != nil { return response } diff --git a/pkg/webhook/tenant/freezed_emitter.go b/pkg/webhook/tenant/freezed_emitter.go index 562b0a4c0..8e5fc4766 100644 --- a/pkg/webhook/tenant/freezed_emitter.go +++ b/pkg/webhook/tenant/freezed_emitter.go @@ -23,7 +23,7 @@ func FreezedEmitter() capsulewebhook.Handler { } func (h *freezedEmitterHandler) OnCreate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } @@ -35,7 +35,7 @@ func (h *freezedEmitterHandler) OnDelete(client.Client, *admission.Decoder, reco } func (h *freezedEmitterHandler) OnUpdate(_ client.Client, decoder *admission.Decoder, recorder record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(_ context.Context, req admission.Request) *admission.Response { oldTnt := &capsulev1beta2.Tenant{} if err := decoder.DecodeRaw(req.OldObject, oldTnt); err != nil { return utils.ErroredResponse(err) diff --git a/pkg/webhook/tenant/hostname_regex.go b/pkg/webhook/tenant/hostname_regex.go index a5f795689..1c0587ad8 100644 --- a/pkg/webhook/tenant/hostname_regex.go +++ b/pkg/webhook/tenant/hostname_regex.go @@ -41,7 +41,7 @@ func (h *hostnameRegexHandler) validate(decoder *admission.Decoder, req admissio } func (h *hostnameRegexHandler) OnCreate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(_ context.Context, req admission.Request) *admission.Response { if response := h.validate(decoder, req); response != nil { return response } @@ -57,7 +57,7 @@ func (h *hostnameRegexHandler) OnDelete(client.Client, *admission.Decoder, recor } func (h *hostnameRegexHandler) OnUpdate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(_ context.Context, req admission.Request) *admission.Response { if err := h.validate(decoder, req); err != nil { return err } diff --git a/pkg/webhook/tenant/ingressclass_regex.go b/pkg/webhook/tenant/ingressclass_regex.go index 1d1a7d43c..4bd4ff218 100644 --- a/pkg/webhook/tenant/ingressclass_regex.go +++ b/pkg/webhook/tenant/ingressclass_regex.go @@ -41,7 +41,7 @@ func (h *ingressClassRegexHandler) validate(decoder *admission.Decoder, req admi } func (h *ingressClassRegexHandler) OnCreate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(_ context.Context, req admission.Request) *admission.Response { if response := h.validate(decoder, req); response != nil { return response } @@ -57,7 +57,7 @@ func (h *ingressClassRegexHandler) OnDelete(client.Client, *admission.Decoder, r } func (h *ingressClassRegexHandler) OnUpdate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(_ context.Context, req admission.Request) *admission.Response { if err := h.validate(decoder, req); err != nil { return err } diff --git a/pkg/webhook/tenant/metadata.go b/pkg/webhook/tenant/metadata.go index 0bdd547b8..6d43af3eb 100644 --- a/pkg/webhook/tenant/metadata.go +++ b/pkg/webhook/tenant/metadata.go @@ -23,8 +23,8 @@ func MetaHandler() capsulewebhook.Handler { return &metaHandler{} } -func (h *metaHandler) OnCreate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { +func (h *metaHandler) OnCreate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { + return func(context.Context, admission.Request) *admission.Response { return nil } } @@ -36,7 +36,7 @@ func (h *metaHandler) OnDelete(client.Client, *admission.Decoder, record.EventRe } func (h *metaHandler) OnUpdate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(_ context.Context, req admission.Request) *admission.Response { tenant := &capsulev1beta2.Tenant{} if err := decoder.Decode(req, tenant); err != nil { return utils.ErroredResponse(err) diff --git a/pkg/webhook/tenant/name.go b/pkg/webhook/tenant/name.go index 7e6a73617..c35443a99 100644 --- a/pkg/webhook/tenant/name.go +++ b/pkg/webhook/tenant/name.go @@ -23,7 +23,7 @@ func NameHandler() capsulewebhook.Handler { } func (h *nameHandler) OnCreate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(_ context.Context, req admission.Request) *admission.Response { tenant := &capsulev1beta2.Tenant{} if err := decoder.Decode(req, tenant); err != nil { return utils.ErroredResponse(err) @@ -47,7 +47,7 @@ func (h *nameHandler) OnDelete(client.Client, *admission.Decoder, record.EventRe } func (h *nameHandler) OnUpdate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } } diff --git a/pkg/webhook/tenant/protected.go b/pkg/webhook/tenant/protected.go index 06868e47a..95f42d47d 100644 --- a/pkg/webhook/tenant/protected.go +++ b/pkg/webhook/tenant/protected.go @@ -28,7 +28,7 @@ func (h *protectedHandler) OnCreate(client.Client, *admission.Decoder, record.Ev } } -func (h *protectedHandler) OnDelete(clt client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { +func (h *protectedHandler) OnDelete(clt client.Client, _ *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { return func(ctx context.Context, req admission.Request) *admission.Response { tenant := &capsulev1beta2.Tenant{} diff --git a/pkg/webhook/tenant/storageclass_regex.go b/pkg/webhook/tenant/storageclass_regex.go index e7c77b3b7..958facfcf 100644 --- a/pkg/webhook/tenant/storageclass_regex.go +++ b/pkg/webhook/tenant/storageclass_regex.go @@ -41,7 +41,7 @@ func (h *storageClassRegexHandler) validate(decoder *admission.Decoder, req admi } func (h *storageClassRegexHandler) OnCreate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(_ context.Context, req admission.Request) *admission.Response { if err := h.validate(decoder, req); err != nil { return err } @@ -57,7 +57,7 @@ func (h *storageClassRegexHandler) OnDelete(client.Client, *admission.Decoder, r } func (h *storageClassRegexHandler) OnUpdate(_ client.Client, decoder *admission.Decoder, _ record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(_ context.Context, req admission.Request) *admission.Response { if err := h.validate(decoder, req); err != nil { return err } diff --git a/pkg/webhook/tenantresource/objects.go b/pkg/webhook/tenantresource/objects.go index 9767d37bd..10f769efc 100644 --- a/pkg/webhook/tenantresource/objects.go +++ b/pkg/webhook/tenantresource/objects.go @@ -71,7 +71,7 @@ func (h *cordoningHandler) handler(ctx context.Context, clt client.Client, req a } func (h *cordoningHandler) OnCreate(client.Client, *admission.Decoder, record.EventRecorder) capsulewebhook.Func { - return func(ctx context.Context, req admission.Request) *admission.Response { + return func(context.Context, admission.Request) *admission.Response { return nil } }