Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
Antonio Murdaca 2015-04-21 19:59:45 +02:00
Родитель afd5636461
Коммит ba0017595e
2 изменённых файлов: 11 добавлений и 18 удалений

Просмотреть файл

@ -139,9 +139,7 @@ func (s *TagStore) exportImage(eng *engine.Engine, name, tempdir string) error {
if err != nil {
return err
}
job = eng.Job("image_tarlayer", n)
job.Stdout.Add(fsTar)
if err := job.Run(); err != nil {
if err := s.ImageTarLayer(n, fsTar); err != nil {
return err
}

Просмотреть файл

@ -11,14 +11,13 @@ import (
func (s *TagStore) Install(eng *engine.Engine) error {
for name, handler := range map[string]engine.Handler{
"image_set": s.CmdSet,
"image_get": s.CmdGet,
"image_inspect": s.CmdLookup,
"image_tarlayer": s.CmdTarLayer,
"image_export": s.CmdImageExport,
"viz": s.CmdViz,
"load": s.CmdLoad,
"push": s.CmdPush,
"image_set": s.CmdSet,
"image_get": s.CmdGet,
"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 {
return fmt.Errorf("Could not register %q: %v", name, err)
@ -152,12 +151,8 @@ func (s *TagStore) CmdLookup(job *engine.Job) error {
return fmt.Errorf("No such image: %s", name)
}
// CmdTarLayer return the tarLayer of the image
func (s *TagStore) CmdTarLayer(job *engine.Job) error {
if len(job.Args) != 1 {
return fmt.Errorf("usage: %s NAME", job.Name)
}
name := job.Args[0]
// ImageTarLayer return the tarLayer of the image
func (s *TagStore) ImageTarLayer(name string, dest io.Writer) error {
if image, err := s.LookupImage(name); err == nil && image != nil {
fs, err := image.TarLayer()
if err != nil {
@ -165,7 +160,7 @@ func (s *TagStore) CmdTarLayer(job *engine.Job) error {
}
defer fs.Close()
written, err := io.Copy(job.Stdout, fs)
written, err := io.Copy(dest, fs)
if err != nil {
return err
}