summaryrefslogtreecommitdiff
path: root/libpod/image
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/image')
-rw-r--r--libpod/image/image.go16
-rw-r--r--libpod/image/image_test.go12
-rw-r--r--libpod/image/prune.go10
-rw-r--r--libpod/image/pull.go2
4 files changed, 25 insertions, 15 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index c8583a1c5..6ea49e2a9 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -781,6 +781,7 @@ type History struct {
CreatedBy string `json:"createdBy"`
Size int64 `json:"size"`
Comment string `json:"comment"`
+ Tags []string `json:"tags"`
}
// History gets the history of an image and the IDs of images that are part of
@@ -840,14 +841,17 @@ func (i *Image) History(ctx context.Context) ([]*History, error) {
delete(topLayerMap, layer.ID)
}
}
-
- allHistory = append(allHistory, &History{
+ h := History{
ID: id,
Created: oci.History[x].Created,
CreatedBy: oci.History[x].CreatedBy,
Size: size,
Comment: oci.History[x].Comment,
- })
+ }
+ if layer != nil {
+ h.Tags = layer.Names
+ }
+ allHistory = append(allHistory, &h)
if layer != nil && layer.Parent != "" && !oci.History[x].EmptyLayer {
layer, err = i.imageruntime.store.Layer(layer.Parent)
@@ -898,8 +902,7 @@ func (i *Image) Annotations(ctx context.Context) (map[string]string, error) {
}
}
annotations := make(map[string]string)
- switch manifestType {
- case ociv1.MediaTypeImageManifest:
+ if manifestType == ociv1.MediaTypeImageManifest {
var m ociv1.Manifest
if err := json.Unmarshal(imageManifest, &m); err == nil {
for k, v := range m.Annotations {
@@ -1007,6 +1010,7 @@ func (i *Image) Inspect(ctx context.Context) (*inspect.ImageData, error) {
ManifestType: manifestType,
User: ociv1Img.Config.User,
History: ociv1Img.History,
+ NamesHistory: i.NamesHistory(),
}
return data, nil
}
@@ -1523,7 +1527,7 @@ func GetLayersMapWithImageInfo(imageruntime *Runtime) (map[string]*LayerInfo, er
}
}
- // scan all layers & add all childs for each layers to layerInfo
+ // scan all layers & add all childid's for each layers to layerInfo
for _, layer := range layers {
_, ok := layerInfoMap[layer.ID]
if ok {
diff --git a/libpod/image/image_test.go b/libpod/image/image_test.go
index 5aff7d860..3ff6210d9 100644
--- a/libpod/image/image_test.go
+++ b/libpod/image/image_test.go
@@ -3,7 +3,6 @@ package image
import (
"context"
"fmt"
- "io"
"io/ioutil"
"os"
"testing"
@@ -91,8 +90,7 @@ func TestImage_NewFromLocal(t *testing.T) {
RunRoot: workdir,
GraphRoot: workdir,
}
- var writer io.Writer
- writer = os.Stdout
+ writer := os.Stdout
// Need images to be present for this test
ir, err := NewImageRuntimeFromOptions(so)
@@ -108,7 +106,7 @@ func TestImage_NewFromLocal(t *testing.T) {
for _, image := range tm {
// tag our images
- image.img.TagImage(image.taggedName)
+ err = image.img.TagImage(image.taggedName)
assert.NoError(t, err)
for _, name := range image.names {
newImage, err := ir.NewFromLocal(name)
@@ -142,8 +140,7 @@ func TestImage_New(t *testing.T) {
// Build the list of pull names
names = append(names, bbNames...)
names = append(names, fedoraNames...)
- var writer io.Writer
- writer = os.Stdout
+ writer := os.Stdout
// Iterate over the names and delete the image
// after the pull
@@ -213,7 +210,7 @@ func TestImage_RepoDigests(t *testing.T) {
t.Fatal(err)
}
- for _, test := range []struct {
+ for _, tt := range []struct {
name string
names []string
expected []string
@@ -234,6 +231,7 @@ func TestImage_RepoDigests(t *testing.T) {
expected: []string{"docker.io/library/busybox@sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc"},
},
} {
+ test := tt
t.Run(test.name, func(t *testing.T) {
image := &Image{
image: &storage.Image{
diff --git a/libpod/image/prune.go b/libpod/image/prune.go
index f5be8ed50..3afff22af 100644
--- a/libpod/image/prune.go
+++ b/libpod/image/prune.go
@@ -116,6 +116,10 @@ func (ir *Runtime) PruneImages(ctx context.Context, all bool, filter []string) (
return nil, errors.Wrap(err, "unable to get images to prune")
}
for _, p := range pruneImages {
+ repotags, err := p.RepoTags()
+ if err != nil {
+ return nil, err
+ }
if err := p.Remove(ctx, true); err != nil {
if errors.Cause(err) == storage.ErrImageUsedByContainer {
logrus.Warnf("Failed to prune image %s as it is in use: %v", p.ID(), err)
@@ -124,7 +128,11 @@ func (ir *Runtime) PruneImages(ctx context.Context, all bool, filter []string) (
return nil, errors.Wrap(err, "failed to prune image")
}
defer p.newImageEvent(events.Prune)
- prunedCids = append(prunedCids, p.ID())
+ nameOrID := p.ID()
+ if len(repotags) > 0 {
+ nameOrID = repotags[0]
+ }
+ prunedCids = append(prunedCids, nameOrID)
}
return prunedCids, nil
}
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index 326a23f4c..76294ba06 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -407,5 +407,5 @@ func checkRemoteImageForLabel(ctx context.Context, label string, imageInfo pullR
return nil
}
}
- return errors.Errorf("%s has no label %s", imageInfo.image, label)
+ return errors.Errorf("%s has no label %s in %q", imageInfo.image, label, remoteInspect.Labels)
}