summaryrefslogtreecommitdiff
path: root/image/image.go
diff options
context:
space:
mode:
Diffstat (limited to 'image/image.go')
-rw-r--r--image/image.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/image/image.go b/image/image.go
index b56cbf08ee..5c250947ce 100644
--- a/image/image.go
+++ b/image/image.go
@@ -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 {