[CFX-6308] refactor(workload): wrap workload list JSON in envelope object#613
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit fe31cd9. Configure here.
wojtekwdr
left a comment
There was a problem hiding this comment.
LGTM, fix failing tests
Replace bare JSON array output with PrintJSONEnvelope wrapper so
dr workload list --output-format json outputs
{"workloads": [...]} instead of a bare [...]. Part of CFX-6308.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Fixed on rebase |
fe31cd9 to
4fea51d
Compare
|
/approve-smoke-tests |
|
🔐 Fork PR smoke tests triggered by @ajalon1 What happens next:
|
|
🔐 Fork smoke tests started by maintainer ⏳ Security scans passed. Running smoke tests... Commit: |
|
✅ All smoke tests passed! (Fork PR) ✅ Security Scan: success |
|
/skip-smoke-tests |
|
Skipping bc my only recent change was to unit tests |

Rationale
dr workload list --output-format jsoncurrently emits a bare JSON array:Before:
[ { "id": "wl-001", "name": "my-workload", "status": "running", "type": "custom", "importance": "high", "artifactID": "art-001", "endpoint": "https://...", "createdAt": "2026-04-01T08:00:00Z", "updatedAt": "2026-04-01T08:00:00Z" } ]This PR wraps it in a consistent JSON envelope object using the existing
PrintJSONEnvelopehelper (introduced in #582):After:
{ "workloads": [ { "id": "wl-001", "name": "my-workload", "status": "running", "type": "custom", "importance": "high", "artifactID": "art-001", "endpoint": "https://...", "createdAt": "2026-04-01T08:00:00Z", "updatedAt": "2026-04-01T08:00:00Z" } ] }Changes
internal/workload/output.go: Replacedjson.MarshalIndentinprintWorkloadsJSON()withoutputformat.PrintJSONEnvelope(os.Stdout, "workloads", outputs)Notes
No test changes needed (no existing tests for
printWorkloadsJSON). This is a breaking change for JSON consumers. Please confirm the new shape is acceptable for your integrations. Part of CFX-6308.Note
Medium Risk
Breaking JSON contract for
workload listconsumers; change is localized to list JSON formatting with no auth or data-path impact.Overview
dr workload list --output-format jsonno longer prints a bare array; it now usesoutputformat.PrintJSONEnvelopewith theworkloadskey, matching other list commands (e.g. components, plugins, tasks).In
printWorkloadsJSON, the manualjson.MarshalIndent+fmt.Printlnpath is replaced by a single call toPrintJSONEnvelope(os.Stdout, "workloads", outputs). Single-workload JSON and text/table output are unchanged.This is a breaking change for scripts or integrations that expect a top-level JSON array.
Reviewed by Cursor Bugbot for commit fe31cd9. Configure here.