Skip to content

Commit 92d01ff

Browse files
📖: Add v2 webhook implementation to multiversion tutorial
The multiversion tutorial webhooks.md was only showing the v1 webhook implementation but not the v2 webhook implementation. This caused confusion as the v2 webhook has different validation logic to handle the structured CronSchedule type instead of a simple string. Updated webhooks.md to show both: - v1 webhook: handles conversion and validates string-based schedule - v2 webhook: validates structured CronSchedule by building cron expression from fields Co-authored-by: camilamacedo86 <[email protected]>
1 parent bca36cc commit 92d01ff

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

docs/book/src/multiversion-tutorial/webhooks.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@
33
Our conversion is in place, so all that's left is to tell
44
controller-runtime about our conversion.
55

6-
## Webhook setup...
6+
## Webhook setup for v1...
7+
8+
The v1 webhook handles conversion (as the hub) and provides validation/defaulting
9+
for the v1 CronJob format with a string-based schedule:
710

811
{{#literatego ./testdata/project/internal/webhook/v1/cronjob_webhook.go}}
912

13+
## Webhook setup for v2...
14+
15+
The v2 webhook provides validation and defaulting for the v2 CronJob format
16+
with the structured CronSchedule type. Note how the validation logic differs
17+
from v1 - it builds a cron expression from the individual schedule fields:
18+
19+
{{#literatego ./testdata/project/internal/webhook/v2/cronjob_webhook.go}}
20+
1021
## ...and `main.go`
1122

1223
Similarly, our existing main file is sufficient:

0 commit comments

Comments
 (0)