mirror of
https://github.com/containers/podman.git
synced 2025-12-09 23:27:09 +08:00
vendor: bump c/common to dbeb17e40c80
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
This commit is contained in:
33
vendor/github.com/containers/common/libimage/copier.go
generated
vendored
33
vendor/github.com/containers/common/libimage/copier.go
generated
vendored
@@ -21,8 +21,10 @@ import (
|
||||
"github.com/containers/image/v5/signature"
|
||||
"github.com/containers/image/v5/signature/signer"
|
||||
storageTransport "github.com/containers/image/v5/storage"
|
||||
"github.com/containers/image/v5/transports"
|
||||
"github.com/containers/image/v5/types"
|
||||
encconfig "github.com/containers/ocicrypt/config"
|
||||
"github.com/containers/storage"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -175,8 +177,8 @@ type Copier struct {
|
||||
// newCopier creates a Copier based on a runtime's system context.
|
||||
// Note that fields in options *may* overwrite the counterparts of
|
||||
// the specified system context. Please make sure to call `(*Copier).Close()`.
|
||||
func (r *Runtime) newCopier(options *CopyOptions, reportResolvedReference *types.ImageReference) (*Copier, error) {
|
||||
return NewCopier(options, r.SystemContext(), reportResolvedReference)
|
||||
func (r *Runtime) newCopier(options *CopyOptions) (*Copier, error) {
|
||||
return NewCopier(options, r.SystemContext(), nil)
|
||||
}
|
||||
|
||||
// storageAllowedPolicyScopes overrides the policy for local storage
|
||||
@@ -350,6 +352,12 @@ func (c *Copier) Close() error {
|
||||
// Copy the source to the destination. Returns the bytes of the copied
|
||||
// manifest which may be used for digest computation.
|
||||
func (c *Copier) Copy(ctx context.Context, source, destination types.ImageReference) ([]byte, error) {
|
||||
return c.copyInternal(ctx, source, destination, nil)
|
||||
}
|
||||
|
||||
// Copy the source to the destination. Returns the bytes of the copied
|
||||
// manifest which may be used for digest computation.
|
||||
func (c *Copier) copyInternal(ctx context.Context, source, destination types.ImageReference, reportResolvedReference *types.ImageReference) ([]byte, error) {
|
||||
logrus.Debugf("Copying source image %s to destination image %s", source.StringWithinTransport(), destination.StringWithinTransport())
|
||||
|
||||
// Avoid running out of time when running inside a systemd unit by
|
||||
@@ -454,6 +462,11 @@ func (c *Copier) Copy(ctx context.Context, source, destination types.ImageRefere
|
||||
var returnManifest []byte
|
||||
f := func() error {
|
||||
opts := c.imageCopyOptions
|
||||
// This is already set when `newCopier` was called but there is an option
|
||||
// to override it by callers if needed.
|
||||
if reportResolvedReference != nil {
|
||||
opts.ReportResolvedReference = reportResolvedReference
|
||||
}
|
||||
if sourceInsecure != nil {
|
||||
value := types.NewOptionalBool(*sourceInsecure)
|
||||
opts.SourceCtx.DockerInsecureSkipTLSVerify = value
|
||||
@@ -472,6 +485,22 @@ func (c *Copier) Copy(ctx context.Context, source, destination types.ImageRefere
|
||||
return returnManifest, retry.IfNecessary(ctx, f, &c.retryOptions)
|
||||
}
|
||||
|
||||
func (c *Copier) copyToStorage(ctx context.Context, source, destination types.ImageReference) (*storage.Image, error) {
|
||||
var resolvedReference types.ImageReference
|
||||
_, err := c.copyInternal(ctx, source, destination, &resolvedReference)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("internal error: unable to copy from source %s: %w", source, err)
|
||||
}
|
||||
if resolvedReference == nil {
|
||||
return nil, fmt.Errorf("internal error: After attempting to copy %s, resolvedReference is nil", source)
|
||||
}
|
||||
_, image, err := storageTransport.ResolveReference(resolvedReference)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("resolving an already-resolved reference %q to the pulled image: %w", transports.ImageName(resolvedReference), err)
|
||||
}
|
||||
return image, nil
|
||||
}
|
||||
|
||||
// checkRegistrySourcesAllows checks the $BUILD_REGISTRY_SOURCES environment
|
||||
// variable, if it's set. The contents are expected to be a JSON-encoded
|
||||
// github.com/openshift/api/config/v1.Image, set by an OpenShift build
|
||||
|
||||
Reference in New Issue
Block a user