grim/convey

485ad02d17a9
Parents 038b43191343
Children 6df88f1baa6b
EnvMap labels in build and run tasks. Fixes #108
--- a/ChangeLog Mon Jun 19 21:46:01 2017 -0500
+++ b/ChangeLog Tue Jul 04 17:15:12 2017 -0500
@@ -1,5 +1,6 @@
0.8.0:
- * Nothing yet... Be the first!!
+ * Allow labels for the Docker run and build tasks to use environment
+ variables. (fixed #112)
0.7.0: 20170619
* Added support for passing arguments to the Docker build task (--build-arg).
--- a/docker/build.go Mon Jun 19 21:46:01 2017 -0500
+++ b/docker/build.go Tue Jul 04 17:15:12 2017 -0500
@@ -87,7 +87,7 @@
"dockerfile": filepath.Join(tmpDir, filepath.Base(b.Dockerfile)),
"tag": environment.Mapper(b.Tag, fullEnv),
"buildContext": tmpDir,
- "Labels": b.Labels,
+ "Labels": environment.SliceMapper(b.Labels, fullEnv),
"Arguments": b.Arguments,
}
--- a/docker/run.go Mon Jun 19 21:46:01 2017 -0500
+++ b/docker/run.go Tue Jul 04 17:15:12 2017 -0500
@@ -155,7 +155,7 @@
"EntryPoint": entryPoint,
"GID": user.Gid,
"Image": environment.Mapper(r.Image, fullEnv),
- "Labels": r.Labels,
+ "Labels": environment.SliceMapper(r.Labels, fullEnv),
"Memory": st.Memory,
"ScriptFile": scriptFile,
"SSHAgent": st.EnableSSHAgent,
--- a/environment/mapper.go Mon Jun 19 21:46:01 2017 -0500
+++ b/environment/mapper.go Tue Jul 04 17:15:12 2017 -0500
@@ -57,3 +57,14 @@
return next
}
+
+// SliceMapper calls Mapper for each item in a slice and returns a new slice.
+func SliceMapper(slice []string, env []string) []string {
+ mapped := []string{}
+
+ for _, template := range slice {
+ mapped = append(mapped, Mapper(template, env))
+ }
+
+ return mapped
+}