mirror of
https://github.com/containers/podman.git
synced 2025-12-06 13:56:22 +08:00
Vendor in containers/(storage,image, common, buildah)
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
48
vendor/github.com/containers/common/pkg/supplemented/supplemented.go
generated
vendored
48
vendor/github.com/containers/common/pkg/supplemented/supplemented.go
generated
vendored
@@ -3,6 +3,7 @@ package supplemented
|
||||
import (
|
||||
"container/list"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
cp "github.com/containers/image/v5/copy"
|
||||
@@ -12,7 +13,6 @@ import (
|
||||
"github.com/containers/image/v5/types"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -58,7 +58,7 @@ func Reference(ref types.ImageReference, supplemental []types.ImageReference, mu
|
||||
func (s *supplementedImageReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
|
||||
src, err := s.NewImageSource(ctx, sys)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error building a new Image using an ImageSource")
|
||||
return nil, fmt.Errorf("error building a new Image using an ImageSource: %w", err)
|
||||
}
|
||||
return image.FromSource(ctx, sys, src)
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func (s *supplementedImageReference) NewImageSource(ctx context.Context, sys *ty
|
||||
// Open the default instance for reading.
|
||||
top, err := s.ImageReference.NewImageSource(ctx, sys)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error opening %q as image source", transports.ImageName(s.ImageReference))
|
||||
return nil, fmt.Errorf("error opening %q as image source: %w", transports.ImageName(s.ImageReference), err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
@@ -105,14 +105,14 @@ func (s *supplementedImageReference) NewImageSource(ctx context.Context, sys *ty
|
||||
// Mark this instance as being associated with this ImageSource.
|
||||
manifestDigest, err := manifest.Digest(manifestBytes)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error computing digest over manifest %q", string(manifestBytes))
|
||||
return fmt.Errorf("error computing digest over manifest %q: %w", string(manifestBytes), err)
|
||||
}
|
||||
sources[manifestDigest] = src
|
||||
|
||||
// Parse the manifest as a single image.
|
||||
man, err := manifest.FromBlob(manifestBytes, manifestType)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error parsing manifest %q", string(manifestBytes))
|
||||
return fmt.Errorf("error parsing manifest %q: %w", string(manifestBytes), err)
|
||||
}
|
||||
|
||||
// Log the config blob's digest and the blobs of its layers as associated with this manifest.
|
||||
@@ -135,14 +135,14 @@ func (s *supplementedImageReference) NewImageSource(ctx context.Context, sys *ty
|
||||
// Mark this instance as being associated with this ImageSource.
|
||||
manifestDigest, err := manifest.Digest(manifestBytes)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error computing manifest digest")
|
||||
return fmt.Errorf("error computing manifest digest: %w", err)
|
||||
}
|
||||
sources[manifestDigest] = src
|
||||
|
||||
// Parse the manifest as a list of images.
|
||||
list, err := manifest.ListFromBlob(manifestBytes, manifestType)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error parsing manifest blob %q as a %q", string(manifestBytes), manifestType)
|
||||
return fmt.Errorf("error parsing manifest blob %q as a %q: %w", string(manifestBytes), manifestType, err)
|
||||
}
|
||||
|
||||
// Figure out which of its instances we want to look at.
|
||||
@@ -151,7 +151,7 @@ func (s *supplementedImageReference) NewImageSource(ctx context.Context, sys *ty
|
||||
case cp.CopySystemImage:
|
||||
instance, err := list.ChooseInstance(sys)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error selecting appropriate instance from list")
|
||||
return fmt.Errorf("error selecting appropriate instance from list: %w", err)
|
||||
}
|
||||
chaseInstances = []digest.Digest{instance}
|
||||
case cp.CopySpecificImages:
|
||||
@@ -194,14 +194,14 @@ func (s *supplementedImageReference) NewImageSource(ctx context.Context, sys *ty
|
||||
} else {
|
||||
src, err = ref.NewImageSource(ctx, sys)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error opening %q as image source", transports.ImageName(ref))
|
||||
return nil, fmt.Errorf("error opening %q as image source: %w", transports.ImageName(ref), err)
|
||||
}
|
||||
}
|
||||
|
||||
// Read the default manifest for the image.
|
||||
manifestBytes, manifestType, err := src.GetManifest(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error reading default manifest from image %q", transports.ImageName(ref))
|
||||
return nil, fmt.Errorf("error reading default manifest from image %q: %w", transports.ImageName(ref), err)
|
||||
}
|
||||
|
||||
// If this is the first image, mark it as our starting point.
|
||||
@@ -223,18 +223,18 @@ func (s *supplementedImageReference) NewImageSource(ctx context.Context, sys *ty
|
||||
// Record the digest of the ImageSource's default instance's manifest.
|
||||
manifestDigest, err := manifest.Digest(manifestBytes)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error computing digest of manifest from image %q", transports.ImageName(ref))
|
||||
return nil, fmt.Errorf("error computing digest of manifest from image %q: %w", transports.ImageName(ref), err)
|
||||
}
|
||||
sis.sourceDefaultInstances[src] = manifestDigest
|
||||
|
||||
// If the ImageSource's default manifest is a list, parse each of its instances.
|
||||
if manifest.MIMETypeIsMultiImage(manifestType) {
|
||||
if err = addMulti(manifestBytes, manifestType, src); err != nil {
|
||||
return nil, errors.Wrapf(err, "error adding multi-image %q", transports.ImageName(ref))
|
||||
return nil, fmt.Errorf("error adding multi-image %q: %w", transports.ImageName(ref), err)
|
||||
}
|
||||
} else {
|
||||
if err = addSingle(manifestBytes, manifestType, src); err != nil {
|
||||
return nil, errors.Wrapf(err, "error adding single image %q", transports.ImageName(ref))
|
||||
return nil, fmt.Errorf("error adding single image %q: %w", transports.ImageName(ref), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,22 +257,22 @@ func (s *supplementedImageReference) NewImageSource(ctx context.Context, sys *ty
|
||||
// Read the instance's manifest.
|
||||
manifestBytes, manifestType, err := manifestToRead.src.GetManifest(ctx, manifestToRead.instance)
|
||||
if err != nil {
|
||||
// if errors.Cause(err) == storage.ErrImageUnknown || os.IsNotExist(errors.Cause(err)) {
|
||||
// if errors.Is(err, storage.ErrImageUnknown) || errors.Is(err, os.ErrNotExist) {
|
||||
// Trust that we either don't need it, or that it's in another reference.
|
||||
// continue
|
||||
// }
|
||||
return nil, errors.Wrapf(err, "error reading manifest for instance %q", manifestToRead.instance)
|
||||
return nil, fmt.Errorf("error reading manifest for instance %q: %w", manifestToRead.instance, err)
|
||||
}
|
||||
|
||||
if manifest.MIMETypeIsMultiImage(manifestType) {
|
||||
// Add the list's contents.
|
||||
if err = addMulti(manifestBytes, manifestType, manifestToRead.src); err != nil {
|
||||
return nil, errors.Wrapf(err, "error adding single image instance %q", manifestToRead.instance)
|
||||
return nil, fmt.Errorf("error adding single image instance %q: %w", manifestToRead.instance, err)
|
||||
}
|
||||
} else {
|
||||
// Add the single image's contents.
|
||||
if err = addSingle(manifestBytes, manifestType, manifestToRead.src); err != nil {
|
||||
return nil, errors.Wrapf(err, "error adding single image instance %q", manifestToRead.instance)
|
||||
return nil, fmt.Errorf("error adding single image instance %q: %w", manifestToRead.instance, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,7 +281,7 @@ func (s *supplementedImageReference) NewImageSource(ctx context.Context, sys *ty
|
||||
}
|
||||
|
||||
func (s *supplementedImageReference) DeleteImage(ctx context.Context, sys *types.SystemContext) error {
|
||||
return errors.Errorf("deletion of images not implemented")
|
||||
return fmt.Errorf("deletion of images not implemented")
|
||||
}
|
||||
|
||||
func (s *supplementedImageSource) Close() error {
|
||||
@@ -313,17 +313,17 @@ func (s *supplementedImageSource) GetManifest(ctx context.Context, instanceDiges
|
||||
}
|
||||
return sourceInstance.GetManifest(ctx, requestInstanceDigest)
|
||||
}
|
||||
return nil, "", errors.Wrapf(ErrDigestNotFound, "error getting manifest for digest %q", *instanceDigest)
|
||||
return nil, "", fmt.Errorf("error getting manifest for digest %q: %w", *instanceDigest, ErrDigestNotFound)
|
||||
}
|
||||
|
||||
func (s *supplementedImageSource) GetBlob(ctx context.Context, blob types.BlobInfo, bic types.BlobInfoCache) (io.ReadCloser, int64, error) {
|
||||
sourceInstance, ok := s.instancesByBlobDigest[blob.Digest]
|
||||
if !ok {
|
||||
return nil, -1, errors.Wrapf(ErrBlobNotFound, "error blob %q in known instances", blob.Digest)
|
||||
return nil, -1, fmt.Errorf("error blob %q in known instances: %w", blob.Digest, ErrBlobNotFound)
|
||||
}
|
||||
src, ok := s.sourceInstancesByInstance[sourceInstance]
|
||||
if !ok {
|
||||
return nil, -1, errors.Wrapf(ErrDigestNotFound, "error getting image source for instance %q", sourceInstance)
|
||||
return nil, -1, fmt.Errorf("error getting image source for instance %q: %w", sourceInstance, ErrDigestNotFound)
|
||||
}
|
||||
return src.GetBlob(ctx, blob, bic)
|
||||
}
|
||||
@@ -364,7 +364,7 @@ func (s *supplementedImageSource) GetSignatures(ctx context.Context, instanceDig
|
||||
if src != nil {
|
||||
return src.GetSignatures(ctx, requestInstanceDigest)
|
||||
}
|
||||
return nil, errors.Wrapf(ErrDigestNotFound, "error finding instance for instance digest %q to read signatures", digest)
|
||||
return nil, fmt.Errorf("error finding instance for instance digest %q to read signatures: %w", digest, ErrDigestNotFound)
|
||||
}
|
||||
|
||||
func (s *supplementedImageSource) LayerInfosForCopy(ctx context.Context, instanceDigest *digest.Digest) ([]types.BlobInfo, error) {
|
||||
@@ -387,7 +387,7 @@ func (s *supplementedImageSource) LayerInfosForCopy(ctx context.Context, instanc
|
||||
if src != nil {
|
||||
blobInfos, err := src.LayerInfosForCopy(ctx, requestInstanceDigest)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error reading layer infos for copy from instance %q", instanceDigest)
|
||||
return nil, fmt.Errorf("error reading layer infos for copy from instance %q: %w", instanceDigest, err)
|
||||
}
|
||||
var manifestDigest digest.Digest
|
||||
if instanceDigest != nil {
|
||||
@@ -398,5 +398,5 @@ func (s *supplementedImageSource) LayerInfosForCopy(ctx context.Context, instanc
|
||||
}
|
||||
return blobInfos, nil
|
||||
}
|
||||
return nil, errors.Wrapf(ErrDigestNotFound, "error finding instance for instance digest %q to copy layers", errMsgDigest)
|
||||
return nil, fmt.Errorf("error finding instance for instance digest %q to copy layers: %w", errMsgDigest, ErrDigestNotFound)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user