-
Notifications
You must be signed in to change notification settings - Fork 2.1k
cli/command/system: define struct for formatting version #6648
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
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
The client.ServerVersion method in the moby/client module defines an output struct that's separate from the API response. These output structs are not designed to be marshaled as JSON, but the CLI depended on them defining `json` labels, which it used to format the output as JSON (`docker version --format=json`); as a result, the JSON output changed in docker v29, as it would now use the naming based on the Go struct's fields (`APIVersion` instead of `ApiVersion`). In future, we should consider having a `--raw` (or similar) option for the CLI to print API responses as-is, instead of using client structs or CLI structs for this (this would also make sure the JSON output does not inherit client-side formatting of fields). For now, let's create a struct for formatting the output, similar to what we do for the client-side information. Signed-off-by: Sebastiaan van Stijn <[email protected]>
736df9d to
bff56f0
Compare
| out.GitCommit = component.Details["GitCommit"] | ||
| out.GoVersion = component.Details["GoVersion"] | ||
| out.KernelVersion = component.Details["KernelVersion"] | ||
| out.Experimental = func() bool { b, _ := strconv.ParseBool(component.Details["Experimental"]); return b }() | ||
| out.BuildTime = reformatDate(component.Details["BuildTime"]) |
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.
These were empty in 29.0.0. Is it intentional to restore them?
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.
Yeah, I was on the fence on these; decided to keep the status quo (pre v29) for now, in case there's people depending on them after all but we should consider removing them.
|
OK, let's bring this one in 👍 |
docker versionJSON ouput case changed in version 29.0.0, inconsistent and breaks utilities #6649The client.ServerVersion method in the moby/client module defines an output struct that's separate from the API response. These output structs are not designed to be marshaled as JSON, but the CLI depended on them defining
jsonlabels, which it used to format the output as JSON (docker version --format=json); as a result, the JSON output changed in docker v29, as it would now use the naming based on the Go struct's fields (APIVersioninstead ofApiVersion).In future, we should consider having a
--raw(or similar) option for the CLI to print API responses as-is, instead of using client structs or CLI structs for this (this would also make sure the JSON output does not inherit client-side formatting of fields).For now, let's create a struct for formatting the output, similar to what we do for the client-side information.
- What I did
- How I did it
- How to verify it
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)