MCPcopy
hub / github.com/docker/compose / progressText

Function progressText

pkg/compose/push.go:187–206  ·  pkg/compose/push.go::progressText

progressText is a minimal variant of [jsonmessage.JSONProgress.String()] [jsonmessage.JSONProgress.String()]: https://github.com/moby/moby/blob/v28.5.2/pkg/jsonmessage/jsonmessage.go#L54-L117

(p *jsonstream.Progress)

Source from the content-addressed store, hash-verified

185//
186// [jsonmessage.JSONProgress.String()]: https://github.com/moby/moby/blob/v28.5.2/pkg/jsonmessage/jsonmessage.go#L54-L117
187func progressText(p *jsonstream.Progress) string {
188 switch {
189 case p.Current <= 0 && p.Total <= 0:
190 return ""
191 case p.Units == "": // no units, use bytes
192 current := units.HumanSize(float64(p.Current))
193 if p.Total <= 0 || p.Total > p.Current {
194 // remove total display if the reported current is wonky.
195 return fmt.Sprintf("%8v", current)
196 }
197 total := units.HumanSize(float64(p.Total))
198 return fmt.Sprintf("%8v/%v", current, total)
199 default:
200 if p.Total <= 0 || p.Total > p.Current {
201 // remove total display if the reported current is wonky.
202 return fmt.Sprintf("%d %s", p.Current, p.Units)
203 }
204 return fmt.Sprintf("%d/%d %s", p.Current, p.Total, p.Units)
205 }
206}

Callers 1

toPushProgressEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected