/
cronhotbackup_webhook.go
49 lines (37 loc) · 1.93 KB
/
cronhotbackup_webhook.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package v1alpha1
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"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)
// log is for logging in this package.
var cronhotbackuplog = logf.Log.WithName("cronhotbackup-resource")
func (r *CronHotBackup) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Complete()
}
// TODO(user): 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-hazelcast-com-v1alpha1-cronhotbackup,mutating=false,failurePolicy=ignore,sideEffects=None,groups=hazelcast.com,resources=cronhotbackups,verbs=create;update,versions=v1alpha1,name=vcronhotbackup.kb.io,admissionReviewVersions=v1
var _ webhook.Validator = &CronHotBackup{}
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *CronHotBackup) ValidateCreate() (admission.Warnings, error) {
cronhotbackuplog.Info("validate create", "name", r.Name)
// TODO(user): fill in your validation logic upon object creation.
return admission.Warnings{}, nil
}
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *CronHotBackup) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
cronhotbackuplog.Info("validate update", "name", r.Name)
// TODO(user): fill in your validation logic upon object update.
return admission.Warnings{}, nil
}
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *CronHotBackup) ValidateDelete() (admission.Warnings, error) {
cronhotbackuplog.Info("validate delete", "name", r.Name)
// TODO(user): fill in your validation logic upon object deletion.
return admission.Warnings{}, nil
}