Add an orchestrator column in the docker stack ls command

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
This commit is contained in:
Silvin Lubecki
2018-03-27 16:38:47 +02:00
committed by Mathieu Champlon
parent 8963ab993e
commit 13d0c9c695
8 changed files with 40 additions and 29 deletions

View File

@ -5,9 +5,10 @@ import (
)
const (
defaultStackTableFormat = "table {{.Name}}\t{{.Services}}"
defaultStackTableFormat = "table {{.Name}}\t{{.Services}}\t{{.Orchestrator}}"
stackServicesHeader = "SERVICES"
stackServicesHeader = "SERVICES"
stackOrchestrastorHeader = "ORCHESTRATOR"
)
// Stack contains deployed stack information.
@ -16,6 +17,8 @@ type Stack struct {
Name string
// Services is the number of the services
Services int
// Orchestratort is the platform on which the stack is deployed
Orchestrator string
}
// NewStackFormat returns a format for use with a stack Context
@ -48,8 +51,9 @@ type stackContext struct {
func newStackContext() *stackContext {
stackCtx := stackContext{}
stackCtx.header = map[string]string{
"Name": nameHeader,
"Services": stackServicesHeader,
"Name": nameHeader,
"Services": stackServicesHeader,
"Orchestrator": stackOrchestrastorHeader,
}
return &stackCtx
}
@ -65,3 +69,7 @@ func (s *stackContext) Name() string {
func (s *stackContext) Services() string {
return strconv.Itoa(s.s.Services)
}
func (s *stackContext) Orchestrator() string {
return s.s.Orchestrator
}