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

adding LABEL command #44

Merged
merged 5 commits into from
Mar 26, 2018
Merged

adding LABEL command #44

merged 5 commits into from
Mar 26, 2018

Conversation

sharifelgamal
Copy link
Contributor

Fixes #7


for _, kvp := range labels {
logrus.Infof("Applying label %s=%s", kvp.Key, kvp.Value)
existingLabels[kvp.Key] = kvp.Value
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you might need to parse out backslashes or quotes before setting the label (I had to for the ENV command, so this might be similar)?

for example, the command
LABEL myDog=Rex\ The\ Dog \

in the Dockerfile should be saved as myDog="Rex The Dog" in the config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

existingLabels := config.Labels

// Let's unescape values before setting the label
shlex := shell.NewLex('\\')
Copy link
Collaborator

Choose a reason for hiding this comment

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

So there are two different escape tokens, if you pass in a string version of the command (like here) then the parser will determine which one it is for you, and you can pass that into shell.NewLex()

expectedLabels := map[string]string{
"foo": "override",
"bar": "baz",
"multiword": "lots of words",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that this should parse to "lots\ of\ words", since the first backslash should indicate that the second remains. Hopefully if you make the change above, this will just parse correctly?

Copy link
Collaborator

@priyawadhwa priyawadhwa Mar 26, 2018

Choose a reason for hiding this comment

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

whoops, sorry, it actually should stay "lots\\ of\\ words" in the config.

Copy link
Contributor Author

@sharifelgamal sharifelgamal Mar 26, 2018

Choose a reason for hiding this comment

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

yeah, if I pass in "lots\\\\ of\\\\ words" then I'll get "lots\ of\ words" back out.

@sharifelgamal sharifelgamal merged commit f38dd2d into GoogleContainerTools:master Mar 26, 2018
@sharifelgamal sharifelgamal deleted the label-cmd branch March 27, 2018 17:39
@priyawadhwa priyawadhwa added the area/dockerfile-command For all bugs related to dockerfile file commands label Feb 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dockerfile-command For all bugs related to dockerfile file commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants