c8d/load: Handle compressed archives
Allow to load images from compressed tars. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
f6fa56194f
commit
fcabc48ee4
1 changed files with 8 additions and 1 deletions
|
@ -17,6 +17,7 @@ import (
|
|||
"github.com/docker/docker/api/types/events"
|
||||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/errdefs"
|
||||
dockerarchive "github.com/docker/docker/pkg/archive"
|
||||
"github.com/docker/docker/pkg/platforms"
|
||||
"github.com/docker/docker/pkg/streamformatter"
|
||||
"github.com/opencontainers/image-spec/specs-go"
|
||||
|
@ -148,6 +149,12 @@ func leaseContent(ctx context.Context, store content.Store, leasesManager leases
|
|||
// complement of ExportImage. The input stream is an uncompressed tar
|
||||
// ball containing images and metadata.
|
||||
func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error {
|
||||
decompressed, err := dockerarchive.DecompressStream(inTar)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to decompress input tar archive")
|
||||
}
|
||||
defer decompressed.Close()
|
||||
|
||||
opts := []containerd.ImportOpt{
|
||||
// TODO(vvoland): Allow user to pass platform
|
||||
containerd.WithImportPlatform(cplatforms.All),
|
||||
|
@ -164,7 +171,7 @@ func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, outSt
|
|||
}),
|
||||
}
|
||||
|
||||
imgs, err := i.client.Import(ctx, inTar, opts...)
|
||||
imgs, err := i.client.Import(ctx, decompressed, opts...)
|
||||
if err != nil {
|
||||
log.G(ctx).WithError(err).Debug("failed to import image to containerd")
|
||||
return errdefs.System(err)
|
||||
|
|
Loading…
Add table
Reference in a new issue