From cb7c780af2394ab08d5d8a3932ca7437074ae179 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Tue, 30 Apr 2019 21:54:22 -0700 Subject: [PATCH] ctr images import: add --no-unpack option Signed-off-by: Benjamin Elder --- cmd/ctr/commands/images/import.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/cmd/ctr/commands/images/import.go b/cmd/ctr/commands/images/import.go index 53aa91d02..26637fabc 100644 --- a/cmd/ctr/commands/images/import.go +++ b/cmd/ctr/commands/images/import.go @@ -68,6 +68,10 @@ If foobar.tar contains an OCI ref named "latest" and anonymous ref "sha256:deadb Name: "all-platforms", Usage: "imports content for all platforms, false by default", }, + cli.BoolFlag{ + Name: "no-unpack", + Usage: "skip unpacking the images, false by default", + }, }, commands.SnapshotterFlags...), 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 } - 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 { - // TODO: Allow configuration of the platform - image := containerd.NewImage(client, img) + for _, img := range imgs { + // TODO: Allow configuration of the platform + image := containerd.NewImage(client, img) - // TODO: Show unpack status - fmt.Printf("unpacking %s (%s)...", img.Name, img.Target.Digest) - err = image.Unpack(ctx, context.String("snapshotter")) - if err != nil { - return err + // TODO: Show unpack status + fmt.Printf("unpacking %s (%s)...", img.Name, img.Target.Digest) + err = image.Unpack(ctx, context.String("snapshotter")) + if err != nil { + return err + } + fmt.Println("done") } - fmt.Println("done") } return nil },