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
add --format flag to docker version
#14194
Conversation
Is there any drawbacks for using API for such tasks? |
I'm a big +1, but I agree with @LK4D4 that it seems like this would be better as a client-side feature -- that way we could even use this to just get the version of the client binary when the server isn't responding or isn't up, which right now looks like this (and is useful): $ DOCKER_HOST=unix:///not/a/file.sock docker version
Client:
Version: 1.8.0-dev
API version: 1.20
Go version: go1.4.2
Git commit: b96f109-dirty
Built: Fri Jun 26 16:26:11 UTC 2015
OS/Arch: linux/amd64
Get http:///not/a/file.sock/v1.20/version: dial unix /not/a/file.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS? |
ie, something like this would happen: (with that warning going to stderr) $ docker version -f '{{.Client.Version}}'
Get http:///not/a/file.sock/v1.20/version: dial unix /not/a/file.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
1.8.0-dev |
:-) with that format string I kind of wonder why we're even hitting the daemon |
I'm not quite following. This is a client side feature.
That is what happens (except the order of the lines is reversed).
Yeah, that is one down side. But the only way I can see to make that happen is to add a function to the template map which fetches the server data. And I think that makes the templating dirty. |
LGTM |
LGTM, so sorry needs rebase, we are almost through the tunnel to the end :) |
Signed-off-by: Patrick Hemmer <patrick.hemmer@gmail.com>
Rebased. |
LGTM |
add --format flag to `docker version`
thanks! |
cmd := cli.Subcmd("version", nil, "Show the Docker version information.", true) | ||
tmplStr := cmd.String([]string{"f", "#format", "-format"}, "", "Format the output using the given go template") |
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.
@phemmer i just noticed: you shouldn't use #format
, that's for old flags, you are introducing a new one here.
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.
ping @phemmer could you take care of this, or want someone else to do so?
This adds the
--format
flag todocker version
.Closes #14186
Default output:
Get server version:
Dump raw data:
Dead server:
(error goes to STDERR, allowing capturing STDOUT to still work if only client data is needed)