This PR adds a validating webhook for dynamically validating Connections on correctness. In the webhook the following is executed:
Find the ConnectionType associated with the Connection
Validate the Connection with the ConnectionType
Return any potential errors
There is sadly a limitation to the validation: ValueFrom references (e.g. ConfigMaps, Secrets) can't be validated against the rules. However we can still validate whether the Connection does not contain any invalid fields.
Testing took some effort for the webhook, as at a first glance it was quite hard to set up locally (you can see some of my earlier attempts in the commits still, inspired by this blog). However, it turned out that the latest version of controller-runtime has support for Webhook tests, which was perfect!
There where some other bug fixes I needed to do to get it all working:
Registering the ConnectionType and ConnectionTypeList
+kubebuilder:object:root=true vs +kubebuilder:object:Root=true
This PR adds a validating webhook for dynamically validating Connections on correctness. In the webhook the following is executed:
There is sadly a limitation to the validation: ValueFrom references (e.g. ConfigMaps, Secrets) can't be validated against the rules. However we can still validate whether the Connection does not contain any invalid fields.
Testing took some effort for the webhook, as at a first glance it was quite hard to set up locally (you can see some of my earlier attempts in the commits still, inspired by this blog). However, it turned out that the latest version of controller-runtime has support for Webhook tests, which was perfect!
There where some other bug fixes I needed to do to get it all working:
+kubebuilder:object:root=true
vs+kubebuilder:object:Root=true