vendor latest c/common main

Includes several rootless-netns fixes.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2024-04-02 18:45:45 +02:00
parent 976640474b
commit ce04fbc16a
47 changed files with 661 additions and 267 deletions

View File

@ -13,6 +13,7 @@ import (
dockerArchiveTransport "github.com/containers/image/v5/docker/archive"
ociArchiveTransport "github.com/containers/image/v5/oci/archive"
ociTransport "github.com/containers/image/v5/oci/layout"
"github.com/containers/image/v5/transports"
"github.com/containers/image/v5/types"
"github.com/sirupsen/logrus"
)
@ -21,6 +22,30 @@ type LoadOptions struct {
CopyOptions
}
// doLoadReference does the heavy lifting for LoadReference() and Load(),
// without adding debug messages or handling defaults.
func (r *Runtime) doLoadReference(ctx context.Context, ref types.ImageReference, options *LoadOptions) (images []string, transportName string, err error) {
transportName = ref.Transport().Name()
switch transportName {
case dockerArchiveTransport.Transport.Name():
images, err = r.loadMultiImageDockerArchive(ctx, ref, &options.CopyOptions)
default:
images, err = r.copyFromDefault(ctx, ref, &options.CopyOptions)
}
return images, ref.Transport().Name(), err
}
// LoadReference loads one or more images from the specified location.
func (r *Runtime) LoadReference(ctx context.Context, ref types.ImageReference, options *LoadOptions) ([]string, error) {
logrus.Debugf("Loading image from %q", transports.ImageName(ref))
if options == nil {
options = &LoadOptions{}
}
images, _, err := r.doLoadReference(ctx, ref, options)
return images, err
}
// Load loads one or more images (depending on the transport) from the
// specified path. The path may point to an image the following transports:
// oci, oci-archive, dir, docker-archive.
@ -41,8 +66,7 @@ func (r *Runtime) Load(ctx context.Context, path string, options *LoadOptions) (
if err != nil {
return nil, ociTransport.Transport.Name(), err
}
images, err := r.copyFromDefault(ctx, ref, &options.CopyOptions)
return images, ociTransport.Transport.Name(), err
return r.doLoadReference(ctx, ref, options)
},
// OCI-ARCHIVE
@ -52,8 +76,7 @@ func (r *Runtime) Load(ctx context.Context, path string, options *LoadOptions) (
if err != nil {
return nil, ociArchiveTransport.Transport.Name(), err
}
images, err := r.copyFromDefault(ctx, ref, &options.CopyOptions)
return images, ociArchiveTransport.Transport.Name(), err
return r.doLoadReference(ctx, ref, options)
},
// DOCKER-ARCHIVE
@ -63,8 +86,7 @@ func (r *Runtime) Load(ctx context.Context, path string, options *LoadOptions) (
if err != nil {
return nil, dockerArchiveTransport.Transport.Name(), err
}
images, err := r.loadMultiImageDockerArchive(ctx, ref, &options.CopyOptions)
return images, dockerArchiveTransport.Transport.Name(), err
return r.doLoadReference(ctx, ref, options)
},
// DIR
@ -74,8 +96,7 @@ func (r *Runtime) Load(ctx context.Context, path string, options *LoadOptions) (
if err != nil {
return nil, dirTransport.Transport.Name(), err
}
images, err := r.copyFromDefault(ctx, ref, &options.CopyOptions)
return images, dirTransport.Transport.Name(), err
return r.doLoadReference(ctx, ref, options)
},
} {
loadedImages, transportName, err := f()