abstract polling and execution to runner-go library
This commit is contained in:
@@ -4,7 +4,13 @@
|
||||
|
||||
package engine
|
||||
|
||||
import (
|
||||
"github.com/drone/runner-go/environ"
|
||||
"github.com/drone/runner-go/pipeline/runtime"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// Spec provides the pipeline spec. This provides the
|
||||
// required instructions for reproducible pipeline
|
||||
// execution.
|
||||
@@ -44,7 +50,7 @@ type (
|
||||
Networks []string `json:"networks,omitempty"`
|
||||
Privileged bool `json:"privileged,omitempty"`
|
||||
Pull PullPolicy `json:"pull,omitempty"`
|
||||
RunPolicy RunPolicy `json:"run_policy,omitempty"`
|
||||
RunPolicy runtime.RunPolicy `json:"run_policy,omitempty"`
|
||||
Secrets []*Secret `json:"secrets,omitempty"`
|
||||
ShmSize int64 `json:"shm_size,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
@@ -52,14 +58,6 @@ type (
|
||||
WorkingDir string `json:"working_dir,omitempty"`
|
||||
}
|
||||
|
||||
// Platform defines the target platform.
|
||||
Platform struct {
|
||||
OS string `json:"os,omitempty"`
|
||||
Arch string `json:"arch,omitempty"`
|
||||
Variant string `json:"variant,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// Secret represents a secret variable.
|
||||
Secret struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
@@ -68,11 +66,12 @@ type (
|
||||
Mask bool `json:"mask,omitempty"`
|
||||
}
|
||||
|
||||
// State represents the process state.
|
||||
State struct {
|
||||
ExitCode int // Container exit code
|
||||
Exited bool // Container exited
|
||||
OOMKilled bool // Container is oom killed
|
||||
// Platform defines the target platform.
|
||||
Platform struct {
|
||||
OS string `json:"os,omitempty"`
|
||||
Arch string `json:"arch,omitempty"`
|
||||
Variant string `json:"variant,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// Volume that can be mounted by containers.
|
||||
@@ -128,3 +127,38 @@ type (
|
||||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
)
|
||||
|
||||
//
|
||||
// implements the Spec interface
|
||||
//
|
||||
|
||||
func (s *Spec) StepLen() int { return len(s.Steps) }
|
||||
func (s *Spec) StepAt(i int) runtime.Step { return s.Steps[i] }
|
||||
|
||||
//
|
||||
// implements the Secret interface
|
||||
//
|
||||
|
||||
func (s *Secret) GetName() string { return s.Name }
|
||||
func (s *Secret) GetValue() string { return string(s.Data) }
|
||||
func (s *Secret) IsMasked() bool { return s.Mask }
|
||||
|
||||
//
|
||||
// implements the Step interface
|
||||
//
|
||||
|
||||
func (s *Step) GetName() string { return s.Name }
|
||||
func (s *Step) GetDependencies() []string { return s.DependsOn }
|
||||
func (s *Step) GetEnviron() map[string]string { return s.Envs }
|
||||
func (s *Step) SetEnviron(env map[string]string) { s.Envs = env }
|
||||
func (s *Step) GetErrPolicy() runtime.ErrPolicy { return runtime.ErrFail }
|
||||
func (s *Step) GetRunPolicy() runtime.RunPolicy { return s.RunPolicy }
|
||||
func (s *Step) GetSecretAt(i int) runtime.Secret { return s.Secrets[i] }
|
||||
func (s *Step) GetSecretLen() int { return len(s.Secrets) }
|
||||
func (s *Step) IsDetached() bool { return s.Detach }
|
||||
func (s *Step) Clone() runtime.Step {
|
||||
dst := new(Step)
|
||||
*dst = *s
|
||||
dst.Envs = environ.Combine(s.Envs)
|
||||
return dst
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user