grim/convey

Create a docker/run task that wraps podman/run
redux
2021-10-11, Gary Kramlich
fbf02cafd889
Parents 0e9f78981b7c
Children 337bbe34fcfc
Create a docker/run task that wraps podman/run
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/errors.go Mon Oct 11 05:00:20 2021 -0500
@@ -0,0 +1,10 @@
+package docker
+
+import (
+ "errors"
+)
+
+var (
+ errDetachRemoved = errors.New("the detach attribute was removed in convey 0.15.0")
+ errHealthCheckRemoved = errors.New("the healthcheck attribute was removed in convey 0.15.0")
+)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/run.go Mon Oct 11 05:00:20 2021 -0500
@@ -0,0 +1,70 @@
+package docker
+
+import (
+ "fmt"
+
+ log "github.com/sirupsen/logrus"
+
+ "keep.imfreedom.org/grim/convey/environment"
+ "keep.imfreedom.org/grim/convey/podman"
+ "keep.imfreedom.org/grim/convey/runtime"
+ "keep.imfreedom.org/grim/convey/tasks"
+ "keep.imfreedom.org/grim/convey/yaml"
+)
+
+type Run struct {
+ Command string `yaml:"command"`
+ Detach bool `yaml:"detach"`
+ Entrypoint string `yaml:"entrypoint"`
+ Environment yaml.StringOrSlice `yaml:"environment"`
+ HealthCheck interface{} `yaml:"healthcheck"`
+ Hostname string `yaml:"hostname"`
+ Image string `yaml:"image"`
+ Labels yaml.StringOrSlice `yaml:"labels"`
+ Script yaml.StringOrSlice `yaml:"script"`
+ Shell string `yaml:"shell"`
+ User string `yaml:"user"`
+ Workdir string `yaml:"workdir"`
+ Workspace string `yaml:"workspace"`
+
+ realRun *podman.Run
+}
+
+// New creates a new Run task.
+func (r *Run) New() tasks.Task {
+ return &Run{}
+}
+
+// Valid validates the export task.
+func (r *Run) Valid() error {
+ if r.Detach == true {
+ return errDetachRemoved
+ }
+
+ if r.HealthCheck != nil {
+ return errHealthCheckRemoved
+ }
+
+ r.realRun = &podman.Run{
+ Annotations: r.Labels,
+ Command: r.Command,
+ Entrypoint: r.Entrypoint,
+ Environment: r.Environment,
+ Hostname: r.Hostname,
+ Image: r.Image,
+ User: r.User,
+ Workdir: r.Workdir,
+ Workspace: r.Workspace,
+ }
+
+ return r.realRun.Valid()
+}
+
+// Executes the task
+func (r *Run) Execute(name string, logger *log.Entry, env environment.Environment, rt *runtime.Runtime) error {
+ return r.realRun.Execute(name, logger, env, rt)
+}
+
+func (r *Run) Deprecated() error {
+ return fmt.Errorf("docker/run has been deprecated in favor of podman/run since 0.15.0")
+}
--- a/docker/tasks.go Mon Oct 11 05:00:11 2021 -0500
+++ b/docker/tasks.go Mon Oct 11 05:00:20 2021 -0500
@@ -14,6 +14,7 @@
"docker/pull": &Pull{},
"docker/push": &Push{},
"docker/remove": &Remove{},
+ "docker/run": &Run{},
"docker/tag": &Tag{},
}
)
--- a/podman/tasks.go Mon Oct 11 05:00:11 2021 -0500
+++ b/podman/tasks.go Mon Oct 11 05:00:20 2021 -0500
@@ -14,8 +14,5 @@
"podman/remove": &Remove{},
"podman/run": &Run{},
"podman/tag": &Tag{},
-
- // make it go!
- "docker/run": &Run{},
}
)