add a new flag "skip-reference-check" to skip reference name check
Signed-off-by: Akhil Mohan <makhil@vmware.com>
This commit is contained in:
parent
6ec0d4a3ad
commit
4b59d67dd4
@ -24,7 +24,7 @@ import (
|
|||||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/pkg/transfer/image"
|
"github.com/containerd/containerd/pkg/transfer/image"
|
||||||
"github.com/containerd/containerd/reference/docker"
|
"github.com/distribution/reference"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tagCommand = cli.Command{
|
var tagCommand = cli.Command{
|
||||||
@ -41,6 +41,10 @@ var tagCommand = cli.Command{
|
|||||||
Name: "local",
|
Name: "local",
|
||||||
Usage: "Run tag locally rather than through transfer API",
|
Usage: "Run tag locally rather than through transfer API",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "skip-reference-check",
|
||||||
|
Usage: "Skip the strict check for reference names",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: func(context *cli.Context) error {
|
Action: func(context *cli.Context) error {
|
||||||
var (
|
var (
|
||||||
@ -61,8 +65,10 @@ var tagCommand = cli.Command{
|
|||||||
|
|
||||||
if !context.BoolT("local") {
|
if !context.BoolT("local") {
|
||||||
for _, targetRef := range context.Args()[1:] {
|
for _, targetRef := range context.Args()[1:] {
|
||||||
if _, err := docker.ParseAnyReference(targetRef); err != nil {
|
if !context.Bool("skip-reference-check") {
|
||||||
return fmt.Errorf("error parsing reference: %q is not a valid repository/tag %v", targetRef, err)
|
if _, err := reference.ParseAnyReference(targetRef); err != nil {
|
||||||
|
return fmt.Errorf("error parsing reference: %q is not a valid repository/tag %v", targetRef, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
err = client.Transfer(ctx, image.NewStore(ref), image.NewStore(targetRef))
|
err = client.Transfer(ctx, image.NewStore(ref), image.NewStore(targetRef))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -86,8 +92,10 @@ var tagCommand = cli.Command{
|
|||||||
}
|
}
|
||||||
// Support multiple references for one command run
|
// Support multiple references for one command run
|
||||||
for _, targetRef := range context.Args()[1:] {
|
for _, targetRef := range context.Args()[1:] {
|
||||||
if _, err := docker.ParseAnyReference(targetRef); err != nil {
|
if !context.Bool("skip-reference-check") {
|
||||||
return fmt.Errorf("error parsing reference: %q is not a valid repository/tag %v", targetRef, err)
|
if _, err := reference.ParseAnyReference(targetRef); err != nil {
|
||||||
|
return fmt.Errorf("error parsing reference: %q is not a valid repository/tag %v", targetRef, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
image.Name = targetRef
|
image.Name = targetRef
|
||||||
// Attempt to create the image first
|
// Attempt to create the image first
|
||||||
|
Loading…
Reference in New Issue
Block a user