summaryrefslogtreecommitdiff
path: root/libpod/image
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-07-19 14:59:13 +0200
committerGitHub <noreply@github.com>2019-07-19 14:59:13 +0200
commit02140ea7d1244fbafb77723a3a67423b0806b08e (patch)
tree002608749a0930e7a75a6213217a9f09461eec71 /libpod/image
parent398aeac8537e82ca813bb77e44ddfcefa5cc5ad5 (diff)
parent8ae97b2f57a845dd05f70f244a763c53250b4e81 (diff)
downloadpodman-02140ea7d1244fbafb77723a3a67423b0806b08e.tar.gz
podman-02140ea7d1244fbafb77723a3a67423b0806b08e.tar.bz2
podman-02140ea7d1244fbafb77723a3a67423b0806b08e.zip
Merge pull request #3590 from rhatdan/ro
Add support for listing read/only and read/write images
Diffstat (limited to 'libpod/image')
-rw-r--r--libpod/image/image.go24
-rw-r--r--libpod/image/prune.go2
2 files changed, 19 insertions, 7 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index f9879b85b..a057bc720 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -54,7 +54,6 @@ type Image struct {
inspect.ImageResult
inspectInfo *types.ImageInspectInfo
InputName string
- Local bool
//runtime *libpod.Runtime
image *storage.Image
imageruntime *Runtime
@@ -119,7 +118,6 @@ func setStore(options storage.StoreOptions) (storage.Store, error) {
func (ir *Runtime) newFromStorage(img *storage.Image) *Image {
image := Image{
InputName: img.ID,
- Local: true,
imageruntime: ir,
image: img,
}
@@ -132,7 +130,6 @@ func (ir *Runtime) newFromStorage(img *storage.Image) *Image {
func (ir *Runtime) NewFromLocal(name string) (*Image, error) {
image := Image{
InputName: name,
- Local: true,
imageruntime: ir,
}
localImage, err := image.getLocalImage()
@@ -153,13 +150,11 @@ func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile
// We don't know if the image is local or not ... check local first
newImage := Image{
InputName: name,
- Local: false,
imageruntime: ir,
}
if !forcePull {
localImage, err := newImage.getLocalImage()
if err == nil {
- newImage.Local = true
newImage.image = localImage
return &newImage, nil
}
@@ -199,7 +194,6 @@ func (ir *Runtime) LoadFromArchiveReference(ctx context.Context, srcRef types.Im
for _, name := range imageNames {
newImage := Image{
InputName: name,
- Local: true,
imageruntime: ir,
}
img, err := newImage.getLocalImage()
@@ -299,6 +293,11 @@ func (i *Image) ID() string {
return i.image.ID
}
+// IsReadOnly returns whether the image ID comes from a local store
+func (i *Image) IsReadOnly() bool {
+ return i.image.ReadOnly
+}
+
// Digest returns the image's digest
func (i *Image) Digest() digest.Digest {
return i.image.Digest
@@ -439,12 +438,25 @@ func (ir *Runtime) getImage(image string) (*Image, error) {
// GetImages retrieves all images present in storage
func (ir *Runtime) GetImages() ([]*Image, error) {
+ return ir.getImages(false)
+}
+
+// GetRWImages retrieves all read/write images present in storage
+func (ir *Runtime) GetRWImages() ([]*Image, error) {
+ return ir.getImages(true)
+}
+
+// getImages retrieves all images present in storage
+func (ir *Runtime) getImages(rwOnly bool) ([]*Image, error) {
var newImages []*Image
images, err := ir.store.Images()
if err != nil {
return nil, err
}
for _, i := range images {
+ if rwOnly && i.ReadOnly {
+ continue
+ }
// iterating over these, be careful to not iterate on the literal
// pointer.
image := i
diff --git a/libpod/image/prune.go b/libpod/image/prune.go
index a4f8a0c9f..6ef5d321f 100644
--- a/libpod/image/prune.go
+++ b/libpod/image/prune.go
@@ -12,7 +12,7 @@ func (ir *Runtime) GetPruneImages(all bool) ([]*Image, error) {
var (
pruneImages []*Image
)
- allImages, err := ir.GetImages()
+ allImages, err := ir.GetRWImages()
if err != nil {
return nil, err
}