-
Notifications
You must be signed in to change notification settings - Fork 286
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
Allow build --env option to be comma separated list. #1212
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
So acceptance test have detected some inconsistency. Currently syntax like this one works: On the other hand it really differs only if user pass quotation marks to the command (escaped them in shell) so they would get stripped by flags library - they could just omit quotes in that case.
I have changed acceptance test to avoid that first syntax. |
acceptance/acceptance_test.go
Outdated
@@ -1482,7 +1482,7 @@ func testAcceptance( | |||
"build", repoName, | |||
"-p", filepath.Join("testdata", "mock_app"), | |||
"--env", "DETECT_ENV_BUILDPACK=true", | |||
"--env", `ENV1_CONTENTS="Env1 Layer Contents From Command Line"`, | |||
"--env", `"ENV1_CONTENTS=Env1 Layer Contents From Command Line"`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little concerned by this new change. I can't see this as expected behaviour from a user's perspective. What's the purpose of quoting the key and value?
I would have expected the following to work.
--env 'KEY_1=VAL1,KEY_2="VAL 2"'
key | value |
---|---|
KEY_1 | VAL1 |
KEY_2 | VAL 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I have tried implementing that, but this is way more complicated then I thought it will be - library does not support it so we have to parse it on our own.
@kramarz Unfortunately this implementation is clashing with being able to provide Windows paths in environment variable hence why tests are failing. Here are the relevant logs from the test outputs: |
Right, we don't want to break such use cases. What about different approach to escaping? Original solution with using
Please let me know if you have any suggestions for this issue. |
it("sets flag variables", func() { | ||
mockClient.EXPECT(). | ||
Build(gomock.Any(), EqBuildOptionsWithEnv(map[string]string{ | ||
"KEY1": `VALUE"`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused by this - why is it matching
`VALUE"` and not `VALUE""`
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""
escapes "
- it is the same as in CSV specification. The same escaping is used for other flags: buildpack
and tag
since they use StringSliceVarP
. I just wanted to be consistent with what is already being used.
Sorry for delay - I was on holiday. I see there are some errors about missing tests - I ll try to add them this week.
According to help (https://buildpacks.io/docs/tools/pack/cli/pack_build/) it should already be this way. Escaping is done based on CSV: https://en.wikipedia.org/wiki/Comma-separated_values Signed-off-by: Kuba Skiepko <[email protected]>
@kramarz, seems like we have some use cases that were broken by this change. We had to revert it. The use cases brought up the fact that this may be harder to resolve than originally expected. I believe that the right path forward would be not to support (and therefore not mention) env vars to be listed together in a single flag. |
Summary
According to help
(https://buildpacks.io/docs/tools/pack/cli/pack_build/) it should
already be this way.
Before
only
--env KEY1=VAL1 --env KEY2=VAL2
syntax is allowedAfter
also
--env KEY1=VAL1,KEY2=VAL2
syntax is allowedDocumentation