Skip to content

0.6.0-0.24.0: use selectors where required, raise Shift functions, and set required defaults #29

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

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

alexander-bauer
Copy link
Contributor

@alexander-bauer alexander-bauer commented Jan 10, 2025

This PR includes a suite of changes I've made while testing this out in practice.

escalation.new(id)
+ escalation.spec.parameters.forProvider.escalationChainRef.withName(self.chainName)
+ escalation.spec.parameters.forProvider.escalationChainSelector.withMatchLabels({
'crossplane.io/claim-name': this.chainName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically, the same claim-name could exist in a different namespace, so this is probably not sufficient in the long run.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a downside of keeping all the logic in jsonnet as opposed to using Crossplane Compositions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't/won't escalationChainRef.withName() work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering myself, the withName() refers to the managed resource, which has a generated name, the withMatchLabels() is better in that regard.

@alexander-bauer alexander-bauer marked this pull request as ready for review January 23, 2025 21:41
@alexander-bauer alexander-bauer requested a review from a team as a code owner January 23, 2025 21:41
@alexander-bauer alexander-bauer changed the title fix(oncall): use selectors rather than refs 0.6.0-0.24.0: use selectors where required, raise Shift functions, and set required defaults Jan 27, 2025
@alexander-bauer alexander-bauer marked this pull request as draft January 27, 2025 19:55
Comment on lines +68 to +71
+ forProvider.shiftsSelector.withMatchLabels(this.scheduleShiftLabels),
shifts: [
// Inject matching labels to identify Shifts as belonging to this Schedule.
raw.oncall.v1alpha1.onCallShift.metadata.withLabels(this.scheduleShiftLabels)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work because the latter sets the labels on the claim resource while selector.matchLabels tells Crossplane to look at the managed resources.

I've got a theoretical solution in the pipeline: 88ae384

The idea is to set a label on the managed resource this way, then let selector.matchLabels find it, however we'll need to verify that the code in Crossplane can actually deal with a selector that returns multiple resources.

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.

2 participants