summaryrefslogtreecommitdiff
path: root/libpod/image
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-03-20 10:21:13 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-21 16:20:14 +0000
commit3428de0672afcd94ce65d7c29fd23e44e7e2b465 (patch)
tree1fa7713d169aca7eb17201b83bf8bf11740dceb8 /libpod/image
parent64416f14be695537379f9ac0a54b14c65db9545f (diff)
downloadpodman-3428de0672afcd94ce65d7c29fd23e44e7e2b465.tar.gz
podman-3428de0672afcd94ce65d7c29fd23e44e7e2b465.tar.bz2
podman-3428de0672afcd94ce65d7c29fd23e44e7e2b465.zip
Migrate podman images to image library
Signed-off-by: baude <bbaude@redhat.com> Closes: #523 Approved by: mheon
Diffstat (limited to 'libpod/image')
-rw-r--r--libpod/image/image.go26
-rw-r--r--libpod/image/utils.go20
2 files changed, 46 insertions, 0 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index 5e69a0a98..15fc5174c 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -29,12 +29,16 @@ import (
// Image is the primary struct for dealing with images
// It is still very much a work in progress
type Image struct {
+ // Adding these two structs for now but will cull when we near
+ // completion of this library.
inspect.ImageData
+ inspect.ImageResult
InputName string
Local bool
//runtime *libpod.Runtime
image *storage.Image
imageruntime *Runtime
+ repotagsMap map[string][]string
}
// Runtime contains the store
@@ -496,6 +500,28 @@ func (i *Image) History() ([]ociv1.History, []types.BlobInfo, error) {
return oci.History, img.LayerInfos(), nil
}
+// Dangling returns a bool if the image is "dangling"
+func (i *Image) Dangling() bool {
+ return len(i.Names()) == 0
+}
+
+// Labels returns the image's labels
+func (i *Image) Labels() (map[string]string, error) {
+ sr, err := i.toStorageReference()
+ if err != nil {
+ return nil, err
+ }
+ ic, err := sr.NewImage(&types.SystemContext{})
+ if err != nil {
+ return nil, err
+ }
+ imgInspect, err := ic.Inspect()
+ if err != nil {
+ return nil, err
+ }
+ return imgInspect.Labels, nil
+}
+
// Import imports and image into the store and returns an image
func Import(path, reference string, writer io.Writer, signingOptions SigningOptions, imageConfig ociv1.Image, runtime *Runtime) (*Image, error) {
file := TarballTransport + ":" + path
diff --git a/libpod/image/utils.go b/libpod/image/utils.go
index 76ec349f9..c1b2aacde 100644
--- a/libpod/image/utils.go
+++ b/libpod/image/utils.go
@@ -90,3 +90,23 @@ func getPolicyContext(ctx *types.SystemContext) (*signature.PolicyContext, error
func hasTransport(image string) bool {
return strings.Contains(image, "://")
}
+
+// ReposToMap parses the specified repotags and returns a map with repositories
+// as keys and the corresponding arrays of tags as values.
+func ReposToMap(repotags []string) map[string][]string {
+ // map format is repo -> tag
+ repos := make(map[string][]string)
+ for _, repo := range repotags {
+ var repository, tag string
+ if len(repo) > 0 {
+ li := strings.LastIndex(repo, ":")
+ repository = repo[0:li]
+ tag = repo[li+1:]
+ }
+ repos[repository] = append(repos[repository], tag)
+ }
+ if len(repos) == 0 {
+ repos["<none>"] = []string{"<none>"}
+ }
+ return repos
+}