kubernetes-sigs / cluster-api-provider-vsphere

Apache License 2.0
373 stars 294 forks source link

Use generics for functions used in controller-runtime's builders #3150

Open chrischdi opened 3 months ago

chrischdi commented 3 months ago

/kind cleanup /help

Describe the solution you'd like [A clear and concise description of what you want to happen.]

When using the builder from cotnroller runtime (Setup functions for AddToManager) we should migrate to use generics.

Anything else you would like to add: [Miscellaneous information that will assist in solving the issue.]

Follow-up from https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/pull/3146#discussion_r1713598349

Environment:

k8s-ci-robot commented 3 months ago

@chrischdi: This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed by commenting with the /remove-help command.

In response to [this](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/issues/3150): >/kind cleanup >/help > >**Describe the solution you'd like** >[A clear and concise description of what you want to happen.] > >When using the builder from cotnroller runtime (Setup functions for `AddToManager`) we should migrate to use generics. > >**Anything else you would like to add:** >[Miscellaneous information that will assist in solving the issue.] > > >Follow-up from >https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/pull/3146#discussion_r1713598349 > >**Environment:** > >- Cluster-api-provider-vsphere version: >- Kubernetes version: (use `kubectl version`): >- OS (e.g. from `/etc/os-release`): Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
sbueringer commented 3 months ago

Note: It's enough to do this only in cases where we are actually using the types (vs. just using client.Object).

One example would be: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/204790fdf003ddd714537f3e7a47b82c4335c083/controllers/vmware/vspherecluster_reconciler.go#L338 Here we are actually using VSphereMachine, there are also cases where we just use client.Object, in these cases there would be no benefit to moving to generics