Skip to content

Commit 3dd8c1a

Browse files
Remove unused webhook verbs and defaulting webhook config
1 parent cf332b2 commit 3dd8c1a

File tree

3 files changed

+6
-30
lines changed

3 files changed

+6
-30
lines changed

PROJECT

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ resources:
1818
path: github.com/octopusdeploy/octopus-permissions-controller/api/v1beta1
1919
version: v1beta1
2020
webhooks:
21-
defaulting: true
2221
validation: true
2322
webhookVersion: v1
2423
version: "3"

config/webhook/kustomizeconfig.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,11 @@ nameReference:
44
- kind: Service
55
version: v1
66
fieldSpecs:
7-
- kind: MutatingWebhookConfiguration
8-
group: admissionregistration.k8s.io
9-
path: webhooks/clientConfig/service/name
107
- kind: ValidatingWebhookConfiguration
118
group: admissionregistration.k8s.io
129
path: webhooks/clientConfig/service/name
1310

1411
namespace:
15-
- kind: MutatingWebhookConfiguration
16-
group: admissionregistration.k8s.io
17-
path: webhooks/clientConfig/service/namespace
18-
create: true
1912
- kind: ValidatingWebhookConfiguration
2013
group: admissionregistration.k8s.io
2114
path: webhooks/clientConfig/service/namespace

internal/webhook/v1beta1/workloadserviceaccount_webhook.go

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ func SetupWorkloadServiceAccountWebhookWithManager(mgr ctrl.Manager) error {
4545
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
4646
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
4747
// 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
4949

5050
// WorkloadServiceAccountCustomValidator struct is responsible for validating the WorkloadServiceAccount resource
51-
// when it is created, updated, or deleted.
51+
// when it is created.
5252
//
5353
// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods,
5454
// 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
7474
return nil, nil
7575
}
7676

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) {
8779
return nil, nil
8880
}
8981

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) {
10084
return nil, nil
10185
}

0 commit comments

Comments
 (0)