mirror of https://github.com/docker/cli.git
Merge pull request #29041 from aaronlehmann/hide-updatestatus
api: Hide UpdateStatus when it is not present
This commit is contained in:
commit
e2b06ebc88
|
@ -28,7 +28,9 @@ Service Mode:
|
||||||
{{- if .HasUpdateStatus }}
|
{{- if .HasUpdateStatus }}
|
||||||
UpdateStatus:
|
UpdateStatus:
|
||||||
State: {{ .UpdateStatusState }}
|
State: {{ .UpdateStatusState }}
|
||||||
|
{{- if .HasUpdateStatusStarted }}
|
||||||
Started: {{ .UpdateStatusStarted }}
|
Started: {{ .UpdateStatusStarted }}
|
||||||
|
{{- end }}
|
||||||
{{- if .UpdateIsCompleted }}
|
{{- if .UpdateIsCompleted }}
|
||||||
Completed: {{ .UpdateStatusCompleted }}
|
Completed: {{ .UpdateStatusCompleted }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -172,23 +174,27 @@ func (ctx *serviceInspectContext) ModeReplicatedReplicas() *uint64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *serviceInspectContext) HasUpdateStatus() bool {
|
func (ctx *serviceInspectContext) HasUpdateStatus() bool {
|
||||||
return ctx.Service.UpdateStatus.State != ""
|
return ctx.Service.UpdateStatus != nil && ctx.Service.UpdateStatus.State != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *serviceInspectContext) UpdateStatusState() swarm.UpdateState {
|
func (ctx *serviceInspectContext) UpdateStatusState() swarm.UpdateState {
|
||||||
return ctx.Service.UpdateStatus.State
|
return ctx.Service.UpdateStatus.State
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ctx *serviceInspectContext) HasUpdateStatusStarted() bool {
|
||||||
|
return ctx.Service.UpdateStatus.StartedAt != nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ctx *serviceInspectContext) UpdateStatusStarted() string {
|
func (ctx *serviceInspectContext) UpdateStatusStarted() string {
|
||||||
return units.HumanDuration(time.Since(ctx.Service.UpdateStatus.StartedAt))
|
return units.HumanDuration(time.Since(*ctx.Service.UpdateStatus.StartedAt))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *serviceInspectContext) UpdateIsCompleted() bool {
|
func (ctx *serviceInspectContext) UpdateIsCompleted() bool {
|
||||||
return ctx.Service.UpdateStatus.State == swarm.UpdateStateCompleted
|
return ctx.Service.UpdateStatus.State == swarm.UpdateStateCompleted && ctx.Service.UpdateStatus.CompletedAt != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *serviceInspectContext) UpdateStatusCompleted() string {
|
func (ctx *serviceInspectContext) UpdateStatusCompleted() string {
|
||||||
return units.HumanDuration(time.Since(ctx.Service.UpdateStatus.CompletedAt))
|
return units.HumanDuration(time.Since(*ctx.Service.UpdateStatus.CompletedAt))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *serviceInspectContext) UpdateStatusMessage() string {
|
func (ctx *serviceInspectContext) UpdateStatusMessage() string {
|
||||||
|
|
|
@ -74,9 +74,9 @@ func formatServiceInspect(t *testing.T, format formatter.Format, now time.Time)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UpdateStatus: swarm.UpdateStatus{
|
UpdateStatus: &swarm.UpdateStatus{
|
||||||
StartedAt: now,
|
StartedAt: &now,
|
||||||
CompletedAt: now,
|
CompletedAt: &now,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue