Skip to content

Conversation

twobiers
Copy link
Contributor

Description of your changes

Fixes #225

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

Running unit tests

Copy link
Member

@jbw976 jbw976 left a comment

Choose a reason for hiding this comment

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

Thanks for taking the initiative on this @twobiers!

Would you also be up for taking this update for a test drive in building a function, e.g. building on what's in https://docs.crossplane.io/v2.0/guides/write-a-composition-function-in-go/, to see if everything is working as expected there for namespaced resources? That would be really helpful 🙏

@haarchri
Copy link

haarchri commented Oct 7, 2025

@twobiers did you get a chance to check if your PR works with the linked docs?

@bakito
Copy link

bakito commented Oct 7, 2025

I was able to successfully test this version (redirect to twobiers:v2) of the function sdk in some internal functions with namespaced and cluster scoped resource functions.

@haarchri
Copy link

haarchri commented Oct 7, 2025

@jbw976 can we bring this in and cut a new release ?

@twobiers
Copy link
Contributor Author

twobiers commented Oct 7, 2025

@twobiers did you get a chance to check if your PR works with the linked docs?

No, I didn't have enough capacity yet for a full trial. If anyone wants to take this PR over, feel free to do so.

@jbw976
Copy link
Member

jbw976 commented Oct 8, 2025

If anyone wants to take this PR over, feel free to do so.

Thanks for your efforts so far @twobiers! and thank you @bakito for your testing validation, really helpful! 🙇‍♂️

I rebased this PR from latest on main to fix merge conflicts, mostly around the removal of provider-aws dependency in #224. I also bumped go to v1.24.8 and golangci-lint to v2.4.0 consistently across Makefile and ci.yml.

I've done some testing using some local replace statements in a go.mod, but I also want to build/push/install a package to test the full lifecycle of a function doing v2 stuff on a live control plane too before calling this good ✅

@haarchri
Copy link

@jbw976 can we merge the PR then ?

@jbw976
Copy link
Member

jbw976 commented Oct 14, 2025

Just resolved more merge conflicts now - @haarchri will add some details for how he's tested this PR as well 💪

@jbw976 jbw976 marked this pull request as ready for review October 14, 2025 19:25
Copy link

coderabbitai bot commented Oct 14, 2025

📝 Walkthrough

Walkthrough

Upgrades dependencies and imports to crossplane-runtime v2, adjusts CI/lint tooling versions and config, removes two PublishConnectionDetailsTo methods from composed and composite resources, adds a test for namespace-scoped required resources, and switches listener creation to net.ListenConfig in SDK and tests.

Changes

Cohort / File(s) Summary
CI workflow versions
.github/workflows/ci.yml
Bump GO_VERSION to 1.24.8 and GOLANGCI_VERSION to v2.4.0.
Lint/config updates
.golangci.yml
Switch quote style to double quotes; update gci prefixes to v2 crossplane-runtime path.
Errors package minor edits
errors/errors.go, errors/errors_test.go
Update comment source and test import paths to crossplane-runtime/v2. No functional changes.
Logging package v2 import
logging/logging.go
Update import and comments to crossplane-runtime/v2. Public type alias continues to reference v2 logging.Logger.
Composed resource v2 + API removal
resource/composed/composed.go
Migrate imports to crossplane-runtime/v2; remove GetPublishConnectionDetailsTo and SetPublishConnectionDetailsTo methods.
Composite resource v2 + API removal
resource/composite/composite.go
Migrate imports to crossplane-runtime/v2; remove GetPublishConnectionDetailsTo and SetPublishConnectionDetailsTo methods.
Resource tests import updates
resource/composite/composite_test.go, resource/composed/testresource_test.go
Update imports to crossplane-runtime/v2 packages; no logic changes.
Request test enhancement
request/request_test.go
Add test ensuring namespace is preserved for namespace-scoped RequiredResources.
SDK listener change
sdk.go, sdk_test.go
Replace net.Listen with net.ListenConfig.Listen using context; same error handling and behavior.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant SDK as SDK Server
  participant Net as net.ListenConfig

  User->>SDK: Start(options)
  SDK->>Net: Listen(ctx, so.Network, so.Address)
  alt listen ok
    Net-->>SDK: net.Listener
    SDK-->>User: Running with listener
  else error
    Net-->>SDK: error
    SDK-->>User: return error
  end
