crossplane-runtime
crossplane-runtime copied to clipboard
Avoid corev1.ObjectReference and LocalObjectReference
What problem are you facing?
Most inter-resource references in Crossplane are either an ObjectReference or a LocalObjectReference. ObjectReference contains many optional fields (e.g. UID, FieldPath, etc) that Crossplane never uses. This could be misleading to users, since some fields (i.e. Name) are always optional, and it's not obvious that the other fields are frequently not required when reading the API documentation or CRD specs. The same is true for LocalObjectReference, which exposes only one field - name - that is (for some reason that is not obvious to me) marked optional.
How could Crossplane help solve your problem?
Crossplane could use purpose-specific references that represent a subset of ObjectReference. This is compliant with the API conventions, which state:
Object references should either be called fooName if referring to an object of kind Foo by just the name (within the current namespace, if a namespaced resource), or should be called fooRef, and should contain a subset of the fields of the ObjectReference type.
A related issue: https://github.com/kubernetes-sigs/service-catalog/issues/1411. I strongly recommend clicking through for context - @deads2k (SIG API Machinery chair) explains in more detail how and why ObjectReference is inappropriate.
I agree. A PR that implements all meta methods we have that are built on this object for other reference types we have could be helpful for adoption.
The refactor should include the interfaces where corev1.ObjectReference is accepted as parameter, too, like SetCompositionReference(*corev1.ObjectReference) etc.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.