feat(cli): add JSON/YAML output format to provider list command#1830
Open
jeffmaury wants to merge 1 commit into
Open
feat(cli): add JSON/YAML output format to provider list command#1830jeffmaury wants to merge 1 commit into
jeffmaury wants to merge 1 commit into
Conversation
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).
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
Added
-o/--outputflag support (json, yaml, table) toopenshell provider listby migrating it to use the existing generic output formatter introduced in #1750. This follows the established pattern already used bysandbox list,gateway list, andprovider list-profilescommands.Related Issue
Closes #1745
Changes
crates/openshell-cli/src/run.rs: Addedprovider_to_json()helper function that maps Provider proto fields to JSON, including only credential keys (never values) for security. Addedoutputparameter toprovider_list()function and inserted early-return call tocrate::output::print_output_collection()for structured formats.crates/openshell-cli/src/main.rs: Addedoutput: OutputFormatfield toProviderCommands::Liststruct withconflicts_withconstraints betweennamesandoutputflags. Updated invocation to passoutput.as_str()parameter.crates/openshell-cli/tests/provider_commands_integration.rs: Updatedprovider_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-commitpasses (all 778 unit tests passed)Tests added:
output.rs, and the pattern is proven in production useSecurity 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 theprovider getcommand.Checklist
Documentation updated: