mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-05 05:01:28 +00:00
docker save: raw json
Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)
This commit is contained in:
@@ -149,6 +149,22 @@ func jsonPath(root string) string {
|
||||
return path.Join(root, "json")
|
||||
}
|
||||
|
||||
func (img *Image) RawJson() ([]byte, error) {
|
||||
root, err := img.root()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to get root for image %s: %s", img.ID, err)
|
||||
}
|
||||
fh, err := os.Open(jsonPath(root))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to open json for image %s: %s", img.ID, err)
|
||||
}
|
||||
buf, err := ioutil.ReadAll(fh)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to read json for image %s: %s", img.ID, err)
|
||||
}
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
// TarLayer returns a tar archive of the image's filesystem layer.
|
||||
func (img *Image) TarLayer() (arch archive.Archive, err error) {
|
||||
if img.graph == nil {
|
||||
|
||||
Reference in New Issue
Block a user