crossplane-runtime icon indicating copy to clipboard operation
crossplane-runtime copied to clipboard

Avoid corev1.ObjectReference and LocalObjectReference

Open negz opened this issue 6 years ago • 4 comments

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.

negz avatar Oct 13 '19 02:10 negz

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.

negz avatar Nov 22 '19 07:11 negz

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.

muvaf avatar Jun 13 '20 09:06 muvaf

The refactor should include the interfaces where corev1.ObjectReference is accepted as parameter, too, like SetCompositionReference(*corev1.ObjectReference) etc.

muvaf avatar Jun 13 '20 09:06 muvaf

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.

stale[bot] avatar Aug 13 '22 07:08 stale[bot]

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.

github-actions[bot] avatar Sep 05 '24 01:09 github-actions[bot]