Skip to content

Treat all maps & slices of zero-length equal whether they are nil or not in managed.APISimpleReferenceResolver #617

@ulucinar

Description

@ulucinar

What happened?

Here, the managed.APISimpleReferenceResolver does not consider nil maps & slices as being equal to empty maps or slices. Because in the context of reference resolution, the target referencer fields being set (e.g., Ref fields, if a label selector is specified, and the reference target fields) are semantically equal if they are nil or if they are empty, we had better treat them as equals when doing a comparison. This will prevent unnecessary apply operations when the comparison finds a nil map or slice not equal to an empty one. Using the cmpopts.EquateEmpty() should improve this.

How can we reproduce it?

This behavior can be invoked, for example, by specifying a label selector for a cross-resource reference field when the resolution is not done yet (e.g., the referenced MRs do not exist or not ready yet).

What environment did it happen in?

Crossplane version: 1.14.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions