Skip to content

refactor: move shared library code from cmd/crossplane to pkg - #455

Open
jcogilvie wants to merge 6 commits into
crossplane:mainfrom
jcogilvie:jco-move-shared-cmd-to-internal
Open

jcogilvie wants to merge 6 commits into
crossplane:mainfrom
jcogilvie:jco-move-shared-cmd-to-internal

Conversation

@jcogilvie

@jcogilvie jcogilvie commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description of your changes

This moves the shared library code under cmd/crossplane/ into pkg/. Code in internal/ (#436's diff engine, for example) can then use it without importing cmd/, and outside tools get a stable, discoverable import path. This follows the precedent of pkg/validate.

From To
cmd/crossplane/common/crd pkg/crd
cmd/crossplane/common/load (with testutils) pkg/load
cmd/crossplane/common/resource, /xrm, /xpkg pkg/resource, /xrm, /xpkg
cmd/crossplane/render, root package only pkg/render
ConvertClaimToXR and Options from cmd/crossplane/xr/generate.go pkg/xr/claim.go

render xr, render op, render/contextfn and the xr generate command stay in cmd/.

The change is mechanical: git mv plus import-path updates, and two package doc comments reworded. Nothing changes behaviour, and no label, annotation or other string value changes. It's one commit per package, so renames stay detectable and git log --follow keeps working. The xr move takes two commits: the first moves the file whole, so history follows the library code, and the second puts the command half back in cmd/. The tree doesn't build at that first commit, and its commit message says so.

Warning

This changes import paths for modules outside this repo. There are no forwarding packages at the old paths. Known importers: crossplane-contrib/crossplane-diff (render, xr, common/resource, xrm, common/crd) and crossplane-contrib/xprin (render.LoadXRD). Each needs a one-line import change on its next cli/v2 bump.

Raised in review of #436. Whichever of this PR and #436 merges second updates its imports. #436 also edits render/engine*.go and common/load/loader.go, which this PR moves.

Related: #436, #452, #453.

I have:

  • Read and followed Crossplane's contribution process.
  • Run ./nix.sh flake check to ensure this PR is ready for review. (./nix.sh run .#test and ./nix.sh run .#lint pass.)
  • Added or updated unit tests. (pure move; the existing tests move with their packages)
  • Linked a PR or a docs tracking issue to document this change. (no user-facing change)
  • Added backport release-x.y labels to auto-backport this PR.

🤖 Generated with Claude Code

jcogilvie and others added 6 commits October 27, 2026 11:51
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
This is a pure rename so history follows the claim conversion code. The
tree does not build at this commit: pkg/xr/claim.go still holds the
generate command, whose help embed and kong wiring belong in cmd. The
next commit splits the command half back out.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
@jcogilvie
jcogilvie marked this pull request as ready for review October 27, 2026 20:05
@jcogilvie
jcogilvie requested review from a team and tampakrap as code owners October 27, 2026 20:05
@jcogilvie
jcogilvie requested review from phisco and removed request for a team October 27, 2026 20:05
@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 2ca8fd0 and c85bf8b.

Files ignored due to path filters: 9
  • pkg/load/testdata/folder/nested-folder/resource-a.yaml is excluded by !**/testdata/** and included by **/*.yaml
  • pkg/load/testdata/folder/resource-b.yaml is excluded by !**/testdata/** and included by **/*.yaml
  • pkg/load/testdata/resources.yaml is excluded by !**/testdata/** and included by **/*.yaml
  • pkg/render/testdata/composition.yaml is excluded by !**/testdata/** and included by **/*.yaml
  • pkg/render/testdata/extra-resources.yaml is excluded by !**/testdata/** and included by **/*.yaml
  • pkg/render/testdata/functions.yaml is excluded by !**/testdata/** and included by **/*.yaml
  • pkg/render/testdata/observed.yaml is excluded by !**/testdata/** and included by **/*.yaml
  • pkg/render/testdata/xr.yaml is excluded by !**/testdata/** and included by **/*.yaml
  • pkg/render/testdata/xrd.yaml is excluded by !**/testdata/** and included by **/*.yaml
Files selected for processing: 65
  • cmd/crossplane/project/run.go
  • cmd/crossplane/render/op/cmd.go
  • cmd/crossplane/render/op/cmd_test.go
  • cmd/crossplane/render/xr/cmd.go
  • cmd/crossplane/render/xr/cmd_test.go
  • cmd/crossplane/simulate/simulate.go
  • cmd/crossplane/trace/internal/printer/default.go
  • cmd/crossplane/trace/internal/printer/default_test.go
  • cmd/crossplane/trace/internal/printer/dot.go
  • cmd/crossplane/trace/internal/printer/dot_test.go
  • cmd/crossplane/trace/internal/printer/json.go
  • cmd/crossplane/trace/internal/printer/json_test.go
  • cmd/crossplane/trace/internal/printer/printer.go
  • cmd/crossplane/trace/internal/printer/printer_test.go
  • cmd/crossplane/trace/internal/printer/yaml.go
  • cmd/crossplane/trace/internal/printer/yaml_test.go
  • cmd/crossplane/trace/trace.go
  • cmd/crossplane/trace/watch.go
  • cmd/crossplane/validate/cache.go
  • cmd/crossplane/validate/cmd.go
  • cmd/crossplane/validate/image.go
  • cmd/crossplane/xpkg/get_crds.go
  • cmd/crossplane/xr/generate.go
  • cmd/crossplane/xr/patch.go
  • pkg/crd/crd.go
  • pkg/load/loader.go
  • pkg/load/loader_test.go
  • pkg/load/testutils/mocks.go
  • pkg/render/annotation.go
  • pkg/render/context.go
  • pkg/render/convert.go
  • pkg/render/convert_test.go
  • pkg/render/engine.go
  • pkg/render/engine_docker.go
  • pkg/render/engine_docker_test.go
  • pkg/render/engine_local.go
  • pkg/render/engine_local_test.go
  • pkg/render/engine_mock.go
  • pkg/render/load.go
  • pkg/render/load_test.go
  • pkg/render/network.go
  • pkg/render/network_test.go
  • pkg/render/output.go
  • pkg/render/output_test.go
  • pkg/render/render.go
  • pkg/render/render_test.go
  • pkg/render/runtime.go
  • pkg/render/runtime_development.go
  • pkg/render/runtime_docker.go
  • pkg/render/runtime_docker_test.go
  • pkg/render/schemas.go
  • pkg/render/schemas_test.go
  • pkg/render/session_test.go
  • pkg/resource/client.go
  • pkg/resource/resource.go
  • pkg/resource/xpkg/client.go
  • pkg/resource/xpkg/client_test.go
  • pkg/resource/xpkg/xpkg.go
  • pkg/resource/xpkg/xpkg_test.go
  • pkg/resource/xrm/client.go
  • pkg/resource/xrm/client_test.go
  • pkg/resource/xrm/loader.go
  • pkg/resource/xrm/loader_test.go
  • pkg/xr/claim.go
  • pkg/xr/claim_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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