Skip to content

Commit

Permalink
Add Support for Scaffolding Webhooks for Core Types
Browse files Browse the repository at this point in the history
This update introduces support for scaffolding webhooks for Core Types, which are Kubernetes-native resources defined in the Kubernetes API.
  • Loading branch information
camilamacedo86 committed Oct 14, 2024
1 parent e451dfe commit 5a21ec1
Show file tree
Hide file tree
Showing 42 changed files with 701 additions and 404 deletions.
1 change: 0 additions & 1 deletion docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
- [Kind for Dev & CI](reference/kind.md)
- [What's a webhook?](reference/webhook-overview.md)
- [Admission webhook](reference/admission-webhook.md)
- [Webhooks for Core Types](reference/webhook-for-core-types.md)
- [Markers for Config/Code Generation](./reference/markers.md)

- [CRD Generation](./reference/markers/crd.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ webhooks:
namespace: system
path: /mutate-batch-tutorial-kubebuilder-io-v1-cronjob
failurePolicy: Fail
name: mcronjob-v1.kb.io
name: mcronjob.kb.io
rules:
- apiGroups:
- batch.tutorial.kubebuilder.io
Expand All @@ -38,7 +38,7 @@ webhooks:
namespace: system
path: /validate-batch-tutorial-kubebuilder-io-v1-cronjob
failurePolicy: Fail
name: vcronjob-v1.kb.io
name: vcronjob.kb.io
rules:
- apiGroups:
- batch.tutorial.kubebuilder.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The meaning of each marker can be found [here](/reference/markers/webhook.md).
This marker is responsible for generating a mutation webhook manifest.
*/

// +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
// +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

// CronJobCustomDefaulter struct is responsible for setting default values on the custom resource of the
// Kind CronJob when those are created or updated.
Expand Down Expand Up @@ -154,7 +154,7 @@ validate anything on deletion.
/*
This marker is responsible for generating a validation webhook manifest.
*/
// +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
// +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

// CronJobCustomValidator struct is responsible for validating the CronJob resource
// when it is created, updated, or deleted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ webhooks:
namespace: system
path: /mutate-batch-tutorial-kubebuilder-io-v1-cronjob
failurePolicy: Fail
name: mcronjob-v1.kb.io
name: mcronjob.kb.io
rules:
- apiGroups:
- batch.tutorial.kubebuilder.io
Expand All @@ -32,7 +32,7 @@ webhooks:
namespace: system
path: /mutate-batch-tutorial-kubebuilder-io-v2-cronjob
failurePolicy: Fail
name: mcronjob-v2.kb.io
name: mcronjob.kb.io
rules:
- apiGroups:
- batch.tutorial.kubebuilder.io
Expand All @@ -58,7 +58,7 @@ webhooks:
namespace: system
path: /validate-batch-tutorial-kubebuilder-io-v1-cronjob
failurePolicy: Fail
name: vcronjob-v1.kb.io
name: vcronjob.kb.io
rules:
- apiGroups:
- batch.tutorial.kubebuilder.io
Expand All @@ -78,7 +78,7 @@ webhooks:
namespace: system
path: /validate-batch-tutorial-kubebuilder-io-v2-cronjob
failurePolicy: Fail
name: vcronjob-v2.kb.io
name: vcronjob.kb.io
rules:
- apiGroups:
- batch.tutorial.kubebuilder.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The meaning of each marker can be found [here](/reference/markers/webhook.md).
This marker is responsible for generating a mutation webhook manifest.
*/

// +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
// +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

// CronJobCustomDefaulter struct is responsible for setting default values on the custom resource of the
// Kind CronJob when those are created or updated.
Expand Down Expand Up @@ -158,7 +158,7 @@ validate anything on deletion.
/*
This marker is responsible for generating a validation webhook manifest.
*/
// +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
// +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

// CronJobCustomValidator struct is responsible for validating the CronJob resource
// when it is created, updated, or deleted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func SetupCronJobWebhookWithManager(mgr ctrl.Manager) error {

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

// +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
// +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

// CronJobCustomDefaulter struct is responsible for setting default values on the custom resource of the
// Kind CronJob when those are created or updated.
Expand Down Expand Up @@ -90,7 +90,7 @@ func (d *CronJobCustomDefaulter) Default(ctx context.Context, obj runtime.Object
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
// +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
// +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

// CronJobCustomValidator struct is responsible for validating the CronJob resource
// when it is created, updated, or deleted.
Expand Down
Loading

0 comments on commit 5a21ec1

Please sign in to comment.