@@ -45,10 +45,10 @@ func SetupWorkloadServiceAccountWebhookWithManager(mgr ctrl.Manager) error {
45
45
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
46
46
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
47
47
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
48
- // +kubebuilder:webhook:path=/validate-agent-octopus-com-v1beta1-workloadserviceaccount,mutating=false,failurePolicy=fail,sideEffects=None,groups=agent.octopus.com,resources=workloadserviceaccounts,verbs=create;update ,versions=v1beta1,name=vworkloadserviceaccount-v1beta1.kb.io,admissionReviewVersions=v1
48
+ // +kubebuilder:webhook:path=/validate-agent-octopus-com-v1beta1-workloadserviceaccount,mutating=false,failurePolicy=fail,sideEffects=None,groups=agent.octopus.com,resources=workloadserviceaccounts,verbs=create,versions=v1beta1,name=vworkloadserviceaccount-v1beta1.kb.io,admissionReviewVersions=v1
49
49
50
50
// WorkloadServiceAccountCustomValidator struct is responsible for validating the WorkloadServiceAccount resource
51
- // when it is created, updated, or deleted .
51
+ // when it is created.
52
52
//
53
53
// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods,
54
54
// as this struct is used only for temporary operations and does not need to be deeply copied.
@@ -74,28 +74,12 @@ func (v *WorkloadServiceAccountCustomValidator) ValidateCreate(_ context.Context
74
74
return nil , nil
75
75
}
76
76
77
- // ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type WorkloadServiceAccount.
78
- func (v * WorkloadServiceAccountCustomValidator ) ValidateUpdate (_ context.Context , oldObj , newObj runtime.Object ) (admission.Warnings , error ) {
79
- workloadserviceaccount , ok := newObj .(* agentoctopuscomv1beta1.WorkloadServiceAccount )
80
- if ! ok {
81
- return nil , fmt .Errorf ("expected a WorkloadServiceAccount object for the newObj but got %T" , newObj )
82
- }
83
- workloadserviceaccountlog .Info ("Validation for WorkloadServiceAccount upon update" , "name" , workloadserviceaccount .GetName ())
84
-
85
- // TODO(user): fill in your validation logic upon object update.
86
-
77
+ // ValidateUpdate implements webhook.CustomValidator but is not used since webhook only handles create operations.
78
+ func (v * WorkloadServiceAccountCustomValidator ) ValidateUpdate (_ context.Context , _ , _ runtime.Object ) (admission.Warnings , error ) {
87
79
return nil , nil
88
80
}
89
81
90
- // ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type WorkloadServiceAccount.
91
- func (v * WorkloadServiceAccountCustomValidator ) ValidateDelete (ctx context.Context , obj runtime.Object ) (admission.Warnings , error ) {
92
- workloadserviceaccount , ok := obj .(* agentoctopuscomv1beta1.WorkloadServiceAccount )
93
- if ! ok {
94
- return nil , fmt .Errorf ("expected a WorkloadServiceAccount object but got %T" , obj )
95
- }
96
- workloadserviceaccountlog .Info ("Validation for WorkloadServiceAccount upon deletion" , "name" , workloadserviceaccount .GetName ())
97
-
98
- // TODO(user): fill in your validation logic upon object deletion.
99
-
82
+ // ValidateDelete implements webhook.CustomValidator but is not used since webhook only handles create operations.
83
+ func (v * WorkloadServiceAccountCustomValidator ) ValidateDelete (_ context.Context , _ runtime.Object ) (admission.Warnings , error ) {
100
84
return nil , nil
101
85
}
0 commit comments