Skip to content

Commit d71c7ad

Browse files
authored
Merge pull request #3259 from BenTheElder/no-unpack
ctr images import: add --no-unpack option
2 parents 82f2ac7 + cb7c780 commit d71c7ad

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

cmd/ctr/commands/images/import.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ If foobar.tar contains an OCI ref named "latest" and anonymous ref "sha256:deadb
6868
Name: "all-platforms",
6969
Usage: "imports content for all platforms, false by default",
7070
},
71+
cli.BoolFlag{
72+
Name: "no-unpack",
73+
Usage: "skip unpacking the images, false by default",
74+
},
7175
}, commands.SnapshotterFlags...),
7276

7377
Action: func(context *cli.Context) error {
@@ -119,19 +123,21 @@ If foobar.tar contains an OCI ref named "latest" and anonymous ref "sha256:deadb
119123
return closeErr
120124
}
121125

122-
log.G(ctx).Debugf("unpacking %d images", len(imgs))
126+
if !context.Bool("no-unpack") {
127+
log.G(ctx).Debugf("unpacking %d images", len(imgs))
123128

124-
for _, img := range imgs {
125-
// TODO: Allow configuration of the platform
126-
image := containerd.NewImage(client, img)
129+
for _, img := range imgs {
130+
// TODO: Allow configuration of the platform
131+
image := containerd.NewImage(client, img)
127132

128-
// TODO: Show unpack status
129-
fmt.Printf("unpacking %s (%s)...", img.Name, img.Target.Digest)
130-
err = image.Unpack(ctx, context.String("snapshotter"))
131-
if err != nil {
132-
return err
133+
// TODO: Show unpack status
134+
fmt.Printf("unpacking %s (%s)...", img.Name, img.Target.Digest)
135+
err = image.Unpack(ctx, context.String("snapshotter"))
136+
if err != nil {
137+
return err
138+
}
139+
fmt.Println("done")
133140
}
134-
fmt.Println("done")
135141
}
136142
return nil
137143
},

0 commit comments

Comments
 (0)