1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #12579 from ZJU-SEL/remove_job_from_load

remove job from load
This commit is contained in:
Doug Davis 2015-04-23 08:20:37 -04:00
commit 1b4de6f2e8
3 changed files with 19 additions and 9 deletions

View file

@ -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 {

View file

@ -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
}
}

View file

@ -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 {