diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/runtime_img.go | 38 |
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 := "" |