Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to DesiredComposedResources and ObservedComposedResources #23

Merged
merged 2 commits into from
Sep 18, 2023

Conversation

negz
Copy link
Member

@negz negz commented Sep 16, 2023

Description of your changes

This makes it possible to mutate struct values while iterating over the map of composed resources. I found myself naturally wanting to do this while writing a Function. e.g.:

desired, _ = request.GetDesiredComposedResources(req)

for _, dr := range desired {
	dr.Ready = resource.ReadyTrue
}

_ = response.SetDesiredComposedResources(desired)

I haven't made the same change for observed resources, since they're supposed to be read-only to a Function.

This PR also removes the DesiredComposedResources and ObservedComposedResources types. I found they were just obfuscating what the types actually were when I tried to use them.

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

These just served to obfuscate what the types actually were - a map of
resource name to observed/desired composed resource structs.

Signed-off-by: Nic Cope <nicc@rk0n.org>
This makes it possible to mutate struct values while iterating over the
map of composed resources. I found myself naturally wanting to do this
while writing a Function. e.g.:

desired, _ = request.GetDesiredComposedResources(req)

for _, dr := range desired {
	dr.Ready = resource.ReadyTrue
}

_ = response.SetDesiredComposedResources(desired)

I haven't made the same change for observed resources, since they're
supposed to be read-only to a Function.

Signed-off-by: Nic Cope <nicc@rk0n.org>
@negz negz requested a review from phisco September 16, 2023 02:07
@negz negz merged commit af486fa into crossplane:main Sep 18, 2023
8 checks passed
@negz negz deleted the maps-how-do-they-work branch September 18, 2023 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant