Skip to content

[deckhouse-cli] Add -o output format flag to module values#406

Open
Glitchy-Sheep wants to merge 4 commits into
mainfrom
feat/reading-values-alias
Open

[deckhouse-cli] Add -o output format flag to module values#406
Glitchy-Sheep wants to merge 4 commits into
mainfrom
feat/reading-values-alias

Conversation

@Glitchy-Sheep

@Glitchy-Sheep Glitchy-Sheep commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • d8 s module values/list/snapshots always printed YAML, with no way to ask for JSON.
  • This adds -o/--output (yaml|json) to all three, closing #154.
  • The docs can now suggest d8 s module values XXX -o json instead of the long d8 k -n d8-system exec svc/deckhouse-leader -c deckhouse -- deckhouse-controller module values XXX -o json.

How it works

  • These commands run curl against the addon-operator debug API inside the deckhouse pod.
  • That API picks the response format from the path extension (values.yaml vs values.json).
  • So the flag value maps straight into the request path, no local re-serialization.
  • New helper utilk8s.GetOutputFormat reads --output and validates it against the accepted formats. It pairs with the existing utilk8s.AddOutputFlag.

Before / After

Before: d8 s module values user-authn only prints YAML.
After: d8 s module values user-authn -o json prints JSON; no flag keeps the old YAML default.

2026-07-15 AT 11 37@2x 2026-07-15 AT 11 36@2x

Notes

  • text is not offered for module 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.
  • Two small fixes came along in the touched files:
    • module list no longer registers the stray --editor flag it never used.
    • module snapshots now requires the module name argument instead of panicking when called without it.

Tests

  • TestGetOutputFormat covers the default value, an explicit allowed format, an unsupported format, and a command with no output flag registered.
  • Manual run against a live cluster: values, list and snapshots with -o json return JSON; without the flag they return the previous YAML; -o xml is rejected before any cluster call.

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>
@Glitchy-Sheep Glitchy-Sheep self-assigned this Jul 15, 2026
@Glitchy-Sheep Glitchy-Sheep added the enhancement New feature or request label Jul 15, 2026
@Glitchy-Sheep
Glitchy-Sheep marked this pull request as ready for review July 15, 2026 08:39
@Glitchy-Sheep
Glitchy-Sheep requested a review from ldmonster as a code owner July 15, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant