sigs.k8s.io/kueue@v0.6.2/pkg/controller/jobs/noop/noop_webhook.go (about)

     1  /*
     2  Copyright 2023 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package noop
    18  
    19  import (
    20  	"context"
    21  
    22  	"k8s.io/apimachinery/pkg/runtime"
    23  	ctrl "sigs.k8s.io/controller-runtime"
    24  	"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
    25  )
    26  
    27  type webhook struct {
    28  }
    29  
    30  // SetupWebhook configures the webhook for batchJob.
    31  func SetupWebhook(mgr ctrl.Manager, apiType runtime.Object) error {
    32  	wh := &webhook{}
    33  	return ctrl.NewWebhookManagedBy(mgr).
    34  		For(apiType).
    35  		WithDefaulter(wh).
    36  		WithValidator(wh).
    37  		Complete()
    38  }
    39  
    40  // Default implements webhook.CustomDefaulter so a webhook will be registered for the type
    41  func (w *webhook) Default(ctx context.Context, obj runtime.Object) error {
    42  	return nil
    43  }
    44  
    45  // ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type
    46  func (w *webhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
    47  	return nil, nil
    48  }
    49  
    50  // ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type
    51  func (w *webhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
    52  	return nil, nil
    53  }
    54  
    55  // ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type
    56  func (w *webhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
    57  	return nil, nil
    58  }