Skip to content

Commit 83a16e5

Browse files
🐛 clarify that webhooks path in the marker should not be changed
1 parent cab5b15 commit 83a16e5

File tree

10 files changed

+21
-0
lines changed

10 files changed

+21
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ Here, however, we just use the same shared validation for `ValidateCreate` and
115115
validate anything on deletion.
116116
*/
117117

118+
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
119+
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
120+
118121
var _ webhook.Validator = &CronJob{}
119122

120123
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type

pkg/plugins/golang/v4/scaffolds/internal/templates/api/webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ func (r *{{ .Resource.Kind }}) Default() {
125125
//nolint:lll
126126
validatingWebhookTemplate = `
127127
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
128+
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
129+
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
128130
//+kubebuilder:webhook:{{ if ne .Resource.Webhooks.WebhookVersion "v1" }}webhookVersions={{"{"}}{{ .Resource.Webhooks.WebhookVersion }}{{"}"}},{{ end }}path=/validate-{{ .QualifiedGroupWithDash }}-{{ .Resource.Version }}-{{ lower .Resource.Kind }},mutating=false,failurePolicy=fail,sideEffects=None,groups={{ .Resource.QualifiedGroup }},resources={{ .Resource.Plural }},verbs=create;update,versions={{ .Resource.Version }},name=v{{ lower .Resource.Kind }}.kb.io,admissionReviewVersions={{ .AdmissionReviewVersions }}
129131
130132
var _ webhook.Validator = &{{ .Resource.Kind }}{}

testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/captain_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ func (r *Captain) Default() {
4848
}
4949

5050
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
51+
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
52+
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
5153
//+kubebuilder:webhook:path=/validate-crew-testproject-org-v1-captain,mutating=false,failurePolicy=fail,sideEffects=None,groups=crew.testproject.org,resources=captains,verbs=create;update,versions=v1,name=vcaptain.kb.io,admissionReviewVersions=v1
5254

5355
var _ webhook.Validator = &Captain{}

testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/cruiser_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ func (r *Cruiser) SetupWebhookWithManager(mgr ctrl.Manager) error {
3737
// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
3838

3939
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
40+
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
41+
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
4042
//+kubebuilder:webhook:path=/validate-ship-testproject-org-v2alpha1-cruiser,mutating=false,failurePolicy=fail,sideEffects=None,groups=ship.testproject.org,resources=cruisers,verbs=create;update,versions=v2alpha1,name=vcruiser.kb.io,admissionReviewVersions=v1
4143

4244
var _ webhook.Validator = &Cruiser{}

testdata/project-v4-multigroup-with-deploy-image/api/v1/lakers_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ func (r *Lakers) Default() {
4848
}
4949

5050
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
51+
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
52+
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
5153
//+kubebuilder:webhook:path=/validate-testproject-org-v1-lakers,mutating=false,failurePolicy=fail,sideEffects=None,groups=testproject.org,resources=lakers,verbs=create;update,versions=v1,name=vlakers.kb.io,admissionReviewVersions=v1
5254

5355
var _ webhook.Validator = &Lakers{}

testdata/project-v4-multigroup/api/crew/v1/captain_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ func (r *Captain) Default() {
4848
}
4949

5050
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
51+
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
52+
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
5153
//+kubebuilder:webhook:path=/validate-crew-testproject-org-v1-captain,mutating=false,failurePolicy=fail,sideEffects=None,groups=crew.testproject.org,resources=captains,verbs=create;update,versions=v1,name=vcaptain.kb.io,admissionReviewVersions=v1
5254

5355
var _ webhook.Validator = &Captain{}

testdata/project-v4-multigroup/api/ship/v2alpha1/cruiser_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ func (r *Cruiser) SetupWebhookWithManager(mgr ctrl.Manager) error {
3737
// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
3838

3939
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
40+
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
41+
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
4042
//+kubebuilder:webhook:path=/validate-ship-testproject-org-v2alpha1-cruiser,mutating=false,failurePolicy=fail,sideEffects=None,groups=ship.testproject.org,resources=cruisers,verbs=create;update,versions=v2alpha1,name=vcruiser.kb.io,admissionReviewVersions=v1
4143

4244
var _ webhook.Validator = &Cruiser{}

testdata/project-v4-multigroup/api/v1/lakers_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ func (r *Lakers) Default() {
4848
}
4949

5050
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
51+
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
52+
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
5153
//+kubebuilder:webhook:path=/validate-testproject-org-v1-lakers,mutating=false,failurePolicy=fail,sideEffects=None,groups=testproject.org,resources=lakers,verbs=create;update,versions=v1,name=vlakers.kb.io,admissionReviewVersions=v1
5254

5355
var _ webhook.Validator = &Lakers{}

testdata/project-v4-with-deploy-image/api/v1alpha1/memcached_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ func (r *Memcached) SetupWebhookWithManager(mgr ctrl.Manager) error {
3737
// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
3838

3939
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
40+
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
41+
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
4042
//+kubebuilder:webhook:path=/validate-example-com-testproject-org-v1alpha1-memcached,mutating=false,failurePolicy=fail,sideEffects=None,groups=example.com.testproject.org,resources=memcacheds,verbs=create;update,versions=v1alpha1,name=vmemcached.kb.io,admissionReviewVersions=v1
4143

4244
var _ webhook.Validator = &Memcached{}

testdata/project-v4/api/v1/captain_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ func (r *Captain) Default() {
4848
}
4949

5050
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
51+
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
52+
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
5153
//+kubebuilder:webhook:path=/validate-crew-testproject-org-v1-captain,mutating=false,failurePolicy=fail,sideEffects=None,groups=crew.testproject.org,resources=captains,verbs=create;update,versions=v1,name=vcaptain.kb.io,admissionReviewVersions=v1
5254

5355
var _ webhook.Validator = &Captain{}

0 commit comments

Comments
 (0)