Add JSON output format for CLI commands

This commit is contained in:
2026-06-01 20:44:27 +00:00
parent 0382978af0
commit e51bc28b05
13 changed files with 849 additions and 48 deletions

View File

@@ -32,6 +32,12 @@ Preview local fan-out publication:
go run ./cmd/distributor run --config examples/fan-out.yml --dry-run
```
Preview a run for automation:
```sh
go run ./cmd/distributor run --config examples/fan-out.yml --dry-run --format json
```
Preview an environment-gated SSH destination config after editing it for an SSH/SFTP endpoint you control:
```sh
@@ -78,6 +84,8 @@ Dry-run output is useful before publishing to confirm actions such as `publish_n
Destination action lines include the destination backend, so mixed local, SSH, and S3 fan-out runs can be audited before publication.
Use `--format json` when another process needs stable run data. JSON output includes warnings, pipeline summaries, destination actions, output records, final counters, and partial failure records. If one destination fails after planning or execution begins, JSON output still contains the successful and failed destination records with `ok: false`, and the command exits non-zero.
## Retry and Replacement Behavior
If a destination has matching `.distributor.json`, publication skips it as already published.
@@ -107,6 +115,8 @@ If one destination fails in a fan-out run, independent later destinations are st
Errors include the pipeline id, destination id, destination backend, and bundle path where applicable.
In JSON mode, destination failures after planning or execution begins are reported in the top-level `errors` array and in the run result while preserving a non-zero exit code. Fatal setup errors such as an unreadable config or invalid secrets directory write no JSON document.
If a write fails during publication, `distributor` attempts to remove outputs written during that failed attempt so a retry does not see those partial outputs as unmanaged destination content.
After a successful publish or replacement, the internal notifier hook runs. The current default notifier is a no-op. Skipped destinations do not invoke it.