Calling Builder.For() multiple times loses previous apiTypes #1173
Labels
good first issue
Denotes an issue ready for a new contributor, according to the "help wanted" guidelines.
help wanted
Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
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.
At https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/builder/controller.go#L74 , For latches the apiType of the For() call.
If a controller-runtime consumer calls Builder.For(foo).For(bar), then foo will be silently lost in favour of bar.
This contrasts with Owns' behaviour, where Builder.Owns(foo).Owns(bar) will append both foo and bar to an internal slice.
Judging by the code comment on For (
For defines the type of Object being *reconciled*
), it may not be intended for For to be called multiple times on a Builder. Nonetheless, the current behaviour can be confusing.As a workaround, a consumer who wants to watch multiple apiTypes can use Watches(foo).Watches(bar) instead.
IMO it would be nice to make the behaviour here clearer, either:
The text was updated successfully, but these errors were encountered: