Skip to content

Commit 6e4d32c

Browse files
committed
Expose clobber refusal error
This enables consumers of this library to handle the error for clobber refusal in a Go idiomatic manner. Signed-off-by: Paulo Gomes <[email protected]>
1 parent aab7c77 commit 6e4d32c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/crane/copy.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ import (
2626
"golang.org/x/sync/errgroup"
2727
)
2828

29+
// ErrRefusingToClobberExistingTag is returned when NoClobber is true and the
30+
// tag already exists in the target registry/repo.
31+
var ErrRefusingToClobberExistingTag = errors.New("refusing to clobber existing tag")
32+
2933
// Copy copies a remote image or index from src to dst.
3034
func Copy(src, dst string, opt ...Option) error {
3135
o := makeOptions(opt...)
@@ -58,7 +62,7 @@ func Copy(src, dst string, opt ...Option) error {
5862
}
5963

6064
if head != nil {
61-
return fmt.Errorf("refusing to clobber existing tag %s@%s", tag, head.Digest)
65+
return fmt.Errorf("%w %s@%s", ErrRefusingToClobberExistingTag, tag, head.Digest)
6266
}
6367
}
6468
}

0 commit comments

Comments
 (0)