summaryrefslogtreecommitdiff
path: root/libpod/runtime_img.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-01-04 15:29:36 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-08 18:15:55 +0000
commit6847636c30bb3b70882000189946cb36cc5a246a (patch)
tree48a244f068b61fbb0f56ac80ed28a12e57cddb96 /libpod/runtime_img.go
parentf881a8d17c677192ea862bcfc25b829f3cfd7392 (diff)
downloadpodman-6847636c30bb3b70882000189946cb36cc5a246a.tar.gz
podman-6847636c30bb3b70882000189946cb36cc5a246a.tar.bz2
podman-6847636c30bb3b70882000189946cb36cc5a246a.zip
Remove by shortname
Removing by shortname was not working. Also pruned container storage's remove func from rmi and moved it into an image.Remove func, which consolidates our usage of cs. Signed-off-by: baude <bbaude@redhat.com> Closes: #188 Approved by: baude
Diffstat (limited to 'libpod/runtime_img.go')
-rw-r--r--libpod/runtime_img.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index 6178d5372..66630beb2 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -184,6 +184,24 @@ func (k *Image) GetImageID() (string, error) {
return img.ID, nil
}
}
+ // If the user input is an ID
+ images, err := k.runtime.GetImages(&ImageFilterParams{})
+ if err != nil {
+ return "", errors.Wrapf(err, "unable to get images")
+ }
+ for _, image := range images {
+ // Check if we have an ID match
+ if strings.HasPrefix(image.ID, k.Name) {
+ return image.ID, nil
+ }
+ // Check if we have a name match, perhaps a tagged name
+ for _, name := range image.Names {
+ if k.Name == name {
+ return image.ID, nil
+ }
+ }
+ }
+
// If neither the ID is known and no local name
// is know, we search it out.
image, _ := k.GetFQName()
@@ -408,6 +426,26 @@ func (k *Image) Pull(writer io.Writer) error {
return nil
}
+// Remove calls into container storage and deletes the image
+func (k *Image) Remove(force bool) (string, error) {
+ if k.LocalName == "" {
+ // This populates the images local name
+ _, err := k.GetLocalImageName()
+ if err != nil {
+ return "", errors.Wrapf(err, "unable to find %s locally", k.Name)
+ }
+ }
+ iid, err := k.GetImageID()
+ if err != nil {
+ return "", errors.Wrapf(err, "unable to get image id")
+ }
+ image, err := k.runtime.GetImage(iid)
+ if err != nil {
+ return "", errors.Wrapf(err, "unable to remove %s", iid)
+ }
+ return k.runtime.RemoveImage(image, force)
+}
+
// GetRegistries gets the searchable registries from the global registration file.
func GetRegistries() ([]string, error) {
registryConfigPath := ""