summaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorDan Duvall <dduvall@wikimedia.org>2017-06-15 16:07:19 -0700
committerDan Duvall <dduvall@wikimedia.org>2017-06-20 10:17:10 -0700
commitbbb5eba26ae3edb671693c10d6d73a958546af27 (patch)
tree4eb7cfd4b7bb5fd7adf59e562cd87061dc68ab8a /docker
parent58c8e9718c97cc7d6dd34f9751f313f51fcc61df (diff)
downloadblubber-bbb5eba26ae3edb671693c10d6d73a958546af27.tar.gz
Use correct COPY syntax for quoted paths
Summary: Fixed compilation of copy build instructions to Dockerfile syntax. Test Plan: Run `go test ./...`. Reviewers: thcipriani, mobrovac, hashar, Jrbranaa, mmodell, #release-engineering-team Reviewed By: mobrovac Tags: #release-engineering-team Differential Revision: https://phabricator.wikimedia.org/D685
Diffstat (limited to 'docker')
-rw-r--r--docker/compiler.go6
-rw-r--r--docker/compiler_test.go11
2 files changed, 14 insertions, 3 deletions
diff --git a/docker/compiler.go b/docker/compiler.go
index a129ec4..0a16362 100644
--- a/docker/compiler.go
+++ b/docker/compiler.go
@@ -63,7 +63,7 @@ func CompileStage(buffer *bytes.Buffer, stage string, vcfg *config.VariantConfig
if vcfg.SharedVolume.True {
Writeln(buffer, "VOLUME [\"", vcfg.Runs.In, "\"]")
} else {
- Writeln(buffer, "COPY . \"", vcfg.Runs.In, "\"")
+ Writeln(buffer, "COPY . .")
}
// Artifact copying
@@ -74,7 +74,7 @@ func CompileStage(buffer *bytes.Buffer, stage string, vcfg *config.VariantConfig
Write(buffer, "--from=", artifact.From, " ")
}
- Writeln(buffer, artifact.Source, " ", artifact.Destination)
+ Writeln(buffer, "[\"", artifact.Source, "\", \"", artifact.Destination, "\"]")
}
CompilePhase(buffer, vcfg, build.PhasePostInstall)
@@ -95,7 +95,7 @@ func CompileInstruction(buffer *bytes.Buffer, instruction build.Instruction) {
case build.Run:
Writeln(buffer, append([]string{"RUN "}, instruction.Arguments...)...)
case build.Copy:
- Writeln(buffer, "COPY \"", instruction.Arguments[0], "\" \"", instruction.Arguments[1], "\"")
+ Writeln(buffer, "COPY [\"", instruction.Arguments[0], "\", \"", instruction.Arguments[1], "\"]")
}
}
diff --git a/docker/compiler_test.go b/docker/compiler_test.go
index f8b467f..c6fec1b 100644
--- a/docker/compiler_test.go
+++ b/docker/compiler_test.go
@@ -1,9 +1,11 @@
package docker_test
import (
+ "bytes"
"testing"
"gopkg.in/stretchr/testify.v1/assert"
+ "phabricator.wikimedia.org/source/blubber.git/build"
"phabricator.wikimedia.org/source/blubber.git/config"
"phabricator.wikimedia.org/source/blubber.git/docker"
)
@@ -41,3 +43,12 @@ variants:
assert.Contains(t, dockerfile, "FROM foo/bar AS build\n")
assert.Contains(t, dockerfile, "FROM foo/bar AS production\n")
}
+
+func TestCompileInstructionCopy(t *testing.T) {
+ buffer := new(bytes.Buffer)
+ instruction := build.Instruction{build.Copy, []string{"foo", "bar"}}
+
+ docker.CompileInstruction(buffer, instruction)
+
+ assert.Equal(t, "COPY [\"foo\", \"bar\"]\n", buffer.String())
+}