Skip to content

refactor(simulate): move resource simulate's planning and diff server lifecycle into internal/simulate - #479

Merged
jcogilvie merged 1 commit into
crossplane:mainfrom
jcogilvie:jco-extract-resource-simulate
Oct 30, 2026
Merged

jcogilvie merged 1 commit into
crossplane:mainfrom
jcogilvie:jco-extract-resource-simulate

Conversation

@jcogilvie

@jcogilvie jcogilvie commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description of your changes

Summary

A pure code move with no behaviour change. crossplane resource simulate keeps the same output, flags, help and exit codes.

Why

project simulate (#436) needs the same diff server lifecycle, per-resource planning and kubeconfig handling. If the code moves into shared packages first, #436's diff for these files shows only its new behaviour, not about 1.2k lines of moved code.

What changed

  • internal/simulate/simulate.go: Router, Planner / NewPlanner / Plan (this was Cmd.simulateOne; the object store and CRD defaults caches now live inside the Planner), fetchLive, the object store cache, providerConfigMapping, RelevantProviderImages.
  • internal/simulate/servers.go: the runtime annotation constants, EnsureServers / StopServers (the start-behind-spinner, skipped-report and cleanup code from Run), ImageConfigs, NeedsDocker, LoadProviderInputs, LoadImageConfigs.
  • internal/simulate/defaults.go: moved with git mv, unchanged.
  • internal/kube/config.go: RESTConfig, the kubeconfig, impersonation and QPS/Burst setup from setupKubeClient, with a new unit test.
  • cmd/crossplane/simulate/simulate.go keeps only the command: flags, help, AfterApply, Run and the client and REST mapper setup.
  • Tests moved to internal/simulate/{simulate,servers}_test.go. The assertions are unchanged; they now call the exported names, and TestSimulateOne is now TestPlanner.

Testing

  • ./nix.sh run .#test and ./nix.sh run .#lint pass.
  • resource simulate --help and the error output for a missing -f file are byte-identical to main's.

Related

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.
  • Linked a PR or a docs tracking issue to document this change. (pure move, no user-facing change)
  • Added backport release-x.y labels to auto-backport this PR.

Need help with this checklist? See the cheat sheet.

🤖 Generated with Claude Code

… lifecycle into internal/simulate

Pure move with no behaviour change. The per-resource planner, provider
discovery, provider-input and image-config loading, diff server start
and stop, and CRD defaulting move from cmd/crossplane/simulate into
internal/simulate. The kubeconfig loading moves into kube.RESTConfig.
The tests move along with the code.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
@coderabbitai

coderabbitai Bot commented Oct 30, 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 59 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 bf5a02b and dd62c0c.

Files selected for processing: 8
  • cmd/crossplane/simulate/simulate.go
  • internal/kube/config.go
  • internal/kube/config_test.go
  • internal/simulate/defaults.go
  • internal/simulate/servers.go
  • internal/simulate/servers_test.go
  • internal/simulate/simulate.go
  • internal/simulate/simulate_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.

@adamwg adamwg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, lgtm.

@jcogilvie
jcogilvie merged commit b3ea83e into crossplane:main Oct 30, 2026
10 of 12 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.

2 participants