grim/convey

Merge.
cleanup-on-signal
2017-10-14, Eric Fritz
1966939175c1
Merge.
--- a/ChangeLog Sat Oct 14 10:11:16 2017 -0500
+++ b/ChangeLog Sat Oct 14 10:11:23 2017 -0500
@@ -1,8 +1,10 @@
0.10.5:
- * Nothing yet! Be the first!!
+ * Added a quiet option to Remove tasks. Fixed #131. PR #31 (Eric Fritz)
+ * Don't pass empty environment variables to Runs tasks. PR #35 (Eric Fritz)
+ * Fix an infinite loop in variable expansion. Fixed #130. PR #33 (Eric Fritz)
0.10.4:
- * Fix an issue that made scripts non-deterministic. PR #30 (Eric Fritz)
+ * Fix an issue that made scripts non-deterministic. PR #30 (Eric Fritz)
0.10.3: 20171004
* Added support for setting a hostname for run tasks. This makes it possible
--- a/REFERENCE.md Sat Oct 14 10:11:16 2017 -0500
+++ b/REFERENCE.md Sat Oct 14 10:11:23 2017 -0500
@@ -362,6 +362,7 @@
| ------ | -------- | ------- | ----------- |
| image | | | The name including the tag and registry of the image to remove. |
| images | | | A list of images as described above. |
+| quiet | | false | True if a missing image should not count as a task failure. |
At least one image must be supplied by either the `image` or `images` attribute. If both are
supplied, `image` is inserted to the front of `images`.
--- a/docker/remove.go Sat Oct 14 10:11:16 2017 -0500
+++ b/docker/remove.go Sat Oct 14 10:11:23 2017 -0500
@@ -18,6 +18,8 @@
package docker
import (
+ "strings"
+
"github.com/aphistic/gomol"
"bitbucket.org/rw_grim/convey/environment"
@@ -29,6 +31,7 @@
type Remove struct {
Image string `yaml:"image"`
Images yaml.StringOrSlice `yaml:"images"`
+ Quiet bool `yaml:"quiet"`
}
const removeTemplate = `rmi {{.image}}`
@@ -46,7 +49,11 @@
"image": image,
}
- if err := Docker(name, removeTemplate, params, st); err != nil {
+ if _, stderr, err := DockerOutput(name, removeTemplate, params, st); err != nil {
+ if strings.Contains(stderr, "No such image") && r.Quiet {
+ continue
+ }
+
return err
}
}
--- a/docker/run.go Sat Oct 14 10:11:16 2017 -0500
+++ b/docker/run.go Sat Oct 14 10:11:23 2017 -0500
@@ -240,7 +240,7 @@
"CPUShares": st.CPUShares,
"Detach": r.Detach,
"Hostname": hostname,
- "Environment": fullEnv,
+ "Environment": environment.Prune(fullEnv),
"EntryPoint": entryPoint,
"GID": user.Gid,
"HealthCheck": r.HealthCheck,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/environment/prune.go Sat Oct 14 10:11:23 2017 -0500
@@ -0,0 +1,38 @@
+/*
+ * Convey
+ * Copyright 2016-2017 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package environment
+
+import (
+ "os"
+)
+
+// Prune removes all empty-value variables from the environment.
+func Prune(env []string) []string {
+ pruned := []string{}
+
+ for _, val := range env {
+ k, v := splitEqual(val)
+ if v == "" && os.Getenv(k) == "" {
+ continue
+ }
+
+ pruned = append(pruned, val)
+ }
+
+ return pruned
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/environment/prune_test.go Sat Oct 14 10:11:23 2017 -0500
@@ -0,0 +1,32 @@
+/*
+ * Convey
+ * Copyright 2016-2017 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package environment
+
+import (
+ "os"
+
+ "github.com/aphistic/sweet"
+ . "github.com/onsi/gomega"
+)
+
+func (e *environmentSuite) TestPrune(t sweet.T) {
+ os.Clearenv()
+ os.Setenv("BONK", "not-empty")
+
+ Expect(Prune([]string{"FOO=bar", "BAZ", "BONK", "QUUX="})).To(Equal([]string{"FOO=bar", "BONK"}))
+}