update vendored pipeline runner

This commit is contained in:
Brad Rydzewski 2018-04-01 11:34:01 -07:00
parent 81103a9820
commit d3898a755e
4 changed files with 52 additions and 51 deletions

View file

@ -1,21 +1,24 @@
package backend
import "io"
import (
"context"
"io"
)
// Engine defines a container orchestration backend and is used
// to create and manage container resources.
type Engine interface {
// Setup the pipeline environment.
Setup(*Config) error
Setup(context.Context, *Config) error
// Start the pipeline step.
Exec(*Step) error
Exec(context.Context, *Step) error
// Kill the pipeline step.
Kill(*Step) error
Kill(context.Context, *Step) error
// Wait for the pipeline step to complete and returns
// the completion results.
Wait(*Step) (*State, error)
Wait(context.Context, *Step) (*State, error)
// Tail the pipeline step logs.
Tail(*Step) (io.ReadCloser, error)
Tail(context.Context, *Step) (io.ReadCloser, error)
// Destroy the pipeline environment.
Destroy(*Config) error
Destroy(context.Context, *Config) error
}

View file

@ -35,7 +35,7 @@ func NewEnv() (backend.Engine, error) {
return New(cli), nil
}
func (e *engine) Setup(conf *backend.Config) error {
func (e *engine) Setup(_ context.Context, conf *backend.Config) error {
for _, vol := range conf.Volumes {
_, err := e.client.VolumeCreate(noContext, volume.VolumesCreateBody{
Name: vol.Name,
@ -60,9 +60,7 @@ func (e *engine) Setup(conf *backend.Config) error {
return nil
}
func (e *engine) Exec(proc *backend.Step) error {
ctx := context.Background()
func (e *engine) Exec(ctx context.Context, proc *backend.Step) error {
config := toConfig(proc)
hostConfig := toHostConfig(proc)
@ -126,12 +124,12 @@ func (e *engine) Exec(proc *backend.Step) error {
return e.client.ContainerStart(ctx, proc.Name, startOpts)
}
func (e *engine) Kill(proc *backend.Step) error {
func (e *engine) Kill(_ context.Context, proc *backend.Step) error {
return e.client.ContainerKill(noContext, proc.Name, "9")
}
func (e *engine) Wait(proc *backend.Step) (*backend.State, error) {
_, err := e.client.ContainerWait(noContext, proc.Name)
func (e *engine) Wait(ctx context.Context, proc *backend.Step) (*backend.State, error) {
_, err := e.client.ContainerWait(ctx, proc.Name)
if err != nil {
// todo
}
@ -151,8 +149,8 @@ func (e *engine) Wait(proc *backend.Step) (*backend.State, error) {
}, nil
}
func (e *engine) Tail(proc *backend.Step) (io.ReadCloser, error) {
logs, err := e.client.ContainerLogs(noContext, proc.Name, logsOpts)
func (e *engine) Tail(ctx context.Context, proc *backend.Step) (io.ReadCloser, error) {
logs, err := e.client.ContainerLogs(ctx, proc.Name, logsOpts)
if err != nil {
return nil, err
}
@ -167,7 +165,7 @@ func (e *engine) Tail(proc *backend.Step) (io.ReadCloser, error) {
return rc, nil
}
func (e *engine) Destroy(conf *backend.Config) error {
func (e *engine) Destroy(_ context.Context, conf *backend.Config) error {
for _, stage := range conf.Stages {
for _, step := range stage.Steps {
e.client.ContainerKill(noContext, step.Name, "9")

View file

@ -55,11 +55,11 @@ func New(spec *backend.Config, opts ...Option) *Runtime {
// Run starts the runtime and waits for it to complete.
func (r *Runtime) Run() error {
defer func() {
r.engine.Destroy(r.spec)
r.engine.Destroy(r.ctx, r.spec)
}()
r.started = time.Now().Unix()
if err := r.engine.Setup(r.spec); err != nil {
if err := r.engine.Setup(r.ctx, r.spec); err != nil {
return err
}
@ -124,12 +124,12 @@ func (r *Runtime) exec(proc *backend.Step) error {
}
}
if err := r.engine.Exec(proc); err != nil {
if err := r.engine.Exec(r.ctx, proc); err != nil {
return err
}
if r.logger != nil {
rc, err := r.engine.Tail(proc)
rc, err := r.engine.Tail(r.ctx, proc)
if err != nil {
return err
}
@ -144,7 +144,7 @@ func (r *Runtime) exec(proc *backend.Step) error {
return nil
}
wait, err := r.engine.Wait(proc)
wait, err := r.engine.Wait(r.ctx, proc)
if err != nil {
return err
}

58
vendor/vendor.json vendored
View file

@ -193,82 +193,82 @@
"revisionTime": "2017-03-05T07:05:34Z"
},
{
"checksumSHA1": "W3AuK8ocqHwlUajGmQLFvnRhTZE=",
"checksumSHA1": "ZHIN9ZvSnpB6xJZrlRPiuSU5I+Y=",
"path": "github.com/cncd/pipeline/pipeline",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "iRKdpheRPBTP0DKTQH7zmE2PI34=",
"checksumSHA1": "fVN8cdG7KyWMge1UL3UzC0IZ8T4=",
"path": "github.com/cncd/pipeline/pipeline/backend",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "EHJGG1USUliP8nzNWV/axO5KLzw=",
"checksumSHA1": "W8YLHobCsauDN8mHNGv0kdDsNzM=",
"path": "github.com/cncd/pipeline/pipeline/backend/docker",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "HWV2BBLXS4gY5eLJeNIg7Z6nAOA=",
"path": "github.com/cncd/pipeline/pipeline/frontend",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "ncGH2MfHDtM7/dNzj2i+lnXFnf4=",
"path": "github.com/cncd/pipeline/pipeline/frontend/yaml",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "cdjOSSSS5Gzx7gRLNvObQvNJWYg=",
"path": "github.com/cncd/pipeline/pipeline/frontend/yaml/compiler",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "Sj2VYU+asWToYriIqcinav5MJZo=",
"path": "github.com/cncd/pipeline/pipeline/frontend/yaml/linter",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "kx2sPUIMozPC/g6E4w48h3FfH3k=",
"path": "github.com/cncd/pipeline/pipeline/frontend/yaml/matrix",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "L7Q5qJmPITNmvFEEaj5MPwCWFRk=",
"path": "github.com/cncd/pipeline/pipeline/frontend/yaml/types",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "2/3f3oNmxXy5kcrRLCFa24Oc9O4=",
"path": "github.com/cncd/pipeline/pipeline/interrupt",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "uOjTfke7Qxosrivgz/nVTHeIP5g=",
"path": "github.com/cncd/pipeline/pipeline/multipart",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "mfWlnRAr5B4+RL13W3s0BQVBofM=",
"path": "github.com/cncd/pipeline/pipeline/rpc",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "N+3wNQ8hc/6yrh3FxbaxkEVwrkY=",
"path": "github.com/cncd/pipeline/pipeline/rpc/proto",
"revision": "3a09486affc9215ba52f55b1f6e10182458d1aba",
"revisionTime": "2018-01-10T21:28:38Z"
"revision": "20fb2f4efd792fc8dafc53aec766c2edcfdf0bb0",
"revisionTime": "2018-04-01T18:32:51Z"
},
{
"checksumSHA1": "7Qj1DK0ceAXkYztW0l3+L6sn+V8=",