mirror of
https://github.com/containers/podman.git
synced 2025-11-14 01:57:58 +08:00
Vendor in containers/(storage,image, common, buildah)
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
49
vendor/github.com/containers/common/libimage/image.go
generated
vendored
49
vendor/github.com/containers/common/libimage/image.go
generated
vendored
@@ -2,6 +2,7 @@ package libimage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -16,7 +17,6 @@ import (
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/opencontainers/go-digest"
|
||||
ociv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -54,7 +54,7 @@ func (i *Image) reload() error {
|
||||
logrus.Tracef("Reloading image %s", i.ID())
|
||||
img, err := i.runtime.store.Image(i.ID())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "reloading image")
|
||||
return fmt.Errorf("reloading image: %w", err)
|
||||
}
|
||||
i.storageImage = img
|
||||
i.cached.imageSource = nil
|
||||
@@ -81,7 +81,7 @@ func (i *Image) isCorrupted(name string) error {
|
||||
if name == "" {
|
||||
name = i.ID()[:12]
|
||||
}
|
||||
return errors.Errorf("Image %s exists in local storage but may be corrupted (remove the image to resolve the issue): %v", name, err)
|
||||
return fmt.Errorf("Image %s exists in local storage but may be corrupted (remove the image to resolve the issue): %v", name, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -195,7 +195,7 @@ func (i *Image) Labels(ctx context.Context) (map[string]string, error) {
|
||||
if err != nil {
|
||||
isManifestList, listErr := i.IsManifestList(ctx)
|
||||
if listErr != nil {
|
||||
err = errors.Wrapf(err, "fallback error checking whether image is a manifest list: %v", err)
|
||||
err = fmt.Errorf("fallback error checking whether image is a manifest list: %v: %w", err, err)
|
||||
} else if isManifestList {
|
||||
logrus.Debugf("Ignoring error: cannot return labels for manifest list or image index %s", i.ID())
|
||||
return nil, nil
|
||||
@@ -305,7 +305,7 @@ func (i *Image) removeContainers(options *RemoveImagesOptions) error {
|
||||
for _, cID := range containers {
|
||||
if err := i.runtime.store.DeleteContainer(cID); err != nil {
|
||||
// If the container does not exist anymore, we're good.
|
||||
if errors.Cause(err) != storage.ErrContainerUnknown {
|
||||
if !errors.Is(err, storage.ErrContainerUnknown) {
|
||||
multiE = multierror.Append(multiE, err)
|
||||
}
|
||||
}
|
||||
@@ -361,7 +361,7 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
|
||||
logrus.Debugf("Removing image %s", i.ID())
|
||||
|
||||
if i.IsReadOnly() {
|
||||
return processedIDs, errors.Errorf("cannot remove read-only image %q", i.ID())
|
||||
return processedIDs, fmt.Errorf("cannot remove read-only image %q", i.ID())
|
||||
}
|
||||
|
||||
if i.runtime.eventChannel != nil {
|
||||
@@ -384,15 +384,12 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
|
||||
// have a closer look at the errors. On top, image removal should be
|
||||
// tolerant toward corrupted images.
|
||||
handleError := func(err error) error {
|
||||
switch errors.Cause(err) {
|
||||
case storage.ErrImageUnknown, storage.ErrNotAnImage, storage.ErrLayerUnknown:
|
||||
// The image or layers of the image may already
|
||||
// have been removed in which case we consider
|
||||
// the image to be removed.
|
||||
if errors.Is(err, storage.ErrImageUnknown) || errors.Is(err, storage.ErrNotAnImage) || errors.Is(err, storage.ErrLayerUnknown) {
|
||||
// The image or layers of the image may already have been removed
|
||||
// in which case we consider the image to be removed.
|
||||
return nil
|
||||
default:
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// Calculate the size if requested. `podman-image-prune` likes to
|
||||
@@ -421,11 +418,11 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
|
||||
byDigest := strings.HasPrefix(referencedBy, "sha256:")
|
||||
if !options.Force {
|
||||
if byID && numNames > 1 {
|
||||
return processedIDs, errors.Errorf("unable to delete image %q by ID with more than one tag (%s): please force removal", i.ID(), i.Names())
|
||||
return processedIDs, fmt.Errorf("unable to delete image %q by ID with more than one tag (%s): please force removal", i.ID(), i.Names())
|
||||
} else if byDigest && numNames > 1 {
|
||||
// FIXME - Docker will remove the digest but containers storage
|
||||
// does not support that yet, so our hands are tied.
|
||||
return processedIDs, errors.Errorf("unable to delete image %q by digest with more than one tag (%s): please force removal", i.ID(), i.Names())
|
||||
return processedIDs, fmt.Errorf("unable to delete image %q by digest with more than one tag (%s): please force removal", i.ID(), i.Names())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,16 +506,16 @@ var errTagDigest = errors.New("tag by digest not supported")
|
||||
// storage. The name is normalized according to the rules of NormalizeName.
|
||||
func (i *Image) Tag(name string) error {
|
||||
if strings.HasPrefix(name, "sha256:") { // ambiguous input
|
||||
return errors.Wrap(errTagDigest, name)
|
||||
return fmt.Errorf("%s: %w", name, errTagDigest)
|
||||
}
|
||||
|
||||
ref, err := NormalizeName(name)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "normalizing name %q", name)
|
||||
return fmt.Errorf("normalizing name %q: %w", name, err)
|
||||
}
|
||||
|
||||
if _, isDigested := ref.(reference.Digested); isDigested {
|
||||
return errors.Wrap(errTagDigest, name)
|
||||
return fmt.Errorf("%s: %w", name, errTagDigest)
|
||||
}
|
||||
|
||||
logrus.Debugf("Tagging image %s with %q", i.ID(), ref.String())
|
||||
@@ -546,12 +543,12 @@ var errUntagDigest = errors.New("untag by digest not supported")
|
||||
// of NormalizeName.
|
||||
func (i *Image) Untag(name string) error {
|
||||
if strings.HasPrefix(name, "sha256:") { // ambiguous input
|
||||
return errors.Wrap(errUntagDigest, name)
|
||||
return fmt.Errorf("%s: %w", name, errUntagDigest)
|
||||
}
|
||||
|
||||
ref, err := NormalizeName(name)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "normalizing name %q", name)
|
||||
return fmt.Errorf("normalizing name %q: %w", name, err)
|
||||
}
|
||||
|
||||
// FIXME: this is breaking Podman CI but must be re-enabled once
|
||||
@@ -560,9 +557,9 @@ func (i *Image) Untag(name string) error {
|
||||
//
|
||||
// !!! Also make sure to re-enable the tests !!!
|
||||
//
|
||||
// if _, isDigested := ref.(reference.Digested); isDigested {
|
||||
// return errors.Wrap(errUntagDigest, name)
|
||||
// }
|
||||
// if _, isDigested := ref.(reference.Digested); isDigested {
|
||||
// return fmt.Errorf("%s: %w", name, errUntagDigest)
|
||||
// }
|
||||
|
||||
name = ref.String()
|
||||
|
||||
@@ -582,7 +579,7 @@ func (i *Image) Untag(name string) error {
|
||||
}
|
||||
|
||||
if !removedName {
|
||||
return errors.Wrap(errTagUnknown, name)
|
||||
return fmt.Errorf("%s: %w", name, errTagUnknown)
|
||||
}
|
||||
|
||||
if err := i.runtime.store.SetNames(i.ID(), newNames); err != nil {
|
||||
@@ -731,7 +728,7 @@ func (i *Image) Mount(ctx context.Context, mountOptions []string, mountLabel str
|
||||
func (i *Image) Mountpoint() (string, error) {
|
||||
mountedTimes, err := i.runtime.store.Mounted(i.TopLayer())
|
||||
if err != nil || mountedTimes == 0 {
|
||||
if errors.Cause(err) == storage.ErrLayerUnknown {
|
||||
if errors.Is(err, storage.ErrLayerUnknown) {
|
||||
// Can happen, Podman did it, but there's no
|
||||
// explanation why.
|
||||
err = nil
|
||||
@@ -943,7 +940,7 @@ func getImageID(ctx context.Context, src types.ImageReference, sys *types.System
|
||||
}()
|
||||
imageDigest := newImg.ConfigInfo().Digest
|
||||
if err = imageDigest.Validate(); err != nil {
|
||||
return "", errors.Wrapf(err, "getting config info")
|
||||
return "", fmt.Errorf("getting config info: %w", err)
|
||||
}
|
||||
return "@" + imageDigest.Encoded(), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user