feat(fxconfig): add --format flag to namespace list with JSON/YAML output#234
Open
pradhyum6144 wants to merge 1 commit into
Open
feat(fxconfig): add --format flag to namespace list with JSON/YAML output#234pradhyum6144 wants to merge 1 commit into
pradhyum6144 wants to merge 1 commit into
Conversation
…tput Adds structured output support to 'fxconfig namespace list' via a new --format flag (json|yaml|table). The table format preserves the existing output for backward compatibility. For json and yaml formats, the command serialises a typed slice whose fields include a decoded policyString alongside the raw policy bytes. Policy decoding is implemented in the CLI layer: - ThresholdRule → base64-encoded public key - MspRule → proto text representation of SignaturePolicyEnvelope - Unknown/invalid → hex fallback The commented-out parsePolicy stub in app/list.go (which had the wrong unmarshal target type — SignaturePolicy instead of SignaturePolicyEnvelope) is removed; the correct implementation now lives in the CLI layer where display concerns belong. Tests added: - JSON output validates structure and field presence - YAML output validates name and version fields - Invalid format returns a descriptive error Signed-off-by: pradhyum6144 <pradhyum314@gmail.com>
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.
Type of change
Description
Adds a
--formatflag (json|yaml|table) tofxconfig namespace list.The default
tableformat preserves the existing output exactly forbackward compatibility.
For
jsonandyaml, the command serialises a typed slice with thefollowing fields per namespace:
nameversionpolicypolicyStringPolicy decoding (
policyString) is implemented in the CLI layer:ThresholdRule→ base64-encoded public keyMspRule→ proto text ofSignaturePolicyEnvelopeThe commented-out
parsePolicystub inapp/list.gois removed. Ittargeted
common.SignaturePolicyrather thancommon.SignaturePolicyEnvelope(the actual type produced by
policydsl.FromString), and used panics forerror handling. The correct implementation now lives in the CLI layer where
display concerns belong.
Additional details (Optional)
Tests added:
TestNewListCommandRunJSON— validates JSON structure and field presenceTestNewListCommandRunYAML— validates name and version fields in YAMLTestNewListCommandRunInvalidFormat— invalid format returns descriptive errorTestNewListCommandRunto usecmd.SetOut(idiomatic Cobra test pattern)All unit tests pass:
go test ./fxconfig/internal/...Lint clean:
golangci-lint run --new-from-rev=origin/main ./fxconfig/...Example usage after this change: