Skip to content

Commit 5a21ec1

Browse files
Add Support for Scaffolding Webhooks for Core Types
This update introduces support for scaffolding webhooks for Core Types, which are Kubernetes-native resources defined in the Kubernetes API.
1 parent e451dfe commit 5a21ec1

File tree

42 files changed

+701
-404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+701
-404
lines changed

docs/book/src/SUMMARY.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
- [Kind for Dev & CI](reference/kind.md)
8383
- [What's a webhook?](reference/webhook-overview.md)
8484
- [Admission webhook](reference/admission-webhook.md)
85-
- [Webhooks for Core Types](reference/webhook-for-core-types.md)
8685
- [Markers for Config/Code Generation](./reference/markers.md)
8786

8887
- [CRD Generation](./reference/markers/crd.md)

docs/book/src/cronjob-tutorial/testdata/project/config/webhook/manifests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ webhooks:
1212
namespace: system
1313
path: /mutate-batch-tutorial-kubebuilder-io-v1-cronjob
1414
failurePolicy: Fail
15-
name: mcronjob-v1.kb.io
15+
name: mcronjob.kb.io
1616
rules:
1717
- apiGroups:
1818
- batch.tutorial.kubebuilder.io
@@ -38,7 +38,7 @@ webhooks:
3838
namespace: system
3939
path: /validate-batch-tutorial-kubebuilder-io-v1-cronjob
4040
failurePolicy: Fail
41-
name: vcronjob-v1.kb.io
41+
name: vcronjob.kb.io
4242
rules:
4343
- apiGroups:
4444
- batch.tutorial.kubebuilder.io

docs/book/src/cronjob-tutorial/testdata/project/internal/webhook/v1/cronjob_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ The meaning of each marker can be found [here](/reference/markers/webhook.md).
7171
This marker is responsible for generating a mutation webhook manifest.
7272
*/
7373

74-
// +kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=mcronjob-v1.kb.io,admissionReviewVersions=v1
74+
// +kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=mcronjob.kb.io,admissionReviewVersions=v1
7575

7676
// CronJobCustomDefaulter struct is responsible for setting default values on the custom resource of the
7777
// Kind CronJob when those are created or updated.
@@ -154,7 +154,7 @@ validate anything on deletion.
154154
/*
155155
This marker is responsible for generating a validation webhook manifest.
156156
*/
157-
// +kubebuilder:webhook:path=/validate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=vcronjob-v1.kb.io,admissionReviewVersions=v1
157+
// +kubebuilder:webhook:path=/validate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=vcronjob.kb.io,admissionReviewVersions=v1
158158

159159
// CronJobCustomValidator struct is responsible for validating the CronJob resource
160160
// when it is created, updated, or deleted.

docs/book/src/multiversion-tutorial/testdata/project/config/webhook/manifests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ webhooks:
1212
namespace: system
1313
path: /mutate-batch-tutorial-kubebuilder-io-v1-cronjob
1414
failurePolicy: Fail
15-
name: mcronjob-v1.kb.io
15+
name: mcronjob.kb.io
1616
rules:
1717
- apiGroups:
1818
- batch.tutorial.kubebuilder.io
@@ -32,7 +32,7 @@ webhooks:
3232
namespace: system
3333
path: /mutate-batch-tutorial-kubebuilder-io-v2-cronjob
3434
failurePolicy: Fail
35-
name: mcronjob-v2.kb.io
35+
name: mcronjob.kb.io
3636
rules:
3737
- apiGroups:
3838
- batch.tutorial.kubebuilder.io
@@ -58,7 +58,7 @@ webhooks:
5858
namespace: system
5959
path: /validate-batch-tutorial-kubebuilder-io-v1-cronjob
6060
failurePolicy: Fail
61-
name: vcronjob-v1.kb.io
61+
name: vcronjob.kb.io
6262
rules:
6363
- apiGroups:
6464
- batch.tutorial.kubebuilder.io
@@ -78,7 +78,7 @@ webhooks:
7878
namespace: system
7979
path: /validate-batch-tutorial-kubebuilder-io-v2-cronjob
8080
failurePolicy: Fail
81-
name: vcronjob-v2.kb.io
81+
name: vcronjob.kb.io
8282
rules:
8383
- apiGroups:
8484
- batch.tutorial.kubebuilder.io

docs/book/src/multiversion-tutorial/testdata/project/internal/webhook/v1/cronjob_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The meaning of each marker can be found [here](/reference/markers/webhook.md).
7575
This marker is responsible for generating a mutation webhook manifest.
7676
*/
7777

78-
// +kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=mcronjob-v1.kb.io,admissionReviewVersions=v1
78+
// +kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=mcronjob.kb.io,admissionReviewVersions=v1
7979

8080
// CronJobCustomDefaulter struct is responsible for setting default values on the custom resource of the
8181
// Kind CronJob when those are created or updated.
@@ -158,7 +158,7 @@ validate anything on deletion.
158158
/*
159159
This marker is responsible for generating a validation webhook manifest.
160160
*/
161-
// +kubebuilder:webhook:path=/validate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=vcronjob-v1.kb.io,admissionReviewVersions=v1
161+
// +kubebuilder:webhook:path=/validate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=vcronjob.kb.io,admissionReviewVersions=v1
162162

163163
// CronJobCustomValidator struct is responsible for validating the CronJob resource
164164
// when it is created, updated, or deleted.

docs/book/src/multiversion-tutorial/testdata/project/internal/webhook/v2/cronjob_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func SetupCronJobWebhookWithManager(mgr ctrl.Manager) error {
5555

5656
// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
5757

58-
// +kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v2-cronjob,mutating=true,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v2,name=mcronjob-v2.kb.io,admissionReviewVersions=v1
58+
// +kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v2-cronjob,mutating=true,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v2,name=mcronjob.kb.io,admissionReviewVersions=v1
5959

6060
// CronJobCustomDefaulter struct is responsible for setting default values on the custom resource of the
6161
// Kind CronJob when those are created or updated.
@@ -90,7 +90,7 @@ func (d *CronJobCustomDefaulter) Default(ctx context.Context, obj runtime.Object
9090
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
9191
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
9292
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
93-
// +kubebuilder:webhook:path=/validate-batch-tutorial-kubebuilder-io-v2-cronjob,mutating=false,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v2,name=vcronjob-v2.kb.io,admissionReviewVersions=v1
93+
// +kubebuilder:webhook:path=/validate-batch-tutorial-kubebuilder-io-v2-cronjob,mutating=false,failurePolicy=fail,sideEffects=None,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v2,name=vcronjob.kb.io,admissionReviewVersions=v1
9494

9595
// CronJobCustomValidator struct is responsible for validating the CronJob resource
9696
// when it is created, updated, or deleted.

0 commit comments

Comments
 (0)