Decouple webhook and manager packages #190
Labels
kind/feature
Categorizes issue or PR as related to a new feature.
priority/important-longterm
Important over the long term, but may not be staffed and/or may need multiple releases to complete.
Context
I'm currently integrating multicluster-controller with controller-runtime's webhook package, which, unfortunately, depends on the manager package.
Multicluster-controller doesn't use controller-runtime's manager package, but a more lightweight version that only orchestrates runnables (caches and controllers), while the cluster dependencies are extracted into multiple Cluster structs.
Problem
Controller-runtime's webhook package depends on the manager.Manager interface, even though it only needs a fraction of it, namely Add(Runnable) for the server, and GetScheme() and GetRESTMapper() for the builder.
I could create an ad-hoc implementation of manager.Manager on my side, with lots of panics in the methods webhook doesn't need, forwarding the three that are actually needed to a multicluster-controller manager and cluster, but I believe there is a cleaner solution, which could also benefit others.
Proposed Solution
Define small interfaces where they're needed. They will be implemented implicitly by controller-runtime's controllerManager struct, and could be implemented by third-party packages.
It should also make testing easier, and would be arguably more idiomatic: https://blog.chewxy.com/2018/03/18/golang-interfaces/
If you agree to this proposed change, I can submit a PR.
The text was updated successfully, but these errors were encountered: