mirror of
https://github.com/docker/cli.git
synced 2026-09-24 07:25:07 -05:00
Merge pull request #16076 from vbatts/export_image_times
graph: exported images times matching creation Upstream-commit: 77da5d8feb5cf88446df0045240b4943ce4fc206 Component: engine
This commit is contained in:
@@ -2,10 +2,12 @@ package graph
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/pkg/archive"
|
||||
@@ -88,6 +90,9 @@ func (s *TagStore) ImageExport(names []string, outStream io.Writer) error {
|
||||
if err := f.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Chtimes(filepath.Join(tempdir, "repositories"), time.Unix(0, 0), time.Unix(0, 0)); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
logrus.Debugf("There were no repositories to write")
|
||||
}
|
||||
@@ -128,7 +133,11 @@ func (s *TagStore) exportImage(name, tempdir string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
imageInspectRaw, err := s.lookupRaw(n)
|
||||
img, err := s.LookupImage(n)
|
||||
if err != nil || img == nil {
|
||||
return fmt.Errorf("No such image %s", n)
|
||||
}
|
||||
imageInspectRaw, err := s.graph.RawJSON(img.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -149,11 +158,13 @@ func (s *TagStore) exportImage(name, tempdir string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// find parent
|
||||
img, err := s.LookupImage(n)
|
||||
if err != nil {
|
||||
return err
|
||||
for _, fname := range []string{"", "VERSION", "json", "layer.tar"} {
|
||||
if err := os.Chtimes(filepath.Join(tmpImageDir, fname), img.Created, img.Created); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// try again with parent
|
||||
n = img.Parent
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -11,22 +11,6 @@ import (
|
||||
"github.com/docker/docker/utils"
|
||||
)
|
||||
|
||||
// lookupRaw looks up an image by name in a TagStore and returns the raw JSON
|
||||
// describing the image.
|
||||
func (s *TagStore) lookupRaw(name string) ([]byte, error) {
|
||||
image, err := s.LookupImage(name)
|
||||
if err != nil || image == nil {
|
||||
return nil, fmt.Errorf("No such image %s", name)
|
||||
}
|
||||
|
||||
imageInspectRaw, err := s.graph.RawJSON(image.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return imageInspectRaw, nil
|
||||
}
|
||||
|
||||
// Lookup looks up an image by name in a TagStore and returns it as an
|
||||
// ImageInspect structure.
|
||||
func (s *TagStore) Lookup(name string) (*types.ImageInspect, error) {
|
||||
|
||||
Reference in New Issue
Block a user