@@ -451,7 +451,7 @@ func (srv *Server) ImageInsert(name, url, path string, out io.Writer, sf *utils.
451451 return err
452452 }
453453
454- if err := c .Inject (utils .ProgressReader (file .Body , int (file .ContentLength ), out , sf . FormatProgress ( "" , "Downloading" , "%8v/%v (%v)" ), sf , false ), path ); err != nil {
454+ if err := c .Inject (utils .ProgressReader (file .Body , int (file .ContentLength ), out , sf , false , "" , "Downloading" ), path ); err != nil {
455455 return err
456456 }
457457 // FIXME: Handle custom repo, tag comment, author
@@ -761,7 +761,7 @@ func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgID, endpoin
761761 if err != nil {
762762 return err
763763 }
764- out .Write (sf .FormatProgress (utils .TruncateID (imgID ), "Pulling" , " dependent layers" ))
764+ out .Write (sf .FormatProgress (utils .TruncateID (imgID ), "Pulling dependent layers" , nil ))
765765 // FIXME: Try to stream the images?
766766 // FIXME: Launch the getRemoteImage() in goroutines
767767
@@ -776,33 +776,33 @@ func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgID, endpoin
776776 defer srv .poolRemove ("pull" , "layer:" + id )
777777
778778 if ! srv .runtime .graph .Exists (id ) {
779- out .Write (sf .FormatProgress (utils .TruncateID (id ), "Pulling" , " metadata" ))
779+ out .Write (sf .FormatProgress (utils .TruncateID (id ), "Pulling metadata" , nil ))
780780 imgJSON , imgSize , err := r .GetRemoteImageJSON (id , endpoint , token )
781781 if err != nil {
782- out .Write (sf .FormatProgress (utils .TruncateID (id ), "Error" , " pulling dependent layers" ))
782+ out .Write (sf .FormatProgress (utils .TruncateID (id ), "Error pulling dependent layers" , nil ))
783783 // FIXME: Keep going in case of error?
784784 return err
785785 }
786786 img , err := NewImgJSON (imgJSON )
787787 if err != nil {
788- out .Write (sf .FormatProgress (utils .TruncateID (id ), "Error" , " pulling dependent layers" ))
788+ out .Write (sf .FormatProgress (utils .TruncateID (id ), "Error pulling dependent layers" , nil ))
789789 return fmt .Errorf ("Failed to parse json: %s" , err )
790790 }
791791
792792 // Get the layer
793- out .Write (sf .FormatProgress (utils .TruncateID (id ), "Pulling" , " fs layer" ))
793+ out .Write (sf .FormatProgress (utils .TruncateID (id ), "Pulling fs layer" , nil ))
794794 layer , err := r .GetRemoteImageLayer (img .ID , endpoint , token )
795795 if err != nil {
796- out .Write (sf .FormatProgress (utils .TruncateID (id ), "Error" , " pulling dependent layers" ))
796+ out .Write (sf .FormatProgress (utils .TruncateID (id ), "Error pulling dependent layers" , nil ))
797797 return err
798798 }
799799 defer layer .Close ()
800- if err := srv .runtime .graph .Register (imgJSON , utils .ProgressReader (layer , imgSize , out , sf . FormatProgress ( utils .TruncateID (id ), "Downloading" , "%8v/%v (%v)" ), sf , false ), img ); err != nil {
801- out .Write (sf .FormatProgress (utils .TruncateID (id ), "Error" , " downloading dependent layers" ))
800+ if err := srv .runtime .graph .Register (imgJSON , utils .ProgressReader (layer , imgSize , out , sf , false , utils .TruncateID (id ), "Downloading" ), img ); err != nil {
801+ out .Write (sf .FormatProgress (utils .TruncateID (id ), "Error downloading dependent layers" , nil ))
802802 return err
803803 }
804804 }
805- out .Write (sf .FormatProgress (utils .TruncateID (id ), "Download" , " complete" ))
805+ out .Write (sf .FormatProgress (utils .TruncateID (id ), "Download complete" , nil ))
806806
807807 }
808808 return nil
@@ -875,29 +875,29 @@ func (srv *Server) pullRepository(r *registry.Registry, out io.Writer, localName
875875 }
876876 defer srv .poolRemove ("pull" , "img:" + img .ID )
877877
878- out .Write (sf .FormatProgress (utils .TruncateID (img .ID ), "Pulling" , fmt .Sprintf ("image (%s) from %s" , img .Tag , localName )))
878+ out .Write (sf .FormatProgress (utils .TruncateID (img .ID ), fmt .Sprintf ("Pulling image (%s) from %s" , img .Tag , localName ), nil ))
879879 success := false
880880 var lastErr error
881881 for _ , ep := range repoData .Endpoints {
882- out .Write (sf .FormatProgress (utils .TruncateID (img .ID ), "Pulling" , fmt .Sprintf ("image (%s) from %s, endpoint: %s" , img .Tag , localName , ep )))
882+ out .Write (sf .FormatProgress (utils .TruncateID (img .ID ), fmt .Sprintf ("Pulling image (%s) from %s, endpoint: %s" , img .Tag , localName , ep ), nil ))
883883 if err := srv .pullImage (r , out , img .ID , ep , repoData .Tokens , sf ); err != nil {
884884 // Its not ideal that only the last error is returned, it would be better to concatenate the errors.
885885 // As the error is also given to the output stream the user will see the error.
886886 lastErr = err
887- out .Write (sf .FormatProgress (utils .TruncateID (img .ID ), "Error pulling" , fmt .Sprintf ("image (%s) from %s, endpoint: %s, %s" , img .Tag , localName , ep , err )))
887+ out .Write (sf .FormatProgress (utils .TruncateID (img .ID ), fmt .Sprintf ("Error pulling image (%s) from %s, endpoint: %s, %s" , img .Tag , localName , ep , err ), nil ))
888888 continue
889889 }
890890 success = true
891891 break
892892 }
893893 if ! success {
894- out .Write (sf .FormatProgress (utils .TruncateID (img .ID ), "Error pulling" , fmt .Sprintf ("image (%s) from %s, %s" , img .Tag , localName , lastErr )))
894+ out .Write (sf .FormatProgress (utils .TruncateID (img .ID ), fmt .Sprintf ("Error pulling image (%s) from %s, %s" , img .Tag , localName , lastErr ), nil ))
895895 if parallel {
896896 errors <- fmt .Errorf ("Could not find repository on any of the indexed registries." )
897897 return
898898 }
899899 }
900- out .Write (sf .FormatProgress (utils .TruncateID (img .ID ), "Download" , " complete" ))
900+ out .Write (sf .FormatProgress (utils .TruncateID (img .ID ), "Download complete" , nil ))
901901
902902 if parallel {
903903 errors <- nil
@@ -1171,7 +1171,7 @@ func (srv *Server) pushImage(r *registry.Registry, out io.Writer, remote, imgID,
11711171 defer os .RemoveAll (layerData .Name ())
11721172
11731173 // Send the layer
1174- checksum , err = r .PushImageLayerRegistry (imgData .ID , utils .ProgressReader (layerData , int (layerData .Size ), out , sf . FormatProgress ( "" , "Pushing" , "%8v/%v (%v)" ), sf , false ), ep , token , jsonRaw )
1174+ checksum , err = r .PushImageLayerRegistry (imgData .ID , utils .ProgressReader (layerData , int (layerData .Size ), out , sf , false , "" , "Pushing" ), ep , token , jsonRaw )
11751175 if err != nil {
11761176 return "" , err
11771177 }
@@ -1251,7 +1251,7 @@ func (srv *Server) ImageImport(src, repo, tag string, in io.Reader, out io.Write
12511251 if err != nil {
12521252 return err
12531253 }
1254- archive = utils .ProgressReader (resp .Body , int (resp .ContentLength ), out , sf . FormatProgress ( "" , "Importing" , "%8v/%v (%v)" ), sf , true )
1254+ archive = utils .ProgressReader (resp .Body , int (resp .ContentLength ), out , sf , true , "" , "Importing" )
12551255 }
12561256 img , err := srv .runtime .graph .Create (archive , nil , "Imported from " + src , "" , nil )
12571257 if err != nil {
0 commit comments