Scope orchestration selection to stack commands only
* Renaming DOCKER_ORCHESTRATOR to DOCKER_STACK_ORCHESTRATOR * Renaming config file option "orchestrator" to "stackOrchestrator" * "--orchestrator" flag is no more global but local to stack command and subcommands * Cleaning all global orchestrator code * Replicating Hidden flags in help and Supported flags from root command to stack command Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
This commit is contained in:
committed by
Sebastiaan van Stijn
parent
8de0753869
commit
71272dd203
@ -1,9 +1,9 @@
|
||||
Client:
|
||||
Version: 18.99.5-ce
|
||||
API version: 1.38
|
||||
Go version: go1.10.2
|
||||
Git commit: deadbeef
|
||||
Built: Wed May 30 22:21:05 2018
|
||||
OS/Arch: linux/amd64
|
||||
Experimental: true
|
||||
Orchestrator: swarm
|
||||
Version: 18.99.5-ce
|
||||
API version: 1.38
|
||||
Go version: go1.10.2
|
||||
Git commit: deadbeef
|
||||
Built: Wed May 30 22:21:05 2018
|
||||
OS/Arch: linux/amd64
|
||||
Experimental: true
|
||||
Stack Orchestrator: swarm
|
||||
|
||||
@ -29,7 +29,7 @@ Client:{{if ne .Platform.Name ""}} {{.Platform.Name}}{{end}}
|
||||
Built: {{.BuildTime}}
|
||||
OS/Arch: {{.Os}}/{{.Arch}}
|
||||
Experimental: {{.Experimental}}
|
||||
Orchestrator: {{.Orchestrator}}
|
||||
Stack Orchestrator: {{.StackOrchestrator}}
|
||||
{{- end}}
|
||||
|
||||
{{- if .ServerOK}}{{with .Server}}
|
||||
@ -78,7 +78,7 @@ type clientVersion struct {
|
||||
Arch string
|
||||
BuildTime string `json:",omitempty"`
|
||||
Experimental bool
|
||||
Orchestrator string `json:",omitempty"`
|
||||
StackOrchestrator string `json:",omitempty"`
|
||||
}
|
||||
|
||||
type kubernetesVersion struct {
|
||||
@ -128,6 +128,11 @@ func runVersion(dockerCli command.Cli, opts *versionOptions) error {
|
||||
return cli.StatusError{StatusCode: 64, Status: err.Error()}
|
||||
}
|
||||
|
||||
orchestrator, err := command.GetStackOrchestrator("", dockerCli.ConfigFile().StackOrchestrator)
|
||||
if err != nil {
|
||||
return cli.StatusError{StatusCode: 64, Status: err.Error()}
|
||||
}
|
||||
|
||||
vd := versionInfo{
|
||||
Client: clientVersion{
|
||||
Platform: struct{ Name string }{cli.PlatformName},
|
||||
@ -140,14 +145,17 @@ func runVersion(dockerCli command.Cli, opts *versionOptions) error {
|
||||
Os: runtime.GOOS,
|
||||
Arch: runtime.GOARCH,
|
||||
Experimental: dockerCli.ClientInfo().HasExperimental,
|
||||
Orchestrator: string(dockerCli.ClientInfo().Orchestrator),
|
||||
StackOrchestrator: string(orchestrator),
|
||||
},
|
||||
}
|
||||
|
||||
sv, err := dockerCli.Client().ServerVersion(context.Background())
|
||||
if err == nil {
|
||||
vd.Server = &sv
|
||||
kubeVersion := getKubernetesVersion(dockerCli, opts.kubeConfig)
|
||||
var kubeVersion *kubernetesVersion
|
||||
if orchestrator.HasKubernetes() {
|
||||
kubeVersion = getKubernetesVersion(opts.kubeConfig)
|
||||
}
|
||||
foundEngine := false
|
||||
foundKubernetes := false
|
||||
for _, component := range sv.Components {
|
||||
@ -225,11 +233,7 @@ func getDetailsOrder(v types.ComponentVersion) []string {
|
||||
return out
|
||||
}
|
||||
|
||||
func getKubernetesVersion(dockerCli command.Cli, kubeConfig string) *kubernetesVersion {
|
||||
if !dockerCli.ClientInfo().HasKubernetes() {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getKubernetesVersion(kubeConfig string) *kubernetesVersion {
|
||||
version := kubernetesVersion{
|
||||
Kubernetes: "Unknown",
|
||||
StackAPI: "Unknown",
|
||||
|
||||
@ -39,7 +39,7 @@ func fakeServerVersion(_ context.Context) (types.Version, error) {
|
||||
}
|
||||
|
||||
func TestVersionWithOrchestrator(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{serverVersion: fakeServerVersion}, test.OrchestratorSwarm)
|
||||
cli := test.NewFakeCli(&fakeClient{serverVersion: fakeServerVersion})
|
||||
cmd := NewVersionCommand(cli)
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Contains(cleanTabs(cli.OutBuffer().String()), "Orchestrator: swarm"))
|
||||
@ -57,7 +57,7 @@ func TestVersionAlign(t *testing.T) {
|
||||
Arch: "amd64",
|
||||
BuildTime: "Wed May 30 22:21:05 2018",
|
||||
Experimental: true,
|
||||
Orchestrator: "swarm",
|
||||
StackOrchestrator: "swarm",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user