Merge pull request #3259 from BenTheElder/no-unpack

ctr images import: add --no-unpack option
This commit is contained in:
Phil Estes 2019-05-05 12:29:45 -07:00 committed by GitHub
commit d71c7ada27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,6 +68,10 @@ If foobar.tar contains an OCI ref named "latest" and anonymous ref "sha256:deadb
Name: "all-platforms", Name: "all-platforms",
Usage: "imports content for all platforms, false by default", Usage: "imports content for all platforms, false by default",
}, },
cli.BoolFlag{
Name: "no-unpack",
Usage: "skip unpacking the images, false by default",
},
}, commands.SnapshotterFlags...), }, commands.SnapshotterFlags...),
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
@ -119,19 +123,21 @@ If foobar.tar contains an OCI ref named "latest" and anonymous ref "sha256:deadb
return closeErr return closeErr
} }
log.G(ctx).Debugf("unpacking %d images", len(imgs)) if !context.Bool("no-unpack") {
log.G(ctx).Debugf("unpacking %d images", len(imgs))
for _, img := range imgs { for _, img := range imgs {
// TODO: Allow configuration of the platform // TODO: Allow configuration of the platform
image := containerd.NewImage(client, img) image := containerd.NewImage(client, img)
// TODO: Show unpack status // TODO: Show unpack status
fmt.Printf("unpacking %s (%s)...", img.Name, img.Target.Digest) fmt.Printf("unpacking %s (%s)...", img.Name, img.Target.Digest)
err = image.Unpack(ctx, context.String("snapshotter")) err = image.Unpack(ctx, context.String("snapshotter"))
if err != nil { if err != nil {
return err return err
}
fmt.Println("done")
} }
fmt.Println("done")
} }
return nil return nil
}, },