Skip to content

Conversation

ericsmalling
Copy link

Fixes #1797

pkg/crane/tag.go Outdated
// Tag adds tag to the remote img.
func Tag(img, tag string, opt ...Option) error {
// Tag adds one or more tags to the remote img.
func Tag(img string, tags any, opt ...Option) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an API breaking change.

If we wanted to avoid this, we could maybe have WithTags(string...) Option, but even that might be kind of annoying.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. I'll work on this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New version pushed, let me know what you think.

// Apply each tag
for i, tag := range tagList {
dst := ref.Context().Tag(tag)
if err := remote.Tag(dst, desc, o.Remote...); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nice thing about tagging being done on only one tag is that we know exactly whether to continue or fail when tagging fails. When there are multiple tags requested and one fails, should we:

  1. fail right away
  2. try to undo the successful tags?
  3. keep trying to apply more tags?

I don't have a super strong opinion, and failing right away like this is probably fine, but with single-tagging it's up to the caller what to do. I guess it's still up to them, and they could just keep using single-tagging.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's what I was thinking about here

Signed-off-by: Eric Smalling <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

question: add multiple tags to target image
2 participants