summaryrefslogtreecommitdiff
path: root/client/image_build_test.go
diff options
context:
space:
mode:
authorDoug Davis <dug@us.ibm.com>2016-12-03 05:46:04 -0800
committerDoug Davis <dug@us.ibm.com>2016-12-07 07:41:55 -0800
commitcdb8ea90b04683adb25c8ccd71b6eaedc44b51e2 (patch)
tree1a98157d26df70f10efc268dc16e34af541a1132 /client/image_build_test.go
parent3cb310c21049f652dd00d20899cb1ece1ee9aa8f (diff)
downloaddocker-cdb8ea90b04683adb25c8ccd71b6eaedc44b51e2.tar.gz
Fix processing of unset build-args during build
This reverts 26103. 26103 was trying to make it so that if someone did: docker build --build-arg FOO . and FOO wasn't set as an env var then it would pick-up FOO from the Dockerfile's ARG cmd. However, it went too far and removed the ability to specify a build arg w/o any value. Meaning it required the --build-arg param to always be in the form "name=value", and not just "name". This PR does the right fix - it allows just "name" and it'll grab the value from the env vars if set. If "name" isn't set in the env then it still needs to send "name" to the server so that a warning can be printed about an unused --build-arg. And this is why buildArgs in the options is now a *string instead of just a string - 'nil' == mentioned but no value. Closes #29084 Signed-off-by: Doug Davis <dug@us.ibm.com>
Diffstat (limited to 'client/image_build_test.go')
-rw-r--r--client/image_build_test.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/client/image_build_test.go b/client/image_build_test.go
index ec0cbe2ee4..b9d04f817a 100644
--- a/client/image_build_test.go
+++ b/client/image_build_test.go
@@ -27,6 +27,8 @@ func TestImageBuildError(t *testing.T) {
}
func TestImageBuild(t *testing.T) {
+ v1 := "value1"
+ v2 := "value2"
emptyRegistryConfig := "bnVsbA=="
buildCases := []struct {
buildOptions types.ImageBuildOptions
@@ -105,13 +107,14 @@ func TestImageBuild(t *testing.T) {
},
{
buildOptions: types.ImageBuildOptions{
- BuildArgs: map[string]string{
- "ARG1": "value1",
- "ARG2": "value2",
+ BuildArgs: map[string]*string{
+ "ARG1": &v1,
+ "ARG2": &v2,
+ "ARG3": nil,
},
},
expectedQueryParams: map[string]string{
- "buildargs": `{"ARG1":"value1","ARG2":"value2"}`,
+ "buildargs": `{"ARG1":"value1","ARG2":"value2","ARG3":null}`,
"rm": "0",
},
expectedTags: []string{},