Skip to content

Add crossplane project simulate #367

Description

@haarchri

What

Implement crossplane project simulate as an alpha command, per the accepted design (crossplane/cli#181, design/one-pager-cli-simulate.md).
provider plan servers lands separately, until then the command behaves as --skip-plan always.

This includes the groundwork the design bases simulate on: bringing the crossplane-diff machinery into crossplane/cli as internal packages, with its maintainers' involvement, per "Building on crossplane-diff, Not Beside It".

The flow:

  1. Discover. Parse the project file, find Compositions under the project's API paths, list the XRs on the target cluster whose type each Composition composes. --namespace and --name scope the run.
  2. Prepare. Build the project's embedded functions locally, exactly as project run does.
  3. Render. Re-render each XR with the local Composition and functions, feeding in observed composed resources; resolve required resources with the resolver.
  4. Diff. Calculator + server-side dry-run + removal detection.
  5. Report. Per-XR diffs, Plan: N to add, M to change, K to destroy summary, output formats below.

Also in scope, per the design:

  • No-project input mode: -f accepts changed Composition or XR files directly; matching XRs are discovered on the cluster, functions run from the packages installed on the cluster, everything not overridden locally is fetched live.
  • Pinned XRs: compositionUpdatePolicy: Manual XRs print as deferred by default, simulate with --include-pinned. Exception: when the working tree changes an embedded function, pinned XRs are simulated against their pinned CompositionRevision fetched from the cluster with the locally built functions (function packages are not pinned with the revision until Allow composition pipeline steps to reference specific function revisions crossplane#6139).
  • Claims: a claim passed as a changed file is converted to its XR with the CLI's existing conversion machinery and simulated; results print under the claim's name.
  • Output formats: -o plan (annotated manifest, default), -o diff (line-by-line unified diff, Markdown diff-block compatible, what crossplane-diff emits today), -o json|yaml (one typed result per resource).
  • Flags: as in the design's kong struct (minus the plan-layer flags): -f, --namespace, --name, --include-pinned, --max-iterations, --timeout, --max-concurrency, -o.

Acceptance criteria

  • Resolver, calculator, dry-run, and comp discovery live as internal packages in crossplane/cli, with crossplane-diff maintainer agreement on ownership recorded (CODEOWNERS).
  • crossplane project simulate (alpha) previews Composition, embedded function, and XR changes against a live cluster.
  • -f composition.yaml works without a project.
  • Pinned XRs print as deferred with the documented message; the function-change exception simulates them against their pinned revision.
  • Claims convert and simulate; output uses the claim's name.
  • Removed resources appear as deletes; nothing silently disappears from the preview.
  • All formats work; JSON/YAML results are typed and stable enough for CI gating.
  • Cost scales with what is previewed: no cluster-wide work beyond the scoped discovery.

Out of scope

  • Plan servers, --provider-images, --skip-plan, --keep-plan-servers (follow-up issue: plan layer)
  • Replace detection and known-after-apply values (provider knowledge; plan layer)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions