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)
| 185 | // |
| 186 | // [jsonmessage.JSONProgress.String()]: https://github.com/moby/moby/blob/v28.5.2/pkg/jsonmessage/jsonmessage.go#L54-L117 |
| 187 | func 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 | } |
no outgoing calls
no test coverage detected