feat(cli): openctl plan — batch $ref dependency preview (K7)#151
Merged
Conversation
New `openctl plan -f <files|dirs>`: load a set of manifests and preview the apply order derived from their $ref markers, before any apply and with no controller connection. - internal/plan: pure package that builds the cross-resource dependency graph via refs.Collect (keyed on the full apiVersion|kind|name triple), topologically sorts it (Kahn) into WAVES — resources in a wave have no inter-dependency and can apply concurrently — records each node's direct deps and any $ref targets outside the set (must already exist), and errors on a cycle (naming the stuck resources). - internal/cli/plan.go: the command + a batch loader that walks dirs recursively and dispatches .cue → LoadCUE, .yaml/.yml → LoadMultiple. Validated by planning the shipped examples/homelab/ set (11 resources → 2 waves: cluster+tunnel, then everything that $refs them). Remaining (tracked): per-resource dry-run --diff is server-only (needs the controller's DryRunApply), plus a batch RPC to expose the DAG to the UI. Pairs with I1 (plan-on-PR). Tests: chain/diamond/external-ref/cycle/duplicate/same-kind-name-distinct- apiVersion/no-refs, plus the batch loader (dir walk, multi-doc, bad ext, missing path) and rendered output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
K7 — batch plan-preview (
openctl plan)Adds
openctl plan -f <files|dirs>: load a set of manifests and preview the apply order derived from their$refmarkers — what will happen, in what order, and what waits on what — before any apply, with no controller connection.How
internal/plan— a pure package that builds the cross-resource dependency graph via the samerefs.Collectprimitive the dispatcher uses (keyed on the fullapiVersion|kind|nametriple, so same-Kind/Name across providers don't collide), topologically sorts it (Kahn) into waves — resources in a wave have no inter-dependency and can apply concurrently — records each node's direct deps and any$reftargets outside the set (must already exist), and errors on a dependency cycle naming the stuck resources.internal/cli/plan.go— the command plus a batch loader that walks directories recursively and dispatches.cue→LoadCUE,.yaml/.yml→LoadMultiple.Verification
examples/homelab/set (11 resources → 2 waves).Remaining (tracked in ROADMAP)
--diffis server-only (needs the controller'sDryRunApply: drift vs stored last-applied + live providerGet) — deferred.Local CI: build,
go test ./...(+-raceon plan), gofmt, vet, staticcheck, golangci-lint (0 issues), modernize — all green.