feat: tag image using Transfer api
Signed-off-by: Jian Zeng <anonymousknight96@gmail.com>
This commit is contained in:
@@ -19,9 +19,11 @@ package images
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/urfave/cli"
|
||||
"github.com/containerd/containerd/pkg/transfer/image"
|
||||
)
|
||||
|
||||
var tagCommand = cli.Command{
|
||||
@@ -34,6 +36,10 @@ var tagCommand = cli.Command{
|
||||
Name: "force",
|
||||
Usage: "Force target_ref to be created, regardless if it already exists",
|
||||
},
|
||||
cli.BoolTFlag{
|
||||
Name: "local",
|
||||
Usage: "run tag locally rather than through transfer API",
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) error {
|
||||
var (
|
||||
@@ -52,6 +58,17 @@ var tagCommand = cli.Command{
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
if !context.BoolT("local") {
|
||||
for _, targetRef := range context.Args()[1:] {
|
||||
err = client.Transfer(ctx, image.NewStore(ref), image.NewStore(targetRef))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(targetRef)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
ctx, done, err := client.WithLease(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user