Add the podman/tag task and unit tests for it
--- a/podman/errors.go Mon Oct 11 01:44:17 2021 -0500
+++ b/podman/errors.go Mon Oct 11 01:58:18 2021 -0500
@@ -5,7 +5,7 @@
ErrNoImage = errors.New("no image specified")
@@ -15,4 +15,7 @@
ErrNoTags = errors.New("no tags specified")
+ ErrNoTargets = errors.New("no targets specified") --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/podman/tag.go Mon Oct 11 01:58:18 2021 -0500
@@ -0,0 +1,50 @@
+ log "github.com/sirupsen/logrus" + "keep.imfreedom.org/grim/convey/environment" + "keep.imfreedom.org/grim/convey/exec" + "keep.imfreedom.org/grim/convey/runtime" + "keep.imfreedom.org/grim/convey/tasks" + "keep.imfreedom.org/grim/convey/yaml" + Image string `yaml:"image"` + Targets yaml.StringOrSlice `yaml:"targets"` +func (t *Tag) Execute(name string, logger *log.Entry, stageEnv environment.Environment, rt *runtime.Runtime) error { + env := stageEnv.Copy().Merge(rt.Environment) + generator := exec.NewGenerator( + generator.Appendv(env.Expandv(t.Targets)) + return exec.Run(name, generator.Command(), rt.Timeout) +func (t *Tag) New() tasks.Task { +func (t *Tag) Valid() error { + if len(t.Targets) == 0 { +func (t *Tag) Deprecated() error { --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/podman/tag_test.go Mon Oct 11 01:58:18 2021 -0500
@@ -0,0 +1,49 @@
+ . "github.com/onsi/gomega" +func TestTagSingleTarget(t *testing.T) { + Targets: []string{"bar"}, + g.Expect(tag.Valid()).To(BeNil()) +func TestTagMultipleTargets(t *testing.T) { + Targets: []string{"bar", "baz"}, + g.Expect(tag.Valid()).To(BeNil()) +func TestTagImageRequired(t *testing.T) { + Targets: []string{"bar"}, + g.Expect(tag.Valid()).To(MatchError(ErrNoImage)) +func TestTagTargetRequired(t *testing.T) { + g.Expect(tag.Valid()).To(MatchError(ErrNoTargets)) --- a/podman/tasks.go Mon Oct 11 01:44:17 2021 -0500
+++ b/podman/tasks.go Mon Oct 11 01:58:18 2021 -0500
@@ -12,6 +12,7 @@
"podman/remove": &Remove{},