diff --git a/PROJECT b/PROJECT index 024b3101..3608e28c 100644 --- a/PROJECT +++ b/PROJECT @@ -71,8 +71,4 @@ resources: kind: Runner path: github.com/mercedes-benz/garm-operator/api/v1alpha1 version: v1alpha1 - webhooks: - defaulting: true - validation: true - webhookVersion: v1 version: "3" diff --git a/api/v1alpha1/runner_webhook.go b/api/v1alpha1/runner_webhook.go deleted file mode 100644 index d6c68043..00000000 --- a/api/v1alpha1/runner_webhook.go +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-License-Identifier: MIT - -package v1alpha1 - -import ( - "fmt" - - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" -) - -// log is for logging in this package. -var runnerlog = logf.Log.WithName("runner-resource") - -func (r *Runner) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} - -//+kubebuilder:webhook:path=/validate-garm-operator-mercedes-benz-com-v1alpha1-runner,mutating=false,failurePolicy=fail,sideEffects=None,groups=garm-operator.mercedes-benz.com,resources=runners,verbs=create;update,versions=v1alpha1,name=vrunner.kb.io,admissionReviewVersions=v1 - -var _ webhook.Validator = &Runner{} - -func (r *Runner) ValidateCreate() (admission.Warnings, error) { - runnerlog.Info("validate create", "name", r.Name) - - return nil, apierrors.NewForbidden( - GroupVersion.WithResource("Runner").GroupResource(), - r.Name, - fmt.Errorf("creation of runner CR %s forbitten", r.Name), - ) -} - -func (r *Runner) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { - runnerlog.Info("validate update", "name", r.Name) - - return nil, apierrors.NewForbidden( - GroupVersion.WithResource("Runner").GroupResource(), - r.Name, - fmt.Errorf("update to runner CR %s forbitten", r.Name), - ) -} - -func (r *Runner) ValidateDelete() (admission.Warnings, error) { - runnerlog.Info("validate delete", "name", r.Name) - return nil, nil -} diff --git a/cmd/main.go b/cmd/main.go index ba1f79cd..3c0f57fd 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -241,11 +241,6 @@ func main() { go runnerReconciler.PollRunnerInstances(ctx, eventChan) defer cancel() - if err = (&garmoperatorv1alpha1.Runner{}).SetupWebhookWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create webhook", "webhook", "Runner") - exitCode = 1 - return - } //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index 32fb3345..13b15fbd 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -65,23 +65,3 @@ webhooks: resources: - repositories sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: webhook-service - namespace: system - path: /validate-garm-operator-mercedes-benz-com-v1alpha1-runner - failurePolicy: Fail - name: vrunner.kb.io - rules: - - apiGroups: - - garm-operator.mercedes-benz.com - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - runners - sideEffects: None