Skip to content

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

Open
phisco wants to merge 1 commit intomainfrom
crossplane-v2
Open

chore: align extra-resources with sdk v0.5.0 and template#86
phisco wants to merge 1 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
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
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.

case reflect.String:
return lessAs[string](a, b)
default:
return false, errors.Errorf("unsupported type %q for sorting", kind)
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.

Using %q with reflect.Kind will not format as intended (it’s not a string/rune), and may produce %!q(...) output. Use %s with kind.String() or %v to produce a clear error (e.g., errors.Errorf(\"unsupported type %s for sorting\", kind) or ...%v...).

Suggested change
return false, errors.Errorf("unsupported type %q for sorting", kind)
return false, errors.Errorf("unsupported type %s for sorting", kind.String())

Copilot uses AI. Check for mistakes.
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.
Comment on lines 181 to 183
// FromFieldPathIsOptional returns true if the FromFieldPathPolicy is set to
// +optional
// Optional.
func (e *ResourceSourceSelectorLabelMatcher) FromFieldPathIsOptional() bool {
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.

The doc comment is now grammatically incomplete across the wrapped lines. Consider making it a single coherent sentence, e.g. "... is set to Optional." so it reads cleanly in GoDoc.

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.

1 participant