summaryrefslogtreecommitdiff
path: root/cmd/podman/images.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2019-07-17 10:49:03 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2019-07-19 06:59:49 -0400
commit8ae97b2f57a845dd05f70f244a763c53250b4e81 (patch)
tree002608749a0930e7a75a6213217a9f09461eec71 /cmd/podman/images.go
parent398aeac8537e82ca813bb77e44ddfcefa5cc5ad5 (diff)
downloadpodman-8ae97b2f57a845dd05f70f244a763c53250b4e81.tar.gz
podman-8ae97b2f57a845dd05f70f244a763c53250b4e81.tar.bz2
podman-8ae97b2f57a845dd05f70f244a763c53250b4e81.zip
Add support for listing read/only and read/write images
When removing --all images prune images only attempt to remove read/write images, ignore read/only images Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/images.go')
-rw-r--r--cmd/podman/images.go43
1 files changed, 33 insertions, 10 deletions
diff --git a/cmd/podman/images.go b/cmd/podman/images.go
index f842573d9..281d93e71 100644
--- a/cmd/podman/images.go
+++ b/cmd/podman/images.go
@@ -30,14 +30,16 @@ type imagesTemplateParams struct {
Created string
CreatedTime time.Time
Size string
+ ReadOnly bool
}
type imagesJSONParams struct {
- ID string `json:"id"`
- Name []string `json:"names"`
- Digest digest.Digest `json:"digest"`
- Created time.Time `json:"created"`
- Size *uint64 `json:"size"`
+ ID string `json:"id"`
+ Name []string `json:"names"`
+ Digest digest.Digest `json:"digest"`
+ Created time.Time `json:"created"`
+ Size *uint64 `json:"size"`
+ ReadOnly bool `json:"readonly"`
}
type imagesOptions struct {
@@ -49,6 +51,7 @@ type imagesOptions struct {
outputformat string
sort string
all bool
+ useReadOnly bool
}
// Type declaration and functions for sorting the images output
@@ -175,6 +178,13 @@ func imagesCmd(c *cliconfig.ImagesValues) error {
return errors.Wrapf(err, "unable to get images")
}
+ for _, image := range images {
+ if image.IsReadOnly() {
+ opts.outputformat += "{{.ReadOnly}}\t"
+ break
+ }
+ }
+
var filteredImages []*adapter.ContainerImage
//filter the images
if len(c.Filter) > 0 || len(c.InputArgs) == 1 {
@@ -282,6 +292,7 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
CreatedTime: createdTime,
Created: units.HumanDuration(time.Since(createdTime)) + " ago",
Size: sizeStr,
+ ReadOnly: img.IsReadOnly(),
}
imagesOutput = append(imagesOutput, params)
if opts.quiet { // Show only one image ID when quiet
@@ -305,11 +316,12 @@ func getImagesJSONOutput(ctx context.Context, images []*adapter.ContainerImage)
size = nil
}
params := imagesJSONParams{
- ID: img.ID(),
- Name: img.Names(),
- Digest: img.Digest(),
- Created: img.Created(),
- Size: size,
+ ID: img.ID(),
+ Name: img.Names(),
+ Digest: img.Digest(),
+ Created: img.Created(),
+ Size: size,
+ ReadOnly: img.IsReadOnly(),
}
imagesOutput = append(imagesOutput, params)
}
@@ -351,6 +363,11 @@ func GenImageOutputMap() map[string]string {
if value == "ID" {
value = "Image" + value
}
+
+ if value == "ReadOnly" {
+ values[key] = "R/O"
+ continue
+ }
values[key] = strings.ToUpper(splitCamelCase(value))
}
return values
@@ -378,6 +395,12 @@ func CreateFilterFuncs(ctx context.Context, r *adapter.LocalRuntime, filters []s
return nil, errors.Wrapf(err, "unable to find image %s in local stores", splitFilter[1])
}
filterFuncs = append(filterFuncs, imagefilters.CreatedAfterFilter(after.Created()))
+ case "readonly":
+ readonly, err := strconv.ParseBool(splitFilter[1])
+ if err != nil {
+ return nil, errors.Wrapf(err, "invalid filter readonly=%s", splitFilter[1])
+ }
+ filterFuncs = append(filterFuncs, imagefilters.ReadOnlyFilter(readonly))
case "dangling":
danglingImages, err := strconv.ParseBool(splitFilter[1])
if err != nil {