mirror of
https://github.com/docker/cli.git
synced 2026-01-22 03:22:01 +03:00
Merge pull request #29041 from aaronlehmann/hide-updatestatus
api: Hide UpdateStatus when it is not present
Upstream-commit: e2b06ebc88
Component: cli
This commit is contained in:
@@ -28,7 +28,9 @@ Service Mode:
|
||||
{{- if .HasUpdateStatus }}
|
||||
UpdateStatus:
|
||||
State: {{ .UpdateStatusState }}
|
||||
{{- if .HasUpdateStatusStarted }}
|
||||
Started: {{ .UpdateStatusStarted }}
|
||||
{{- end }}
|
||||
{{- if .UpdateIsCompleted }}
|
||||
Completed: {{ .UpdateStatusCompleted }}
|
||||
{{- end }}
|
||||
@@ -172,23 +174,27 @@ func (ctx *serviceInspectContext) ModeReplicatedReplicas() *uint64 {
|
||||
}
|
||||
|
||||
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 {
|
||||
return ctx.Service.UpdateStatus.State
|
||||
}
|
||||
|
||||
func (ctx *serviceInspectContext) HasUpdateStatusStarted() bool {
|
||||
return ctx.Service.UpdateStatus.StartedAt != nil
|
||||
}
|
||||
|
||||
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 {
|
||||
return ctx.Service.UpdateStatus.State == swarm.UpdateStateCompleted
|
||||
return ctx.Service.UpdateStatus.State == swarm.UpdateStateCompleted && ctx.Service.UpdateStatus.CompletedAt != nil
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -74,9 +74,9 @@ func formatServiceInspect(t *testing.T, format formatter.Format, now time.Time)
|
||||
},
|
||||
},
|
||||
},
|
||||
UpdateStatus: swarm.UpdateStatus{
|
||||
StartedAt: now,
|
||||
CompletedAt: now,
|
||||
UpdateStatus: &swarm.UpdateStatus{
|
||||
StartedAt: &now,
|
||||
CompletedAt: &now,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user