Loading
sequenceDiagram
  autonumber
  participant Fn as Function Logic
  participant RR as RequiredResources
  participant U as Unstructured

  Fn->>RR: GetRequiredResources()
  RR-->>Fn: items with {apiVersion, kind, metadata.name[, metadata.namespace]}
  loop for each item
    Fn->>U: Build Unstructured
    note right of U: Preserve metadata.name<br/>and metadata.namespace if present
  end
  Fn-->>Fn: Return []Unstructured
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Thanks for driving the v2 migration. Two quick confirmations:

  • Is removal of PublishConnectionDetailsTo methods intentional for v2 compatibility?
  • Any downstream projects relying on those methods that need migration notes?

Pre-merge checks

❌ Failed checks (1 error, 1 warning)
Check name Status Explanation Resolution
Breaking Changes ❌ Error The pull request removes the public methods GetPublishConnectionDetailsTo and SetPublishConnectionDetailsTo from the Unstructured types in both the composite and composed packages, which alters the public API and constitutes an unlabelled breaking change. Please add the ‘breaking-change’ label to this PR to acknowledge the removal of these public methods and update any relevant documentation or migration guides to help users adapt to this API change.
Out of Scope Changes Check ⚠️ Warning The PR includes updates to the CI workflow’s Go and golangci-lint version pins and formatting rule configurations, which are not directly required by the crossplane-runtime v2 upgrade objective. Consider splitting the CI and linter version bump changes into a separate PR to keep the runtime upgrade focused solely on crossplane-runtime v2 integration.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title “Update to crossplane-runtime v2.0.0” is concise, under 72 characters, and clearly describes the main change of bumping the crossplane-runtime dependency to version 2.0.0.
Linked Issues Check ✅ Passed The changes uniformly update import paths and API references to crossplane-runtime v2 across the codebase and add a test case to verify namespace-scoped resources, directly fulfilling the objectives of issue #225.
Description Check ✅ Passed The pull request description references the linked issue (#225), outlines the high-level purpose of upgrading the runtime version, and confirms that unit tests were run, making it directly related to the changeset.

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae69ce6 and cea10f4.

⛔ Files ignored due to path filters (5)
  • Makefile is excluded by none and included by none
  • go.mod is excluded by none and included by none
  • go.sum is excluded by !**/*.sum and included by none
  • proto/v1/run_function.pb.go is excluded by !**/*.pb.go, !**/*.pb.go and included by **/*.go
  • proto/v1beta1/run_function.pb.go is excluded by !**/*.pb.go, !**/*.pb.go and included by **/*.go
📒 Files selected for processing (12)
  • .github/workflows/ci.yml (1 hunks)
  • .golangci.yml (3 hunks)
  • errors/errors.go (1 hunks)
  • errors/errors_test.go (1 hunks)
  • logging/logging.go (2 hunks)
  • request/request_test.go (1 hunks)
  • resource/composed/composed.go (1 hunks)
  • resource/composed/testresource_test.go (1 hunks)
  • resource/composite/composite.go (1 hunks)
  • resource/composite/composite_test.go (1 hunks)
  • sdk.go (1 hunks)
  • sdk_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

⚙️ CodeRabbit configuration file

**/*.go: Enforce Crossplane-specific patterns: Use function-sdk-go/errors
for wrapping. Check variable naming (short for local scope, descriptive
for wider scope). Ensure 'return early' pattern. Verify error scoping
(declare in conditionals when possible). For nolint directives, require
specific linter names and explanations. CRITICAL: Ensure all error
messages are meaningful to end users, not just developers - avoid
technical jargon, include context about what the user was trying to do,
and suggest next steps when possible.

Files:

  • errors/errors_test.go
  • sdk.go
  • errors/errors.go
  • resource/composite/composite.go
  • sdk_test.go
  • resource/composed/testresource_test.go
  • resource/composite/composite_test.go
  • resource/composed/composed.go
  • logging/logging.go
  • request/request_test.go
**/*_test.go

⚙️ CodeRabbit configuration file

**/*_test.go: Enforce table-driven test structure: PascalCase test names (no
underscores), args/want pattern, use cmp.Diff with
cmpopts.EquateErrors() for error testing. Check for proper test case
naming and reason fields. Ensure no third-party test frameworks (no
Ginkgo, Gomega, Testify).

Files:

  • errors/errors_test.go
  • sdk_test.go
  • resource/composed/testresource_test.go
  • resource/composite/composite_test.go
  • request/request_test.go
🧬 Code graph analysis (1)
request/request_test.go (2)
proto/v1/run_function.pb.go (9)
  • RunFunctionRequest (269-321)
  • RunFunctionRequest (334-334)
  • RunFunctionRequest (349-351)
  • Resources (526-531)
  • Resources (544-544)
  • Resources (559-561)
  • Resource (1072-1121)
  • Resource (1134-1134)
  • Resource (1149-1151)
resource/resource.go (2)
  • MustStructJSON (151-157)
  • Required (58-60)
🔇 Additional comments (13)
.golangci.yml (1)

244-247: Nice catch aligning the gci prefix.

Thanks for updating the formatter prefix to the /v2 path—this keeps gofmt/gci runs in sync with the new module layout after the runtime upgrade. Looks good to me.

.github/workflows/ci.yml (1)

13-14: Double-check version availability before merging

Have we confirmed that Go 1.24.8 and golangci-lint v2.4.0 are published and downloadable? If either tag isn’t live yet, these jobs will start failing as soon as the workflow runs. Could you please double-check the upstream release pages (and maybe copy a link back for posterity)? Thanks for bumping the toolchain, just want to ensure the CI stays green.

errors/errors.go (1)

19-20: Documentation accurately reflects the v2 upgrade.

The comment correctly updates the source reference to the v2 module path, aligning with the PR's objective to upgrade to crossplane-runtime v2.0.0.

logging/logging.go (2)

19-20: Documentation correctly updated for v2 migration.

The comment accurately reflects the new v2 import path while maintaining the note about potential future divergence. Nice touch keeping the documentation in sync with the implementation.


28-28: LGTM! Import path correctly updated to v2.

The import path change aligns with crossplane-runtime v2 module requirements. The proxy pattern remains intact—all function signatures are unchanged and continue delegating to the v2 logging package, maintaining backward compatibility for callers of this package.

Based on learnings

errors/errors_test.go (1)

24-24: LGTM! Clean v2 import path update.

The import path has been correctly updated to use crossplane-runtime v2.

resource/composite/composite_test.go (1)

26-26: LGTM! Clean v2 import path update.

The fieldpath import has been correctly updated to use crossplane-runtime v2.

sdk_test.go (1)

365-366: LGTM! Improved port binding with context support.

The switch from direct net.Listen to ListenConfig.Listen with an explicit context is a good practice that provides better control and cancellation support.

sdk.go (1)

198-199: LGTM! Improved listener creation with context support.

The migration to ListenConfig.Listen with an explicit context enhances control over the listening socket and aligns with the same pattern used in tests.

resource/composed/testresource_test.go (1)

25-25: LGTM! Clean v2 import path update.

The import has been correctly updated to use crossplane-runtime v2 while maintaining the v1 alias for the API version.

request/request_test.go (1)

345-383: LGTM! Excellent test coverage for namespace-scoped resources.

This test case properly verifies that namespace metadata is preserved when processing namespace-scoped required resources, which aligns with the v2 support for namespaced resources. The test follows the established table-driven pattern.

resource/composed/composed.go (1)

26-28: Verify removal of PublishConnectionDetailsTo methods All Crossplane runtime imports have been updated to v2. I didn’t find any usages of the removed GetPublishConnectionDetailsTo/SetPublishConnectionDetailsTo methods—please double-check they aren’t referenced elsewhere.

resource/composite/composite.go (1)

30-33: Removed PublishConnectionDetailsTo methods aren’t referenced anywhere. Search across the codebase found no occurrences of GetPublishConnectionDetailsTo or SetPublishConnectionDetailsTo outside of composite.go.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@jbw976 jbw976 left a comment

Choose a reason for hiding this comment

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

I was able to build a quick test function that uses the updates in this branch: https://github.com/jbw976/function-v2-test

That function just does the very basic action of returning a variable number of desired ConfigMap resources (which are namespaced). I was able to build and test this function in a live cluster and verify the expected resources are created when the function runs.

The changes in this PR look good to me! Thanks again for your initiative and effort @twobiers and @bakito @haarchri for also helping test 🙇‍♂️

@jbw976 jbw976 merged commit 33787d6 into crossplane:main Oct 19, 2025
10 checks passed
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.

Upgrade to crossplane-runtime v2

4 participants