grim/convey

Add quiet flag to remove task.

2017-10-11, Eric Fritz
eba0fb6f4af8
Add quiet flag to remove task.
--- a/REFERENCE.md Mon Oct 09 11:05:46 2017 -0500
+++ b/REFERENCE.md Wed Oct 11 09:22:28 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 Mon Oct 09 11:05:46 2017 -0500
+++ b/docker/remove.go Wed Oct 11 09:22:28 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
}
}