-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Print Stack API and Kubernetes versions in version command #898
Print Stack API and Kubernetes versions in version command #898
Conversation
Codecov Report
@@ Coverage Diff @@
## master #898 +/- ##
=========================================
- Coverage 53.26% 53.2% -0.06%
=========================================
Files 258 259 +1
Lines 16357 16415 +58
=========================================
+ Hits 8712 8734 +22
- Misses 7081 7117 +36
Partials 564 564 |
cli/command/system/version.go
Outdated
{{- if .KubernetesOK}}{{with .Kubernetes}} | ||
Orchestrator: | ||
Kubernetes: {{.Kubernetes}} | ||
Stack: {{.StackAPI}}{{- end}}{{end}}` |
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 if there is multiple API version available ? Should we display sthg a bit like docker api versions (version negociated vs min version) or a list of version, of just the version used ?
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.
I don't see the benefits of listing all the versions? At least with just the version used, there is no ambiguity.
kubernetes/check.go
Outdated
) | ||
|
||
// GetAPIVersion returns the most recent stack API installed. | ||
func GetAPIVersion(kubeConfig *restclient.Config) (StackVersion, error) { |
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.
We may want to use GetStackAPIVersion
here, as it's only the Stack
api version we're getting here. We could have more api extension in the future, and kubernetes.GetAPIVersion
kinda makes think it's the kubernetes api (server) version.
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.
ok
4a4815a
to
a4e7e6c
Compare
@vdemeester PTAL |
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 🐯
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.
Thanks! This is looking good, just a couple small nits on the template format.
kubernetes/check.go
Outdated
clients, err := kubernetes.NewForConfig(kubeConfig) | ||
if err != nil { | ||
return "", err | ||
} |
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.
This function could accept clients
instead of a config. The client is being created twice.
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.
Good catch, fixed.
cli/command/system/version.go
Outdated
|
||
func getKubernetesServerVersion(kubeConfig *restclient.Config) string { | ||
version := "Unknown" | ||
kubeClient, err := kubernetesClient.NewForConfig(kubeConfig) |
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 accept kubeClient
instead of config, so the client can be passed to GetStackAPIVersion
as well.
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.
Fixed
cli/command/system/version.go
Outdated
{{- end}}{{- end}} | ||
{{- if .KubernetesOK}}{{with .Kubernetes}} | ||
Orchestrator: | ||
Kubernetes: {{.Kubernetes}} |
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.
Minor naming nit: I assume in the future we will need to change "Server" to "Engine".
Maybe this should be formatted as:
Kubernetes:
Version: {{.Kubernetes}}
Stack API: {{.StackAPI}}
I think that would be more consistent with the other sections. What do you think?
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.
My first thought was to generalize this section to all orchestrators, but finally it seems that we don't have much things to print from swarm, and also this section seems very specific to Kubernetes. So I'm with renaming it.
cli/command/system/version.go
Outdated
{{- if .KubernetesOK}}{{with .Kubernetes}} | ||
Orchestrator: | ||
Kubernetes: {{.Kubernetes}} | ||
Stack: {{.StackAPI}}{{- end}}{{end}}` |
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.
Minor formatting nit: the {{- end}}{{end}}
can go on a new line so that the template reads a bit better.
-
in a template means "remove all whitespace before this token, so the trailing newline wont exist in the final rendered 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.
Thanks, I wasn't aware of that, fixed.
@@ -20,7 +20,7 @@ func newDeployCommand(dockerCli command.Cli) *cobra.Command { | |||
RunE: func(cmd *cobra.Command, args []string) error { | |||
opts.Namespace = args[0] | |||
if dockerCli.ClientInfo().HasKubernetes() { | |||
kli, err := kubernetes.WrapCli(dockerCli, cmd) | |||
kli, err := kubernetes.WrapCli(dockerCli, kubernetes.NewOptions(cmd.Flags())) |
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.
I hope that in the future when we add kube to more commands we can have this accept an Options
struct instead of cmd.Flags()
.
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.
Ok I'll refactor that in a future PR.
* Resolve Stack API using Kubernetes discovering API * Refactor Kubernetes flags parsing Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
a4e7e6c
to
854aad8
Compare
PTAL @dnephin |
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
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
- What I did
This pull request adds the Stack API resolution mechanism and print the selected version into the
version
command. It lays the foundation for a following one #899, which adds the v1beta2 version of the Stack API. It's extracted from the PR #854 .- How I did it
- How to verify it
Execute a
docker version
command against latestdocker for mac
, it should output at the end:- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)