62 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Go
		
	
	
	
| /*
 | |
| Copyright 2021.
 | |
| 
 | |
| Licensed under the Apache License, Version 2.0 (the "License");
 | |
| you may not use this file except in compliance with the License.
 | |
| You may obtain a copy of the License at
 | |
| 
 | |
|     http://www.apache.org/licenses/LICENSE-2.0
 | |
| 
 | |
| Unless required by applicable law or agreed to in writing, software
 | |
| distributed under the License is distributed on an "AS IS" BASIS,
 | |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
| See the License for the specific language governing permissions and
 | |
| limitations under the License.
 | |
| */
 | |
| 
 | |
| package v1alpha2
 | |
| 
 | |
| import (
 | |
| 	"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"
 | |
| )
 | |
| 
 | |
| // log is for logging in this package.
 | |
| var jenkinslog = logf.Log.WithName("jenkins-resource")
 | |
| 
 | |
| func (in *Jenkins) SetupWebhookWithManager(mgr ctrl.Manager) error {
 | |
| 	return ctrl.NewWebhookManagedBy(mgr).
 | |
| 		For(in).
 | |
| 		Complete()
 | |
| }
 | |
| 
 | |
| // EDIT THIS FILE!  THIS IS SCAFFOLDING FOR YOU TO OWN!
 | |
| 
 | |
| // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
 | |
| // +kubebuilder:webhook:path=/validate-jenkins-io-jenkins-io-v1alpha2-jenkins,mutating=false,failurePolicy=fail,sideEffects=None,groups=jenkins.io.jenkins.io,resources=jenkins,verbs=create;update,versions=v1alpha2,name=vjenkins.kb.io,admissionReviewVersions={v1,v1beta1}
 | |
| 
 | |
| var _ webhook.Validator = &Jenkins{}
 | |
| 
 | |
| // ValidateCreate implements webhook.Validator so a webhook will be registered for the type
 | |
| func (in *Jenkins) ValidateCreate() error {
 | |
| 	jenkinslog.Info("validate create", "name", in.Name)
 | |
| 
 | |
| 	// TODO(user): fill in your validation logic upon object creation.
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
 | |
| func (in *Jenkins) ValidateUpdate(old runtime.Object) error {
 | |
| 	jenkinslog.Info("validate update", "name", in.Name)
 | |
| 
 | |
| 	// TODO(user): fill in your validation logic upon object update.
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| func (in *Jenkins) ValidateDelete() error {
 | |
| 	// TODO(user): fill in your validation logic upon object deletion.
 | |
| 	return nil
 | |
| }
 |