client: Allow setting image labels on Pull() and Import()
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
@@ -39,7 +39,7 @@ not use this implementation as a guide. The end goal should be having metadata,
|
||||
content and snapshots ready for a direct use via the 'ctr run'.
|
||||
|
||||
Most of this is experimental and there are few leaps to make this work.`,
|
||||
Flags: registryFlags,
|
||||
Flags: append(registryFlags, labelFlag),
|
||||
Action: func(clicontext *cli.Context) error {
|
||||
var (
|
||||
ref = clicontext.Args().First()
|
||||
@@ -84,8 +84,13 @@ func fetch(ctx context.Context, ref string, clicontext *cli.Context) (containerd
|
||||
})
|
||||
|
||||
log.G(pctx).WithField("image", ref).Debug("fetching")
|
||||
|
||||
img, err := client.Pull(pctx, ref, containerd.WithResolver(resolver), containerd.WithImageHandler(h), containerd.WithSchema1Conversion)
|
||||
labels := labelArgs(clicontext.StringSlice("label"))
|
||||
img, err := client.Pull(pctx, ref,
|
||||
containerd.WithPullLabels(labels),
|
||||
containerd.WithResolver(resolver),
|
||||
containerd.WithImageHandler(h),
|
||||
containerd.WithSchema1Conversion,
|
||||
)
|
||||
stopProgress()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -21,12 +21,14 @@ var imagesImportCommand = cli.Command{
|
||||
Value: "",
|
||||
Usage: "reference object e.g. tag@digest (default: use the object specified in ref)",
|
||||
},
|
||||
labelFlag,
|
||||
},
|
||||
Action: func(clicontext *cli.Context) error {
|
||||
var (
|
||||
ref = clicontext.Args().First()
|
||||
in = clicontext.Args().Get(1)
|
||||
refObject = clicontext.String("ref-object")
|
||||
labels = labelArgs(clicontext.StringSlice("label"))
|
||||
)
|
||||
|
||||
ctx, cancel := appContext(clicontext)
|
||||
@@ -50,6 +52,7 @@ var imagesImportCommand = cli.Command{
|
||||
ref,
|
||||
r,
|
||||
containerd.WithRefObject(refObject),
|
||||
containerd.WithImportLabels(labels),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -20,7 +20,7 @@ command. As part of this process, we do the following:
|
||||
2. Prepare the snapshot filesystem with the pulled resources.
|
||||
3. Register metadata for the image.
|
||||
`,
|
||||
Flags: append(registryFlags, snapshotterFlags...),
|
||||
Flags: append(registryFlags, append(snapshotterFlags, labelFlag)...),
|
||||
Action: func(clicontext *cli.Context) error {
|
||||
var (
|
||||
ref = clicontext.Args().First()
|
||||
|
||||
@@ -57,6 +57,11 @@ var (
|
||||
},
|
||||
}
|
||||
|
||||
labelFlag = cli.StringSliceFlag{
|
||||
Name: "label",
|
||||
Usage: "labels to attach to the pulled image",
|
||||
}
|
||||
|
||||
registryFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "skip-verify,k",
|
||||
|
||||
Reference in New Issue
Block a user