Merge pull request #9027 from akhilerm/fix-ctr-forbidden-characters
This commit is contained in:
commit
420503072e
@ -24,6 +24,7 @@ import (
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/pkg/transfer/image"
|
||||
"github.com/distribution/reference"
|
||||
)
|
||||
|
||||
var tagCommand = cli.Command{
|
||||
@ -40,6 +41,10 @@ var tagCommand = cli.Command{
|
||||
Name: "local",
|
||||
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 {
|
||||
var (
|
||||
@ -60,6 +65,11 @@ var tagCommand = cli.Command{
|
||||
|
||||
if !context.BoolT("local") {
|
||||
for _, targetRef := range context.Args()[1:] {
|
||||
if !context.Bool("skip-reference-check") {
|
||||
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))
|
||||
if err != nil {
|
||||
return err
|
||||
@ -82,6 +92,11 @@ var tagCommand = cli.Command{
|
||||
}
|
||||
// Support multiple references for one command run
|
||||
for _, targetRef := range context.Args()[1:] {
|
||||
if !context.Bool("skip-reference-check") {
|
||||
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
|
||||
// Attempt to create the image first
|
||||
if _, err = imageService.Create(ctx, image); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user