summaryrefslogtreecommitdiff
path: root/libpod/image_inspect.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-03-15 10:06:49 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-20 16:20:12 +0000
commit38a1b2f16d210525eafcc845e7a9cce598207113 (patch)
tree5616a12d68ebe55138fbde85f936a6bc90d4c8fd /libpod/image_inspect.go
parentecfa321288f10b70a59166f93296c77d262317fc (diff)
downloadpodman-38a1b2f16d210525eafcc845e7a9cce598207113.tar.gz
podman-38a1b2f16d210525eafcc845e7a9cce598207113.tar.bz2
podman-38a1b2f16d210525eafcc845e7a9cce598207113.zip
Image library stage 4 - create and commit
Migrate the podman create and commit subcommandis to leverage the images library. I also had to migrate the cmd/ portions of run and rmi. Signed-off-by: baude <bbaude@redhat.com> Closes: #498 Approved by: mheon
Diffstat (limited to 'libpod/image_inspect.go')
-rw-r--r--libpod/image_inspect.go26
1 files changed, 17 insertions, 9 deletions
diff --git a/libpod/image_inspect.go b/libpod/image_inspect.go
index df2d3640e..bedad3668 100644
--- a/libpod/image_inspect.go
+++ b/libpod/image_inspect.go
@@ -4,18 +4,22 @@ import (
"encoding/json"
"strings"
- "github.com/containers/image/types"
- "github.com/containers/storage"
digest "github.com/opencontainers/go-digest"
ociv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
+ "github.com/projectatomic/libpod/libpod/image"
"github.com/projectatomic/libpod/pkg/inspect"
)
-func getImageData(img storage.Image, imgRef types.Image, size int64, driver *inspect.Data) (*inspect.ImageData, error) {
- imgSize, err := imgRef.Size()
+// GetImageData returns an image's inspect data
+func GetImageData(img *image.Image) (*inspect.ImageData, error) {
+ imgRef, err := img.ToImageRef()
if err != nil {
- return nil, errors.Wrapf(err, "error reading size of image %q", img.ID)
+ return nil, err
+ }
+ size, err := imgRef.Size()
+ if err != nil {
+ return nil, err
}
manifest, manifestType, err := imgRef.Manifest()
if err != nil {
@@ -37,13 +41,17 @@ func getImageData(img storage.Image, imgRef types.Image, size int64, driver *ins
}
var repoDigests []string
- for _, name := range img.Names {
+ for _, name := range img.Names() {
repoDigests = append(repoDigests, strings.SplitN(name, ":", 2)[0]+"@"+imgDigest.String())
}
+ driver, err := img.DriverData()
+ if err != nil {
+ return nil, err
+ }
data := &inspect.ImageData{
- ID: img.ID,
- RepoTags: img.Names,
+ ID: img.ID(),
+ RepoTags: img.Names(),
RepoDigests: repoDigests,
Comment: ociv1Img.History[0].Comment,
Created: ociv1Img.Created,
@@ -53,7 +61,7 @@ func getImageData(img storage.Image, imgRef types.Image, size int64, driver *ins
ContainerConfig: &ociv1Img.Config,
Version: info.DockerVersion,
Size: size,
- VirtualSize: size + imgSize,
+ VirtualSize: size,
Annotations: annotations,
Digest: imgDigest,
Labels: info.Labels,