Skip to content

feat(cli): add JSON/YAML output format to provider list command#1830

Open
jeffmaury wants to merge 1 commit into
NVIDIA:mainfrom
jeffmaury:feat/1745-add-output-format-provider-list/jeffmaury
Open

feat(cli): add JSON/YAML output format to provider list command#1830
jeffmaury wants to merge 1 commit into
NVIDIA:mainfrom
jeffmaury:feat/1745-add-output-format-provider-list/jeffmaury

Conversation

@jeffmaury

Copy link
Copy Markdown
Contributor

🏗️ build-from-issue-agent

Summary

Added -o/--output flag support (json, yaml, table) to openshell provider list by migrating it to use the existing generic output formatter introduced in #1750. This follows the established pattern already used by sandbox list, gateway list, and provider list-profiles commands.

Related Issue

Closes #1745

Changes

  • crates/openshell-cli/src/run.rs: Added provider_to_json() helper function that maps Provider proto fields to JSON, including only credential keys (never values) for security. Added output parameter to provider_list() function and inserted early-return call to crate::output::print_output_collection() for structured formats.
  • crates/openshell-cli/src/main.rs: Added output: OutputFormat field to ProviderCommands::List struct with conflicts_with constraints between names and output flags. Updated invocation to pass output.as_str() parameter.
  • crates/openshell-cli/tests/provider_commands_integration.rs: Updated provider_list() call to include "table" parameter.

Deviations from Plan

None — implemented as planned. The implementation leverages the generic output module (crates/openshell-cli/src/output.rs) that was created as part of #1750, avoiding code duplication.

Testing

  • mise run pre-commit passes (all 778 unit tests passed)
  • Unit tests added/updated
  • E2E tests added/updated (N/A — CLI command formatting does not require E2E coverage)

Tests added:

  • Unit: No new tests required — generic output helpers are already tested in output.rs, and the pattern is proven in production use
  • Integration: Updated existing integration test call signature to pass output parameter
  • E2E: N/A — CLI output formatting does not require E2E coverage

Security verification:
The provider_to_json() helper only exposes credential keys (the keys from the credentials map), never credential values. This prevents CWE-532 (insertion of sensitive information into output) and follows the same security pattern as the provider get command.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

Documentation updated:

  • None needed — this change affects CLI command output format only, not gateway configuration or published user-facing behavior documentation

Closes NVIDIA#1745

Add -o/--output flag support (json, yaml, table) to openshell provider list
by migrating it to use the existing generic output formatter from NVIDIA#1750.
This follows the established pattern used by sandbox list, gateway list,
and provider list-profiles commands.

Changes:
- crates/openshell-cli/src/run.rs: Add provider_to_json() helper that maps
  Provider proto fields to JSON, including only credential keys (not values)
  for security. Add output parameter to provider_list() and insert early-return
  for structured formats.
- crates/openshell-cli/src/main.rs: Add output field to ProviderCommands::List
  with conflicts_with constraints between names and output flags. Update
  invocation to pass output parameter.
- crates/openshell-cli/tests/provider_commands_integration.rs: Update
  provider_list() call to include output parameter.

Security: The provider_to_json() helper only exposes credential keys, never
credential values, preventing CWE-532 (insertion of sensitive information
into output).
@jeffmaury jeffmaury requested a review from a team as a code owner June 9, 2026 07:34
@copy-pr-bot

copy-pr-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add JSON/YAML output format to provider list command

1 participant