summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorDan Duvall <dduvall@wikimedia.org>2017-09-05 17:33:27 -0700
committerDan Duvall <dduvall@wikimedia.org>2017-09-07 10:06:47 -0700
commit62066296380d19dc77ab216cb27100e7e72ff69f (patch)
tree658fcce89b8e18bad2144d99bc8cfef5869b10e8 /build
parent410085e1f5be759b6a2bfbe08a51dca84aa18e3c (diff)
downloadblubber-62066296380d19dc77ab216cb27100e7e72ff69f.tar.gz
Smarter copies/sharedvolume/default behavior
Summary: Defined new abstract `build.Volume` and corresponding `docker.DockerVolume` instructions. Refactored compilation of main `COPY` or `VOLUME` instruction for application files to use the new instructions and moved injection of these instructions out of the compiler and into `VariantConfig`. The latter can be smarter about the following cases: 1. When `copies` is set, simply depend on artifacts for the application files and do not copy anything from the build host. 2. When `sharedvolume` is `true`, inject a `build.Volume` instruction for the application working directory. 3. When neither of the above are set, copy application files from the host. Fixes T174623 Depends on D768 Test Plan: Run `go test ./...`. Run `blubber blubber.example.yaml production` and ensure: 1. The `prep` stage has a `COPY . .` instruction. 2. The final stage has no `COPY . .` instruction, only `COPY --from=prep` instructions. Reviewers: thcipriani, mobrovac, hashar, mmodell, #release-engineering-team Reviewed By: thcipriani, mobrovac, #release-engineering-team Tags: #release-engineering-team Maniphest Tasks: T174623 Differential Revision: https://phabricator.wikimedia.org/D769
Diffstat (limited to 'build')
-rw-r--r--build/instructions.go8
-rw-r--r--build/instructions_test.go6
-rw-r--r--build/phases.go1
3 files changed, 15 insertions, 0 deletions
diff --git a/build/instructions.go b/build/instructions.go
index 1b954a2..38ea322 100644
--- a/build/instructions.go
+++ b/build/instructions.go
@@ -80,6 +80,14 @@ func (env Env) Compile() []string {
return defs
}
+type Volume struct {
+ Path string
+}
+
+func (vol Volume) Compile() []string {
+ return []string{quote(vol.Path)}
+}
+
func quote(arg string) string {
return strconv.Quote(arg)
}
diff --git a/build/instructions_test.go b/build/instructions_test.go
index 8f9470c..04ebdfb 100644
--- a/build/instructions_test.go
+++ b/build/instructions_test.go
@@ -55,3 +55,9 @@ func TestEnv(t *testing.T) {
`quxname="quxvalue"`,
}, i.Compile())
}
+
+func TestVolume(t *testing.T) {
+ i := build.Volume{"/foo/dir"}
+
+ assert.Equal(t, []string{`"/foo/dir"`}, i.Compile())
+}
diff --git a/build/phases.go b/build/phases.go
index 095263c..02e84e4 100644
--- a/build/phases.go
+++ b/build/phases.go
@@ -6,6 +6,7 @@ const (
PhasePrivileged Phase = iota
PhasePrivilegeDropped
PhasePreInstall
+ PhaseInstall
PhasePostInstall
)