Fix error caused by overlapping merge of 30733

This fix fixes build error caused by overlapping merge of 30733 and 28213.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang 2017-03-03 13:26:00 -08:00
parent 9fb77af2e6
commit e94294e902
2 changed files with 17 additions and 12 deletions

View File

@ -52,9 +52,22 @@ func TaskWrite(ctx Context, tasks []swarm.Task, names map[string]string, nodes m
} }
return nil return nil
} }
return ctx.Write(&taskContext{}, render) taskCtx := taskContext{}
taskCtx.header = taskHeaderContext{
"ID": taskIDHeader,
"Name": nameHeader,
"Image": imageHeader,
"Node": nodeHeader,
"DesiredState": desiredStateHeader,
"CurrentState": currentStateHeader,
"Error": errorHeader,
"Ports": portsHeader,
}
return ctx.Write(&taskCtx, render)
} }
type taskHeaderContext map[string]string
type taskContext struct { type taskContext struct {
HeaderContext HeaderContext
trunc bool trunc bool
@ -68,7 +81,6 @@ func (c *taskContext) MarshalJSON() ([]byte, error) {
} }
func (c *taskContext) ID() string { func (c *taskContext) ID() string {
c.AddHeader(taskIDHeader)
if c.trunc { if c.trunc {
return stringid.TruncateID(c.task.ID) return stringid.TruncateID(c.task.ID)
} }
@ -76,12 +88,10 @@ func (c *taskContext) ID() string {
} }
func (c *taskContext) Name() string { func (c *taskContext) Name() string {
c.AddHeader(nameHeader)
return c.name return c.name
} }
func (c *taskContext) Image() string { func (c *taskContext) Image() string {
c.AddHeader(imageHeader)
image := c.task.Spec.ContainerSpec.Image image := c.task.Spec.ContainerSpec.Image
if c.trunc { if c.trunc {
ref, err := reference.ParseNormalizedNamed(image) ref, err := reference.ParseNormalizedNamed(image)
@ -98,17 +108,14 @@ func (c *taskContext) Image() string {
} }
func (c *taskContext) Node() string { func (c *taskContext) Node() string {
c.AddHeader(nodeHeader)
return c.node return c.node
} }
func (c *taskContext) DesiredState() string { func (c *taskContext) DesiredState() string {
c.AddHeader(desiredStateHeader)
return command.PrettyPrint(c.task.DesiredState) return command.PrettyPrint(c.task.DesiredState)
} }
func (c *taskContext) CurrentState() string { func (c *taskContext) CurrentState() string {
c.AddHeader(currentStateHeader)
return fmt.Sprintf("%s %s ago", return fmt.Sprintf("%s %s ago",
command.PrettyPrint(c.task.Status.State), command.PrettyPrint(c.task.Status.State),
strings.ToLower(units.HumanDuration(time.Since(c.task.Status.Timestamp))), strings.ToLower(units.HumanDuration(time.Since(c.task.Status.Timestamp))),
@ -116,7 +123,6 @@ func (c *taskContext) CurrentState() string {
} }
func (c *taskContext) Error() string { func (c *taskContext) Error() string {
c.AddHeader(errorHeader)
// Trim and quote the error message. // Trim and quote the error message.
taskErr := c.task.Status.Err taskErr := c.task.Status.Err
if c.trunc && len(taskErr) > maxErrLength { if c.trunc && len(taskErr) > maxErrLength {
@ -129,7 +135,6 @@ func (c *taskContext) Error() string {
} }
func (c *taskContext) Ports() string { func (c *taskContext) Ports() string {
c.AddHeader(portsHeader)
if len(c.task.Status.PortStatus.Ports) == 0 { if len(c.task.Status.PortStatus.Ports) == 0 {
return "" return ""
} }

View File

@ -32,7 +32,7 @@ taskID2
`, `,
}, },
{ {
Context{Format: NewTaskFormat("table {{.Name}} {{.Node}} {{.Ports}}", false)}, Context{Format: NewTaskFormat("table {{.Name}}\t{{.Node}}\t{{.Ports}}", false)},
`NAME NODE PORTS `NAME NODE PORTS
foobar_baz foo1 foobar_baz foo1
foobar_bar foo2 foobar_bar foo2