diff --git a/api/server/server.go b/api/server/server.go index 867593e6ad..24b0abd437 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -900,10 +900,14 @@ func (s *Server) getImagesGet(eng *engine.Engine, version version.Version, w htt } func (s *Server) postImagesLoad(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error { - job := eng.Job("load") - job.Stdin.Add(r.Body) - job.Stdout.Add(w) - return job.Run() + + imageLoadConfig := &graph.ImageLoadConfig{ + InTar: r.Body, + OutStream: w, + Engine: eng, + } + + return s.daemon.Repositories().Load(imageLoadConfig) } func (s *Server) postContainersCreate(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error { diff --git a/graph/load.go b/graph/load.go index 5272eb1394..f62b82ce46 100644 --- a/graph/load.go +++ b/graph/load.go @@ -4,6 +4,7 @@ package graph import ( "encoding/json" + "io" "io/ioutil" "os" "path" @@ -15,9 +16,15 @@ import ( "github.com/docker/docker/pkg/chrootarchive" ) +type ImageLoadConfig struct { + InTar io.ReadCloser + OutStream io.Writer + Engine *engine.Engine +} + // Loads a set of images into the repository. This is the complementary of ImageExport. // The input stream is an uncompressed tar ball containing images and metadata. -func (s *TagStore) CmdLoad(job *engine.Job) error { +func (s *TagStore) Load(imageLoadConfig *ImageLoadConfig) error { tmpImageDir, err := ioutil.TempDir("", "docker-import-") if err != nil { return err @@ -41,7 +48,7 @@ func (s *TagStore) CmdLoad(job *engine.Job) error { excludes[i] = k i++ } - if err := chrootarchive.Untar(job.Stdin, repoDir, &archive.TarOptions{ExcludePatterns: excludes}); err != nil { + if err := chrootarchive.Untar(imageLoadConfig.InTar, repoDir, &archive.TarOptions{ExcludePatterns: excludes}); err != nil { return err } @@ -52,7 +59,7 @@ func (s *TagStore) CmdLoad(job *engine.Job) error { for _, d := range dirs { if d.IsDir() { - if err := s.recursiveLoad(job.Eng, d.Name(), tmpImageDir); err != nil { + if err := s.recursiveLoad(imageLoadConfig.Engine, d.Name(), tmpImageDir); err != nil { return err } } @@ -67,7 +74,7 @@ func (s *TagStore) CmdLoad(job *engine.Job) error { for imageName, tagMap := range repositories { for tag, address := range tagMap { - if err := s.SetLoad(imageName, tag, address, true, job.Stdout); err != nil { + if err := s.SetLoad(imageName, tag, address, true, imageLoadConfig.OutStream); err != nil { return err } } diff --git a/graph/service.go b/graph/service.go index 022d5d499d..44c1bdef16 100644 --- a/graph/service.go +++ b/graph/service.go @@ -13,7 +13,6 @@ func (s *TagStore) Install(eng *engine.Engine) error { "image_inspect": s.CmdLookup, "image_export": s.CmdImageExport, "viz": s.CmdViz, - "load": s.CmdLoad, "push": s.CmdPush, } { if err := eng.Register(name, handler); err != nil {