mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Implementation of docker load command: Untarr the incoming tar stream directly into /var/lib/docker/tmp without creating the tar ball
Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
This commit is contained in:
parent
4c38045be1
commit
315260203c
1 changed files with 2 additions and 17 deletions
|
@ -4,7 +4,6 @@ package graph
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
@ -27,23 +26,9 @@ func (s *TagStore) CmdLoad(job *engine.Job) engine.Status {
|
||||||
defer os.RemoveAll(tmpImageDir)
|
defer os.RemoveAll(tmpImageDir)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
repoTarFile = path.Join(tmpImageDir, "repo.tar")
|
repoDir = path.Join(tmpImageDir, "repo")
|
||||||
repoDir = path.Join(tmpImageDir, "repo")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
tarFile, err := os.Create(repoTarFile)
|
|
||||||
if err != nil {
|
|
||||||
return job.Error(err)
|
|
||||||
}
|
|
||||||
if _, err := io.Copy(tarFile, job.Stdin); err != nil {
|
|
||||||
return job.Error(err)
|
|
||||||
}
|
|
||||||
tarFile.Close()
|
|
||||||
|
|
||||||
repoFile, err := os.Open(repoTarFile)
|
|
||||||
if err != nil {
|
|
||||||
return job.Error(err)
|
|
||||||
}
|
|
||||||
if err := os.Mkdir(repoDir, os.ModeDir); err != nil {
|
if err := os.Mkdir(repoDir, os.ModeDir); err != nil {
|
||||||
return job.Error(err)
|
return job.Error(err)
|
||||||
}
|
}
|
||||||
|
@ -57,7 +42,7 @@ func (s *TagStore) CmdLoad(job *engine.Job) engine.Status {
|
||||||
excludes[i] = k
|
excludes[i] = k
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
if err := chrootarchive.Untar(repoFile, repoDir, &archive.TarOptions{ExcludePatterns: excludes}); err != nil {
|
if err := chrootarchive.Untar(job.Stdin, repoDir, &archive.TarOptions{ExcludePatterns: excludes}); err != nil {
|
||||||
return job.Error(err)
|
return job.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue