-
-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: print consistent json/yaml output #1094
fix: print consistent json/yaml output #1094
Conversation
Hi @devholic , thanks for opening this PR! 👍 |
Sure 🙂 |
k3d-io#1094 (comment) Signed-off-by: Sunghoon Kang <[email protected]>
b11130a
to
3099004
Compare
@iwilltry42 I squashed commit, but you can check changelogs at devholic/k3d@main...devholic:k3d:cluster-list-consistent-output-patch 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you very much! |
Currently, some commands (e.g. `k3d cluster list` or `k3d cluster get`) prints differently per output option (`json` / `yaml`). This behavior may break interoperability and can make users hard to figure out the difference between outputs. This commit fixes this issue by replacing `gopkg.in/yaml.v2` with `sigs.k8s.io/yaml`, which converts the json-encoded struct to yaml. Signed-off-by: Sunghoon Kang <[email protected]>
3099004
to
aac3455
Compare
I found that devholic/k3d@b11130a...devholic:k3d:cluster-list-consistent-output-patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Tests passed ✔️
Sorry for the late review! Thanks for this addition :) |
@all-contributors please add @devholic for code |
I've put up a pull request to add @devholic! 🎉 |
What
Print consistent output for commands.
Why
Currently, some commands (e.g.
k3d cluster list
ork3d cluster get
) prints differently per output option (json
/yaml
). This behavior may break interoperability and can make users hard to figure out the difference between outputs.Changes
Replace
gopkg.in/yaml.v2
withsigs.k8s.io/yaml
, which converts the json-encoded struct to yaml.(
sigs.k8s.io/yaml
is a wrapper forgopkg.in/yaml.v2
- https://github.com/kubernetes-sigs/yaml/blob/b5bdf49df8aeb9756eee686adc7b4a6b3640bc14/yaml.go#L30-L38)Implications
Commands will print same struct for both
json
/yaml
output options.This change may breaks previous behavior, since this commit removes
yaml
tag from structs.Open Questions
I think it would be better to use either
gopkg.in/yaml.v2
orsigs.k8s.io/yaml
only across the repository for consistency, and there is an advantage that we don't have to addyaml
tags to struct fields. WDYT?