diff --git a/graph/graph.go b/graph/graph.go index 8f01739a75..b6bd524637 100644 --- a/graph/graph.go +++ b/graph/graph.go @@ -151,15 +151,14 @@ func (graph *Graph) Create(layerData archive.ArchiveReader, containerID, contain img.ContainerConfig = *containerConfig } - if err := graph.Register(nil, layerData, img); err != nil { + if err := graph.Register(img, nil, layerData); err != nil { return nil, err } return img, nil } // Register imports a pre-existing image into the graph. -// FIXME: pass img as first argument -func (graph *Graph) Register(jsonData []byte, layerData archive.ArchiveReader, img *image.Image) (err error) { +func (graph *Graph) Register(img *image.Image, jsonData []byte, layerData archive.ArchiveReader) (err error) { defer func() { // If any error occurs, remove the new dir from the driver. // Don't check for errors since the dir might not have been created. diff --git a/graph/load.go b/graph/load.go index ec87ef59e8..b7fb62ba98 100644 --- a/graph/load.go +++ b/graph/load.go @@ -118,7 +118,7 @@ func (s *TagStore) recursiveLoad(eng *engine.Engine, address, tmpImageDir string } } } - if err := s.graph.Register(imageJson, layer, img); err != nil { + if err := s.graph.Register(img, imageJson, layer); err != nil { return err } } diff --git a/graph/pull.go b/graph/pull.go index 180612fb75..97d693c590 100644 --- a/graph/pull.go +++ b/graph/pull.go @@ -280,9 +280,8 @@ func (s *TagStore) pullImage(r *registry.Session, out io.Writer, imgID, endpoint } defer layer.Close() - err = s.graph.Register(imgJSON, - utils.ProgressReader(layer, imgSize, out, sf, false, utils.TruncateID(id), "Downloading"), - img) + err = s.graph.Register(img, imgJSON, + utils.ProgressReader(layer, imgSize, out, sf, false, utils.TruncateID(id), "Downloading")) if terr, ok := err.(net.Error); ok && terr.Timeout() && j < retries { time.Sleep(time.Duration(j) * 500 * time.Millisecond) continue diff --git a/graph/service.go b/graph/service.go index b7db35dcdd..0003a5014a 100644 --- a/graph/service.go +++ b/graph/service.go @@ -74,7 +74,7 @@ func (s *TagStore) CmdSet(job *engine.Job) engine.Status { if err != nil { return job.Error(err) } - if err := s.graph.Register(imgJSON, layer, img); err != nil { + if err := s.graph.Register(img, imgJSON, layer); err != nil { return job.Error(err) } return engine.StatusOK diff --git a/graph/tags_unit_test.go b/graph/tags_unit_test.go index c6edc2d0d4..36cda68a2b 100644 --- a/graph/tags_unit_test.go +++ b/graph/tags_unit_test.go @@ -61,7 +61,7 @@ func mkTestTagStore(root string, t *testing.T) *TagStore { t.Fatal(err) } img := &image.Image{ID: testImageID} - if err := graph.Register(nil, archive, img); err != nil { + if err := graph.Register(img, nil, archive); err != nil { t.Fatal(err) } if err := store.Set(testImageName, "", testImageID, false); err != nil { diff --git a/integration/graph_test.go b/integration/graph_test.go index c6a0740ca5..4b59a5dbf9 100644 --- a/integration/graph_test.go +++ b/integration/graph_test.go @@ -74,7 +74,7 @@ func TestInterruptedRegister(t *testing.T) { Created: time.Now(), } w.CloseWithError(errors.New("But I'm not a tarball!")) // (Nobody's perfect, darling) - graph.Register(nil, badArchive, image) + graph.Register(image, nil, badArchive) if _, err := graph.Get(image.ID); err == nil { t.Fatal("Image should not exist after Register is interrupted") } @@ -83,7 +83,7 @@ func TestInterruptedRegister(t *testing.T) { if err != nil { t.Fatal(err) } - if err := graph.Register(nil, goodArchive, image); err != nil { + if err := graph.Register(image, nil, goodArchive); err != nil { t.Fatal(err) } } @@ -133,7 +133,7 @@ func TestRegister(t *testing.T) { Comment: "testing", Created: time.Now(), } - err = graph.Register(nil, archive, image) + err = graph.Register(image, nil, archive) if err != nil { t.Fatal(err) } @@ -228,7 +228,7 @@ func TestDelete(t *testing.T) { t.Fatal(err) } // Test delete twice (pull -> rm -> pull -> rm) - if err := graph.Register(nil, archive, img1); err != nil { + if err := graph.Register(img1, nil, archive); err != nil { t.Fatal(err) } if err := graph.Delete(img1.ID); err != nil { @@ -262,9 +262,9 @@ func TestByParent(t *testing.T) { Created: time.Now(), Parent: parentImage.ID, } - _ = graph.Register(nil, archive1, parentImage) - _ = graph.Register(nil, archive2, childImage1) - _ = graph.Register(nil, archive3, childImage2) + _ = graph.Register(parentImage, nil, archive1) + _ = graph.Register(childImage1, nil, archive2) + _ = graph.Register(childImage2, nil, archive3) byParent, err := graph.ByParent() if err != nil {