[deckhouse-cli] Add -o output format flag to module values#406
Open
Glitchy-Sheep wants to merge 4 commits into
Open
[deckhouse-cli] Add -o output format flag to module values#406Glitchy-Sheep wants to merge 4 commits into
Glitchy-Sheep wants to merge 4 commits into
Conversation
GetOutputFormat pairs with AddOutputFlag: reads the -o/--output flag and validates the value against the accepted formats. Signed-off-by: Roman Berezkin <roman.berezkin@flant.com>
The addon-operator debug API selects the response format by the path extension, so the flag value maps to values.<format>. Signed-off-by: Roman Berezkin <roman.berezkin@flant.com>
Same path-extension mechanism as module values. Also drop the stray --editor flag from list and require the module name argument in snapshots instead of panicking. Signed-off-by: Roman Berezkin <roman.berezkin@flant.com>
- The /module/list debug endpoint matches .text in its route but renders the structured payload as JSON anyway, so a text option would promise one format and deliver another. Signed-off-by: Roman Berezkin <roman.berezkin@flant.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.
Summary
d8 s module values/list/snapshotsalways printed YAML, with no way to ask for JSON.-o/--output(yaml|json) to all three, closing #154.d8 s module values XXX -o jsoninstead of the longd8 k -n d8-system exec svc/deckhouse-leader -c deckhouse -- deckhouse-controller module values XXX -o json.How it works
curlagainst the addon-operator debug API inside the deckhouse pod.values.yamlvsvalues.json).utilk8s.GetOutputFormatreads--outputand validates it against the accepted formats. It pairs with the existingutilk8s.AddOutputFlag.Before / After
Before:
d8 s module values user-authnonly prints YAML.After:
d8 s module values user-authn -o jsonprints JSON; no flag keeps the old YAML default.Notes
textis not offered formodule list. The debug route matches.text, but the handler returns a map that the server renders as JSON anyway, so text would promise one format and deliver another.module listno longer registers the stray--editorflag it never used.module snapshotsnow requires the module name argument instead of panicking when called without it.Tests
TestGetOutputFormatcovers the default value, an explicit allowed format, an unsupported format, and a command with no output flag registered.values,listandsnapshotswith-o jsonreturn JSON; without the flag they return the previous YAML;-o xmlis rejected before any cluster call.