-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Render container stats and configs as yaml #444
Conversation
Signed-off-by: Tony-Sol <[email protected]>
Beast. |
@jesseduffield would you please take a look at this? |
Sorry for the late review, I actually much prefer the yaml appearance to the JSON appearance. I'm happy to make it yaml without it being configurable. Could you do that @tony-sol ? |
@jesseduffield mm, maybe just make yaml by default, but keep this setting? |
For rendering in a UI though, I think yaml makes way more sense. k9s for example uses yaml to display pod specs and to my knowledge doesn't offer a way of instead showing it in JSON. I reckon we just switch to yaml and make it configurable if people complain. In general I want to keep configuration to a minimum where possible as it's a maintenance burden |
Nice, let's add that dependency, it's great for readability |
Should i make colors fully customizable, set some pre-configured themes or just hardcode colors? |
hardcode :) |
I see a point of future improvements - make themes or something, to make ui look more smooth and less like christmas tree 😄 |
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.
Could you add a unit test for this?
Accidentally submitted review
pkg/utils/utils.go
Outdated
case "json": | ||
return dataJSON, err | ||
case "yaml": | ||
// Use Unmarshal->Marshal hack to convert vendor-locked objects to YAML with same structure as JSON |
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.
Could you explain a bit more about what's happening here? What do you mean by vendor locked?
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.
Sure, container.Details
declared in vendor/github.com/docker/docker/api/types/stats.go
already has json tags, but not yaml.
So, in order to keep ./vendor/
files consistent and not changed in any inappropriate way, like
-- CPUUsage CPUUsage `json:"cpu_usage"`
++ CPUUsage CPUUsage `json:"cpu_usage" yaml:"cpu_usage"`
and keep the resulting yaml structure exactly as json is, let's at first marshal into json as tagged, then into "any" yaml
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.
Ah, that makes sense. Could you capture that in a comment in the code?
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.
Looking great! Left a couple comments. We also need to scrap the JSON-related code
// Booleans: magenta | ||
// Numbers: yellow | ||
// Strings: green | ||
func ColoredYamlString(str string) string { |
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.
Can you add a unit test for this? (Accidentally just left this as a general comment cos I'm reviewing from phone :) )
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.
@jesseduffield sure, done
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.
And sadly, i don't get about scrapping "the JSON-related code" :c
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.
What I mean is, let's remove DetailsFormat
and always use yaml formatting.
@jesseduffield is everything good?, are we ready for merge?:) |
@tony-sol I've left a couple more comments :) |
`detailsFormat` key removed from config `MarshalIntoFormat` renamed into `marshalIntoFormat` with better description `MarshalIntoYaml` introduced as `marshalIntoFormat` wrapper for common usage
@jesseduffield done 😄 |
Yep that's fine. Merged! Great work on this @tony-sol ! |
json
and yaml
Add optional config
".gui.detailsFormat"
into config file, which provides ability to change output format of container stats and config details.To preserve current behaviour, use
json
as default.Keys and their order are same between
json
andyaml
formats.