Automate Uncommenting Webhook Blocks in kustomize.yaml
When Scaffolding Webhooks #4422
Open
Description
What do you want to happen?
Currently, when scaffolding webhooks (default or conversion or validation), users need to manually uncomment the relevant blocks in the config/default/kustomization.yaml
file. This process can be automated to improve the user experience.
Problem
- When scaffolding default webhooks, users must manually uncomment the corresponding sections in the
kustomization.yaml
file. - For conversion webhooks, the injected code requires further manual adjustments to uncomment specific blocks.
- In the e2e tests, the uncommenting is handled via shell scripts (example here), which could be avoided if the tool itself handles this step during scaffolding.
Solution
-
Automate Uncommenting:
- Use the plugin utility methods (plugin/util/util.go) to automate the process of uncommenting code in
kustomization.yaml
during webhook scaffolding. - Update the scaffold logic in:
- Add the required logic to handle default webhooks and conversion webhooks, similar to the example in api.go.
- Use the plugin utility methods (plugin/util/util.go) to automate the process of uncommenting code in
-
Raise Warnings:
- If the tool cannot automatically uncomment the code (e.g., file issues or other constraints), it should raise a warning instead of throwing an error. This ensures the user knows what to fix manually without blocking the workflow.
-
Remove Shell Script Dependencies in CI:
- Remove references in GitHub Actions that use shell scripts to uncomment blocks during e2e tests (example here).
- Update CI workflows to validate the new behavior where the tool handles uncommenting automatically.
Benefits
- Users will no longer need to manually uncomment code in
kustomization.yaml
when scaffolding webhooks. - Cleaner and more automated CI processes.
- Improved developer experience for
kubebuilder
users. - Improve maintainability for our ci
Extra Labels
No response