builder: dockerfile: allow LABEL w/o a value#17344
Conversation
6590281 to
136a733
Compare
|
Thanks @runcom, yes it was the intent to be able to set a label without value (using an empty string |
|
@thaJeztah the only issue I see here now is that we allowed this: which produces |
|
Hm, good one. I never really liked |
|
I'd say it's still a fix to a wrong behavior in |
136a733 to
3471484
Compare
|
I agree that this is a more user-friendly UX. I think that at some point in the (build time) |
oh, that would definitely help here |
|
/cc @tiborvass @duglin ^^ |
|
I'll fix the failing tests (as they rely on the old behavior) as soon as we decide what's good to do here |
|
ping @rhatdan since I think he added LABEL support and might be able to say whether its ok to do this, or not. |
|
I'm not a fan of the |
|
As you said @duglin I think this has been done to maintain the same behavior as ENV but we're actually allowing docker run with just a label key. Either we edit the doc and add ="" or fix this for LABEL :( |
@rhatdan started the initial implementation, and @ibuildthecloud completed it :-) |
|
I just intended to match the --env behaviour. Although I would prefer name=value. And I would recomend LABEL NAME="" |
|
|
|
runcon could you build a patch to prevent use of no ="" or no NAME VALUE |
|
ping @cpuguy83 |
|
any thoughts on this? O:) |
|
This is supported for |
True, it's a difference, but cli is a different UX in general, i.e. @runcom will this PR break backward compatibility? i.e., will I do prefer the |
it will right now.. |
|
Makes sense I think |
Also add a bunch of tests about labels Signed-off-by: Antonio Murdaca <[email protected]>
3471484 to
ff559b3
Compare
|
rebased :)
@thaJeztah this PR break backward compatibility and maybe it is better to just update the doc, but I really believe this is the correct way to handle LABEL(s) even if you can do LABEL="". ping @tiborvass @duglin @LK4D4 |
|
I looked at the documentation; https://docs.docker.com/engine/userguide/labels-custom-metadata/ and https://docs.docker.com/engine/reference/builder/#label All examples and the documentation mention that We may want to update this line to more explicitly mention that Reading those; I agree, and I think we should use |
|
@runcom yeah, however making breaking changes is worse :/ |
I'm fine updating docs then, really :) |
|
I'm not particularly a fan of this. As @rhatdan pointed out the intended behavior was just to follow the same logic as ENV. Personally I'd rather not have to remember that ENV A B and LABEL A B are parsed differently. I thinks LABEL A="" is perfectly fine. |
|
Oh wait. will LABEL A B now become two keys? If so, then that is way too breaking of a change. But then what will LABEL A B C become? |
|
Ignoring any inconsistency between the docker cmd line and what people see in the Dockerfile, I think should be parsed the same way. Which, right now, will produce one env var (env1) with a value of "env2" and one label (label1) with a value of "label2". Now, to the So, while it might appear that we allow labels and env vars to be specified on the cmd line w/o values, I don't think we do. Instead what we allow people to say is "grab the value from an env var". Net: I think this might be a doc issue. |
|
@duglin Doing |
|
@ibuildthecloud that could be - I don't use labels so I'm not sure what the expected behavior should be, but even if we did change it so that it used "" instead of the corresponding env var I think keeping the current Dockerfile syntax/behavior is probably correct. IOW, forcing them to add |
|
Alright, looks like the majority is for making this a documentation-only change, and keep the current behavior. @runcom shall we close this one, and create a new, fresh PR? |
|
@thaJeztah I'll update docs to mention that users should add |
|
@runcom sounds good, also https://docs.docker.com/engine/userguide/labels-custom-metadata/#add-labels-to-images should be updated, changing to (I don't think we should explicitly mention |
Also add a bunch of tests about labels
Fix #16526
I don't see why the Dockerfile shouldn't allow
LABELw/o value, if anyone remembers this was intentional I'll close thisI also noticed we're allowing the old
KEY name valueformat forLABELwhich seems wrong given we should allowLABELw/o valueSigned-off-by: Antonio Murdaca [email protected]