feat(cli): add --output json/yaml to sandbox get, status, and sandbox create#1989
Open
rhuss wants to merge 1 commit into
Open
feat(cli): add --output json/yaml to sandbox get, status, and sandbox create#1989rhuss wants to merge 1 commit into
rhuss wants to merge 1 commit into
Conversation
… create Add structured output support to three commands that previously only supported human-readable table output: - `sandbox get --output json/yaml`: emits sandbox detail including policy source, revision, and active policy content via a new `sandbox_detail_to_json` converter. - `status --output json/yaml`: emits gateway connection state via a new `status_to_json` converter with conditional fields (auth, version, error, http_status) matching the human output. - `sandbox create --output json/yaml`: emits sandbox metadata after the sandbox reaches Ready phase, suppressing spinners and ANSI chrome from stdout. Uploads and port forwarding still execute before output. Clap rejects `--output` combined with `--editor` or trailing commands. All three commands reuse the existing `OutputFormat` enum and `print_output_single` helper. Default output (no --output flag) is byte-identical to current behavior. Unit tests cover both converters. Closes NVIDIA#1964 Assisted-By: 🤖 Claude Code Signed-off-by: Roland Huß <rhuss@redhat.com>
|
All contributors have signed the DCO ✍️ ✅ |
Author
|
I have read the DCO document and I hereby sign the DCO. |
Author
|
recheck |
johntmyers
reviewed
Jun 24, 2026
| println!(" {} {}", "HTTP:".dimmed(), hs); | ||
| } | ||
| if let Some(ref e) = error { | ||
| println!(" {} {}", "gRPC error:".dimmed(), e); |
Collaborator
There was a problem hiding this comment.
This isn't byte-for-byte identical I don't think. If http_health_check() returns None then we used to show Error: ... but now it should hit this arm and will show gRPC error:
johntmyers
reviewed
Jun 24, 2026
Comment on lines
+3505
to
+3508
| let policy_json = config.policy.as_ref().map_or_else( | ||
| || serde_json::Value::Null, | ||
| |p| openshell_policy::sandbox_policy_to_json_value(p).unwrap_or(serde_json::Value::Null), | ||
| ); |
Collaborator
There was a problem hiding this comment.
Is there a reason this does not propagate the conversion error? Other parts do, do we really want to return a null policy if conversion fails?
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.
Summary
Add
--output json/yamltosandbox get,status, andsandbox createso automation and MCP tool wrappers can consume structured data instead of parsing ANSI-colored human output.Related Issue
Closes #1964
Changes
sandbox get --output json/yaml: Newsandbox_detail_to_jsonconverter enriches the existingsandbox_to_jsonwith policy source, revision, and active policy content fromGetSandboxConfigResponse. Usessandbox_policy_to_json_valuefor direct proto-to-JSON conversion.status --output json/yaml: Newstatus_to_jsonconverter emits gateway, server, status, and conditional fields (auth, version, error, http_status). Refactoredgateway_statusto build data before output routing.sandbox create --output json/yaml: Emits sandbox metadata after Ready phase. Human chrome (header, spinner) suppressed from stdout; progress message on stderr. Uploads and port forwarding still execute before output. Clap rejects--outputcombined with--editoror trailing commands.status --output jsonwith no configured gateway emits{"status": "not_configured"}instead of human text.OutputFormatenum andprint_output_singlehelper.--outputflag) is byte-identical to current behavior (verified by diffing raw ANSI output).sandbox get,sandbox create, andstatusinmanage-sandboxes.mdxandmanage-gateways.mdx.Testing
cargo clippyclean,cargo fmtcleancargo test --lib)sandbox_detail_to_jsonandstatus_to_jsonconverterssandbox get --output json,status --output json/yaml, default output byte-identical regression checkChecklist