Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crane label and crane annotate #974

Closed
imjasonh opened this issue Mar 22, 2021 · 9 comments
Closed

crane label and crane annotate #974

imjasonh opened this issue Mar 22, 2021 · 9 comments

Comments

@imjasonh
Copy link
Collaborator

crane label my-image \
  --label a=b \
  --label b=c
  --new_ref=my-image:labeled

The --new_ref flag is optional, and if omitted, crane label would tag over my-image.

This would necessitate a new mutate.Labels(v1.Image) method to mirror mutate.Annotations(v1.Image) being proposed in #960

This would add or overwrite existing labels/annotations only, and wouldn't facilitate unsetting existing values. I'm not sure whether that's a priority. Perhaps we could interpret --label a= to mean "unset", or --label a=<unset> as a sentinel value. Setting the value to an empty string and unsetting the value are notably separate things.

@jonjohnsonjr
Copy link
Collaborator

jonjohnsonjr commented Mar 22, 2021

Something dumb like --unlabel a?

@jonjohnsonjr
Copy link
Collaborator

One concern I have is an explosion of top-level commands that do various things. Maybe not a huge deal, but small mutations like this might be lump-able under crane mutate or something?

@jonjohnsonjr
Copy link
Collaborator

This would necessitate a new mutate.Labels(v1.Image) method

We can do this today with mutate.Config.

@imjasonh
Copy link
Collaborator Author

Something dumb like --unlabel a?

Love it.

One concern I have is an explosion of top-level commands that do various things. Maybe not a huge deal, but small mutations like this might be lump-able under crane mutate or something?

I'm fine that. Were you imagining crane mutate as a subcommand for other subcommands (crane mutate label and crane mutate annotations) or as a place to do a bunch of mutations (crane mutate --label a=b --annotation b=c) ?

We can do this today with mutate.Config.

Yep, good call.

@jonjohnsonjr
Copy link
Collaborator

Were you imagining crane mutate as a subcommand for other subcommands

Yeah this one seems easiest but there's a lot of interesting things we could do with a generic mutate command.

@imjasonh
Copy link
Collaborator Author

Yeah this one seems easiest but there's a lot of interesting things we could do with a generic mutate command.

Since we've got two pretty easy ones lined up, maybe let's think about putting them in one crane mutate and see how we like it.

Since it's all composable it should also work to do:

crane mutate label -l a=b $(crane mutate annotation -a b=c)

But that's a lot grosser than:

crane mutate label -l a=b -a b=c

And that second one wouldn't have to produce new intermediate manifests in the registry, which is nice.

@otaviof
Copy link

otaviof commented Mar 23, 2021

Hello 👋🏼 !

What do you think about a mixed approach? I like the ability to crane mutate ... labels and annotations at once. So, my suggestion is the following:

# add or remove labels, using "label" and "unlabel" sub-commands
crane label image a=b c=d
crane unlabel image a c

The same goes for annotations, with:

crane annotate image e=f
crane unannotate image e

As for mutate, I think we should let users inform the behavior by inspecting the actual flags, as in --[un]label and --[un]annotate. For instance:

# setting both labels and annotations with "mutate" sub-command:
crane mutate image --label a=b --label c=d --annotate e=f
crane mutate image --unlabel a --unlabel c --unannotate e

@imjasonh
Copy link
Collaborator Author

I think I'd prefer to have one way to label/annotate, to reduce code/docs/tests needed.

A CLI that can set multiple labels can also be used to set one, if you want to do it in multiple calls for whatever reason.

@imjasonh
Copy link
Collaborator Author

Closing in favor of the older #281

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

No branches or pull requests

3 participants