@@ -212,7 +212,7 @@ func (c Client) PullImageWithProcessAndOptions(task *task.Task, imageName string
212212 }
213213 if status == "Pull complete" || status == "Download complete" {
214214 id , _ := progress ["id" ].(string )
215- progressStr := fmt .Sprintf ("%s [%s] --- %.2f%% " , status , id , 100.0 )
215+ progressStr := fmt .Sprintf ("%s %s " , status , id )
216216 _ = setLog (id , progressStr , task )
217217 }
218218 }
@@ -246,7 +246,7 @@ func (c Client) PushImageWithProcessAndOptions(task *task.Task, imageName string
246246 logProcess (progress , task )
247247 case "Pushed" :
248248 id , _ := progress ["id" ].(string )
249- progressStr := fmt .Sprintf ("%s [%s] --- %.2f%% " , status , id , 100.0 )
249+ progressStr := fmt .Sprintf ("%s %s " , status , id )
250250 _ = setLog (id , progressStr , task )
251251 default :
252252 progressStr , _ := json .Marshal (progress )
@@ -290,7 +290,7 @@ func (c Client) BuildImageWithProcessAndOptions(task *task.Task, tar io.ReadClos
290290 logProcess (progress , task )
291291 case "Pull complete" , "Download complete" , "Verifying Checksum" :
292292 id , _ := progress ["id" ].(string )
293- progressStr := fmt .Sprintf ("%s [%s] --- %.2f%% " , status , id , 100.0 )
293+ progressStr := fmt .Sprintf ("%s %s " , status , id )
294294 _ = setLog (id , progressStr , task )
295295 default :
296296 progressStr , _ := json .Marshal (progress )
@@ -304,38 +304,12 @@ func (c Client) PullImageWithProcess(task *task.Task, imageName string) error {
304304 return c .PullImageWithProcessAndOptions (task , imageName , image.PullOptions {})
305305}
306306
307- func formatBytes (bytes uint64 ) string {
308- const (
309- KB = 1024
310- MB = 1024 * KB
311- GB = 1024 * MB
312- TB = 1024 * GB
313- )
314-
315- switch {
316- case bytes < MB :
317- return fmt .Sprintf ("%.0fKB" , float64 (bytes )/ KB )
318- case bytes < GB :
319- return fmt .Sprintf ("%.1fMB" , float64 (bytes )/ MB )
320- case bytes < TB :
321- return fmt .Sprintf ("%.1fGB" , float64 (bytes )/ GB )
322- default :
323- return fmt .Sprintf ("%.2fTB" , float64 (bytes )/ TB )
324- }
325- }
326-
327307func logProcess (progress map [string ]interface {}, task * task.Task ) {
328308 status , _ := progress ["status" ].(string )
329309 id , _ := progress ["id" ].(string )
330- progressDetail , _ := progress ["progressDetail" ].(map [string ]interface {})
331- current , _ := progressDetail ["current" ].(float64 )
310+ progressItem , _ := progress ["progress" ].(string )
332311 progressStr := ""
333- total , ok := progressDetail ["total" ].(float64 )
334- if ok {
335- progressStr = fmt .Sprintf ("%s [%s] --- %.2f%%" , status , id , (current / total )* 100 )
336- } else {
337- progressStr = fmt .Sprintf ("%s [%s] --- %s " , status , id , formatBytes (uint64 (current )))
338- }
312+ progressStr = fmt .Sprintf ("%s %s %s" , status , id , progressItem )
339313 _ = setLog (id , progressStr , task )
340314}
341315
0 commit comments