Skip to content

chore: align extra-resources with sdk v0.5.0 and template#86

Closed
phisco wants to merge 0 commit intomainfrom
crossplane-v2
Closed

chore: align extra-resources with sdk v0.5.0 and template#86
phisco wants to merge 0 commit intomainfrom
crossplane-v2

Conversation

@phisco
Copy link
Collaborator

@phisco phisco commented Feb 13, 2026

Description of your changes

This PR aligns function-extra-resources with the latest function SDK/template direction while preserving the current branch behavior (including namespaced selectors and max receive size support).

Key updates:

  • Migrate request/requirements handling to non-deprecated SDK fields:
    • read from req.RequiredResources
    • use request.GetRequiredResources(...)
    • populate rsp.Requirements.Resources
  • Keep deterministic sorting behavior and replace repetitive casting with typed helpers (lessByKind / lessAs) for safer comparisons.
  • Keep input API/runtime usage on crossplane-runtime/v2.
  • Add package capability metadata:
    • spec.capabilities: [composition]

Rebase/conflict resolution notes:

  • Resolved conflicts by preserving newer branch-side additions (e.g. namespace handling in selectors and MaxRecvMessageSize) and re-applying the SDK migration/sorting improvements.

Validation:

  • go test ./...
  • golangci-lint run

Fixes #

I have:

@phisco phisco requested a review from reedjosh as a code owner February 13, 2026 13:31
@phisco phisco requested a review from Copilot February 13, 2026 14:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Aligns function-extra-resources with the latest function SDK/template conventions while keeping existing branch behavior.

Changes:

  • Adds package capability metadata (spec.capabilities: [composition]).
  • Migrates request/response resource requirement handling to RequiredResources / Requirements.Resources.
  • Refactors deterministic sorting comparisons using typed helpers (lessByKind / lessAs).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
package/crossplane.yaml Declares package capabilities to match current template expectations.
input/v1beta1/resource_select.go Updates an optionality-related comment near selector label matcher logic.
fn.go Migrates to RequiredResources APIs and refactors sorting comparisons with typed helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fn.go Outdated
Comment on lines 258 to 264
less, lessErr := lessByKind(t.Kind(), vali, valj)
if lessErr != nil {
err = lessErr
return false
}
return less
})
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

If lessByKind returns an error once, the sort comparator may continue to be invoked many more times, doing unnecessary work and potentially overwriting err. Add an early guard at the top of the comparator (e.g., if err != nil { return false }) and consider only setting err if it’s currently nil.

Copilot uses AI. Check for mistakes.
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