Repo webhook move - #1129
Conversation
✅ Deploy Preview for kpt-porch ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Moves Repository validating webhook responsibility from the centralized apiserver into the repositories controller, aligning architecture with the existing PackageRevision webhook and ensuring distinct ValidatingWebhookConfiguration names.
Changes:
- Removed apiserver-hosted repository webhook implementation and its tests.
- Added controller-runtime admission webhook handler + tests under the repositories controller, and registered it on the controller webhook server.
- Updated controller-gen markers and generated webhook manifests to use unique ValidatingWebhookConfiguration names; adjusted porch-server deployment to stop exposing/setting up webhooks.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/apiserver/webhooks.go | Removes centralized repository webhook server + cert management + conflict logic. |
| pkg/apiserver/webhooks_test.go | Removes tests tied to the deleted apiserver webhook implementation. |
| pkg/apiserver/apiserver.go | Removes webhook setup from porch-server runtime. |
| deployments/porch/3-porch-server.yaml | Removes webhook cert volume/env/port from porch-server deployment. |
| controllers/repositories/pkg/webhooks/repository_webhook.go | Adds RepositoryValidator admission handler + conflict detection helpers. |
| controllers/repositories/pkg/webhooks/repository_webhook_test.go | Adds unit tests for validator handler + conflict helpers. |
| controllers/repositories/pkg/controllers/repository/config.go | Registers repository webhook on the manager webhook server. |
| controllers/repositories/pkg/controllers/repository/repository_controller.go | Adds controller-gen markers to generate a uniquely named ValidatingWebhookConfiguration. |
| controllers/repositories/config/webhook/manifests.yaml | Adds generated ValidatingWebhookConfiguration manifest for repositories. |
| controllers/packagerevisions/pkg/controllers/packagerevision/packagerevision_controller.go | Adds webhookconfiguration marker for unique Packagerevision VWC name generation. |
| controllers/packagerevisions/config/webhook/manifests.yaml | Renames Packagerevision VWC to a unique name in generated manifest. |
| go.mod | Moves fsnotify to indirect (no longer directly used after apiserver webhook removal). |
| .vscode/launch.json | Removes webhook-related env vars from launch configs. |
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
- Use GetAPIReader() instead of GetClient() for strong consistency during admission validation (prevents cache-induced race conditions) - Scope repository list query to namespace level to reduce admission latency at scale - Test UPDATE operation semantics explicitly for the 'updating self' test case - Fix misleading documentation comment to link to actual deployment config All unit tests pass. No lint issues. Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
1e111cc to
280786b
Compare
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
|



Move Repository validating webhook to repository controller
Description
What changed: Moved the Repository validating webhook from the centralized apiserver to the repository controller, mirroring the design already established for the PackageRevision validating webhook. This decouples webhook logic from the apiserver and aligns both webhooks under their respective controller domains.
Why it's needed:
validating-webhook-configuration), only one was being deployed. Now each has a unique name via the//+kubebuilder:webhookconfiguration:marker.How it works:
controllers/repositories/pkg/webhooks/repository_webhook.goconfig.Init()pkg/apiserver/webhooks.go(no longer needed)Related Issue(s)
Type of Change
Checklist
Testing Instructions
make run-in-kind-v1alpha2kubectl get validatingwebhookconfigurations -n porch-systempackagerevision-validating-webhook-configurationandrepository-validating-webhook-configurationporchctl repo add ...Additional Notes
make generateusing controller-gen markers//+kubebuilder:rbac:markersAI Disclosure