Move libkpod/image libkpod/layer to libpod/images and libpod/layers
Begin moving image and layer handling out of libkpod into libpod. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
47ef2f66df
commit
e18e962238
26 changed files with 272 additions and 104 deletions
35
libpod/images/rmi.go
Normal file
35
libpod/images/rmi.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package images
|
||||
|
||||
import (
|
||||
"github.com/containers/storage"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// UntagImage removes the tag from the given image
|
||||
func UntagImage(store storage.Store, image *storage.Image, imgArg string) (string, error) {
|
||||
// Remove name from image.Names and set the new names
|
||||
newNames := []string{}
|
||||
removedName := ""
|
||||
for _, name := range image.Names {
|
||||
if MatchesReference(name, imgArg) {
|
||||
removedName = name
|
||||
continue
|
||||
}
|
||||
newNames = append(newNames, name)
|
||||
}
|
||||
if removedName != "" {
|
||||
if err := store.SetNames(image.ID, newNames); err != nil {
|
||||
return "", errors.Wrapf(err, "error removing name %q from image %q", removedName, image.ID)
|
||||
}
|
||||
}
|
||||
return removedName, nil
|
||||
}
|
||||
|
||||
// RemoveImage removes the given image from storage
|
||||
func RemoveImage(image *storage.Image, store storage.Store) (string, error) {
|
||||
_, err := store.DeleteImage(image.ID, true)
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "could not remove image %q", image.ID)
|
||||
}
|
||||
return image.ID, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue