Module: Pangea::CLI::Orchestrate
- Defined in:
- lib/pangea/cli/orchestrate.rb
Overview
‘pangea orchestrate <distribution.rb>` — the cross-workspace operator surface (M0.5). Per theory/PANGEA-MAGMA-ORCHESTRATION.md §III.6.
The given Ruby file must define exactly one of:
* `orchestrator` — a Pangea::Magma::Orchestrator instance
* `chain` — a Pangea::Magma::Chain instance
* `distribution` — a Pangea::Magma::Distribution instance
‘pangea orchestrate` then drives `magma flow run` over the resulting chain and prints the parsed AggregateReport JSON.
CLI flags:
--backend <magma|tofu> Backend to dispatch through (default: magma)
--only foo,bar Only reconcile these workspaces
--dry-run Validate + render flow.json; do not run
Class Method Summary collapse
Class Method Details
.run(template_file, backend: nil, only: nil, dry_run: false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/pangea/cli/orchestrate.rb', line 26 def run(template_file, backend: nil, only: nil, dry_run: false) backend ||= 'magma' orch_or_chain = load_template(template_file) chain = case orch_or_chain when Pangea::Magma::Stack orch_or_chain.chain when Pangea::Magma::Orchestrator distribution = orch_or_chain.distribution distribution.to_chain when Pangea::Magma::Chain orch_or_chain when Pangea::Magma::Distribution orch_or_chain.to_chain else raise ArgumentError, "#{template_file} did not define `stack`, " \ "`orchestrator`, `chain`, or `distribution` at " \ "top level; got #{orch_or_chain.class}" end chain = subset_chain(chain, only) if only && !only.empty? if dry_run puts JSON.pretty_generate( backend: backend, chain: chain.to_h, note: 'dry-run: nothing executed; pass without --dry-run to drive backend', ) return end unless backend == 'magma' raise NotImplementedError, "pangea orchestrate currently dispatches through magma only " \ "(got --backend=#{backend}); tofu backend lands once tofu " \ "exposes a workspace-chain primitive (planned M0.5.x)" end report = chain.reconcile_all puts JSON.pretty_generate(report) end |