Skip to content

Double quote build args to support complex values - #159

Merged
vito merged 2 commits into
concourse:masterfrom
jfmyers9:wip-fix-multiline-build-args
Dec 13, 2017
Merged

vito merged 2 commits into
concourse:masterfrom
jfmyers9:wip-fix-multiline-build-args

Conversation

@jfmyers9

@jfmyers9 jfmyers9 commented Dec 5, 2017

Copy link
Copy Markdown
Contributor

This change properly escapes multiline/complex build arg values when calling docker build.

Fixes #158, Fixes #79

Note: We couldn't get the tests to run on OSX. We think the README.md needs some updating?

Signed-off-by: Lyle Franklin [email protected]

@pivotal-issuemaster

Copy link
Copy Markdown

@jfmyers9 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-issuemaster

Copy link
Copy Markdown

@jfmyers9 Thank you for signing the Contributor License Agreement!

@jfmyers9

jfmyers9 commented Dec 5, 2017

Copy link
Copy Markdown
Contributor Author

We believe this change may fix the above issues. As said we struggled to run the out tests when running docker build. The intention of this PR is to hopefully drive the conversation forward on the linked issues.

@ljfranklin

Copy link
Copy Markdown

Don't merge this, it doesn't work :) Fixing it now...

@ljfranklin

Copy link
Copy Markdown

Updated, should be working now. This is the simplest solution we could find which correctly quoted the values of build args.

@vito

vito commented Dec 7, 2017 •

Copy link
Copy Markdown
Contributor

Sorry, the build has been failing for a bit and we hadn't noticed. It should be fixed now; I re-ran the build and it's green. docker build should work again too.

@vito vito added the bug label Dec 8, 2017
@vito

vito commented Dec 12, 2017

Copy link
Copy Markdown
Contributor

@jfmyers9 @ljfranklin Now that the tests are runnable again, do you think there are any that could be added for this?

This change properly escapes multiline build arg values when calling `docker build`.

Fixes #158, Fixes #79

Signed-off-by: Lyle Franklin <[email protected]>
@jfmyers9

Copy link
Copy Markdown
Contributor Author

@vito This was somewhat difficult to test due to nature of the out integration tests and the behavior of the echo command.. Let me know what you think of the test case added.

This change adds a test that validates that complex arguments passed to
the docker command in the out script are properly quoted. It does this
by validating that arguments with newlines and spaces are only passed
into the docker command as one argument.

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not sure but i think the tests might be demonstrating that the linebreak case isn't actually fixed

Comment thread tests/fixtures/bin/docker
echo "DOCKER:" "$@"

for var in "$@"; do
echo "DOCKER ARG:" "$var"

This comment was marked as spam.

Comment thread tests/out_test.go
Expect(session.Err).To(gbytes.Say(dockerarg(`--build-arg`)))
Expect(session.Err).To(gbytes.Say(dockerarg(`arg1=arg with space`)))
Expect(session.Err).To(gbytes.Say(dockerarg(`--build-arg`)))
Expect(session.Err).To(gbytes.Say(dockerarg(`arg2=arg with\nnewline`)))

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@vito vito removed the needs-test label Dec 13, 2017
@vito

vito commented Dec 13, 2017 via email

Copy link
Copy Markdown
Contributor

@vito

vito commented Dec 13, 2017

Copy link
Copy Markdown
Contributor

Thanks!

@vito
vito merged commit 4bb8a06 into concourse:master Dec 13, 2017
@krishicks

krishicks commented Dec 13, 2017 •

Copy link
Copy Markdown
Contributor

I wanted to pass GOOGLE_CREDENTIALS_JSON as a build arg and so also ran into this issue. I pulled this repo, built the image, tried using it, and am seeing:

/opt/resource/common.sh: line 47: SKIP_PRIVILEGED: unbound variable

I don't see how this change relates to that problem; the line containing $SKIP_PRIVILEGED is a month old, meaning it should be in 3.8.0, and yet I don't see that problem in 3.8.0's docker-image-resource.

For what it's worth:

$ sudo docker --version
Docker version 17.09.1-ce, build 19e2cf6

$ sudo docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
golang                        alpine              f421e93ece9c        12 days ago         269MB
alpine                        edge                bf9187896446        12 days ago         4.14MB

@krishicks

Copy link
Copy Markdown
Contributor

The fix for this was to set privileged: true in the resource_type declaration per a search in Concourse Slack.

@krishicks

Copy link
Copy Markdown
Contributor

Added #160 to fix the above and added documentation for others.

vito added a commit that referenced this pull request Dec 18, 2017
@vito vito modified the milestone: v3.9.0 Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants