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

graph: change argument order of Register function

This commit is patch for following comment
FIXME: pass img as first argument

Signed-off-by: Daehyeok.Mun <daehyeok@gmail.com>
This commit is contained in:
Daehyeok.Mun 2014-08-28 19:57:54 +09:00
parent 22b585e0fc
commit 35df24c8e6
6 changed files with 14 additions and 16 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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