Documentation
¶
Index ¶
- Constants
- Variables
- func ProcessVariables(input string, context VariableContext) (string, error)
- type BareJob
- func (j *BareJob) GetCommand() string
- func (j *BareJob) GetCronJobID() int
- func (j *BareJob) GetName() string
- func (j *BareJob) GetProcessedCommand(context VariableContext) string
- func (j *BareJob) GetSchedule() string
- func (c *BareJob) Middlewares() []Middleware
- func (j *BareJob) NotifyStart()
- func (j *BareJob) NotifyStop()
- func (j *BareJob) Running() int32
- func (j *BareJob) SetCronJobID(id int)
- func (j *BareJob) SetVolumeMounts(volumes []string)
- func (c *BareJob) Use(ms ...Middleware)
- type Container
- type ContainerConfig
- type ContainerInfo
- type Context
- type CronUtils
- type DockerActor
- type DockerClient
- type DockerEvent
- type ExecConfig
- type ExecInspect
- type ExecJob
- type Execution
- type HostConfig
- type Job
- type LifecycleEventType
- type LifecycleJob
- func (j *LifecycleJob) Hash() string
- func (c *LifecycleJob) Middlewares() []Middleware
- func (j *LifecycleJob) Reset()
- func (j *LifecycleJob) Run(ctx *Context) error
- func (j *LifecycleJob) SetVolumeMounts(volumes []string)
- func (j *LifecycleJob) ShouldRun(eventType LifecycleEventType) bool
- func (c *LifecycleJob) Use(ms ...Middleware)
- type LocalJob
- type Logger
- type Middleware
- type MockDockerClient
- func (c *MockDockerClient) Close() error
- func (c *MockDockerClient) CreateContainer(config *ContainerConfig) (*Container, error)
- func (c *MockDockerClient) CreateExec(containerID string, cmd []string, config *ExecConfig) (string, error)
- func (c *MockDockerClient) CreateExecJob() *OfficialExecJob
- func (c *MockDockerClient) CreateLifecycleJob() *OfficialLifecycleJob
- func (c *MockDockerClient) CreateRunJob() *OfficialRunJob
- func (c *MockDockerClient) CreateService(config *ServiceConfig) (string, error)
- func (c *MockDockerClient) CreateServiceJob() *OfficialServiceJob
- func (c *MockDockerClient) InspectContainer(id string) (*Container, error)
- func (c *MockDockerClient) InspectExec(execID string) (*ExecInspect, error)
- func (c *MockDockerClient) InspectService(id string) (*Service, error)
- func (c *MockDockerClient) ListContainers(filterMap map[string][]string) ([]Container, error)
- func (c *MockDockerClient) ListTasks(serviceID string) ([]Task, error)
- func (c *MockDockerClient) PullImage(imageName string) error
- func (c *MockDockerClient) RemoveContainer(id string) error
- func (c *MockDockerClient) RemoveService(id string) error
- func (c *MockDockerClient) StartContainer(id string) error
- func (c *MockDockerClient) StartExec(execID string, attachStdout, attachStderr bool) (io.ReadCloser, error)
- func (c *MockDockerClient) StopContainer(id string) error
- func (c *MockDockerClient) WaitContainer(id string) (int, error)
- func (c *MockDockerClient) WatchEvents(ctx context.Context, eventCh chan<- *DockerEvent, errCh chan<- error)
- type OfficialDockerClient
- func (c *OfficialDockerClient) Close() error
- func (c *OfficialDockerClient) CreateContainer(config *ContainerConfig) (*Container, error)
- func (c *OfficialDockerClient) CreateExec(containerID string, cmd []string, config *ExecConfig) (string, error)
- func (c *OfficialDockerClient) CreateExecJob() *OfficialExecJob
- func (c *OfficialDockerClient) CreateLifecycleJob() *OfficialLifecycleJob
- func (c *OfficialDockerClient) CreateRunJob() *OfficialRunJob
- func (c *OfficialDockerClient) CreateService(config *ServiceConfig) (string, error)
- func (c *OfficialDockerClient) CreateServiceJob() *OfficialServiceJob
- func (c *OfficialDockerClient) InspectContainer(id string) (*Container, error)
- func (c *OfficialDockerClient) InspectExec(execID string) (*ExecInspect, error)
- func (c *OfficialDockerClient) InspectService(id string) (*Service, error)
- func (c *OfficialDockerClient) ListContainers(filterMap map[string][]string) ([]Container, error)
- func (c *OfficialDockerClient) ListTasks(serviceID string) ([]Task, error)
- func (c *OfficialDockerClient) PullImage(imageName string) error
- func (c *OfficialDockerClient) RemoveContainer(id string) error
- func (c *OfficialDockerClient) RemoveService(id string) error
- func (c *OfficialDockerClient) StartContainer(id string) error
- func (c *OfficialDockerClient) StartExec(execID string, attachStdout, attachStderr bool) (io.ReadCloser, error)
- func (c *OfficialDockerClient) StopContainer(id string) error
- func (c *OfficialDockerClient) WaitContainer(id string) (int, error)
- func (c *OfficialDockerClient) WatchEvents(ctx context.Context, eventCh chan<- *DockerEvent, errCh chan<- error)
- type OfficialExecJob
- type OfficialLifecycleJob
- type OfficialRunJob
- type OfficialServiceJob
- type ReadCloserWrapper
- type RestartPolicy
- type RunJob
- type RunServiceJob
- type Scheduler
- type Service
- type ServiceConfig
- type ServiceEndpoint
- type ServiceJob
- type ServiceMount
- type ServicePort
- type ServiceUpdateState
- type Task
- type TaskStatus
- type VariableContext
Constants ¶
const HashmeTagName = "hash"
Variables ¶
var ( // ErrSkippedExecution pass this error to `Execution.Stop` if you wish to mark // it as skipped. ErrSkippedExecution = errors.New("skipped execution") ErrUnexpected = errors.New("error unexpected, docker has returned exit code -1, maybe wrong user?") ErrMaxTimeRunning = errors.New("the job has exceed the maximum allowed time running.") ErrLocalImageNotFound = errors.New("couldn't find image on the host") )
var ( ErrEmptyScheduler = errors.New("unable to start a empty scheduler.") ErrEmptySchedule = errors.New("unable to add a job with a empty schedule.") )
var ( SchedulerJobs = promauto.NewGauge(prometheus.GaugeOpts{ Name: "chadburn_scheduler_jobs", Help: "Active job count registered on the scheduler.", }) JobRegisterErrorsTotal = promauto.NewCounter(prometheus.CounterOpts{ Name: "chadburn_scheduler_register_errors_total", Help: "Total number of failed scheduler registrations.", }) RunsTotal = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "chadburn_run_total", Help: "Total number of completed job runs.", }, []string{"job_name"}, ) RunErrorsTotal = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "chadburn_run_errors_total", Help: "Total number of completed job runs that resulted in an error.", }, []string{"job_name"}, ) RunLatest = promauto.NewGaugeVec( prometheus.GaugeOpts{ Name: "chadburn_run_latest_timestamp", Help: "Last time a job run completed.", }, []string{"job_name"}, ) RunDuration = promauto.NewHistogramVec( prometheus.HistogramOpts{ Name: "chadburn_run_duration_seconds", Help: "Duration of all runs.", }, []string{"job_name"}, ) )
Functions ¶
func ProcessVariables ¶ added in v1.5.0
func ProcessVariables(input string, context VariableContext) (string, error)
ProcessVariables replaces variables in the input string using the provided context
Types ¶
type BareJob ¶
type BareJob struct {
Schedule string `hash:"true"`
Name string `hash:"true"`
Command string `hash:"true"`
// contains filtered or unexported fields
}
func (*BareJob) GetCommand ¶
func (*BareJob) GetCronJobID ¶
func (*BareJob) GetProcessedCommand ¶ added in v1.5.0
func (j *BareJob) GetProcessedCommand(context VariableContext) string
GetProcessedCommand returns the command with variables replaced
func (*BareJob) GetSchedule ¶
func (*BareJob) Middlewares ¶
func (c *BareJob) Middlewares() []Middleware
func (*BareJob) NotifyStart ¶
func (j *BareJob) NotifyStart()
func (*BareJob) NotifyStop ¶
func (j *BareJob) NotifyStop()
func (*BareJob) SetCronJobID ¶
func (*BareJob) SetVolumeMounts ¶ added in v1.5.0
func (*BareJob) Use ¶
func (c *BareJob) Use(ms ...Middleware)
type Container ¶ added in v1.7.0
type Container struct {
ID string
Name string
Labels map[string]string
State struct {
Running bool
}
Config struct {
Labels map[string]string
}
}
Container represents a Docker container
type ContainerConfig ¶ added in v1.7.0
type ContainerConfig struct {
Image string
Cmd []string
Env []string
WorkingDir string
User string
Volumes map[string]struct{}
ExposedPorts map[string]struct{}
Labels map[string]string
Tty bool
AttachStdin bool
AttachStdout bool
AttachStderr bool
NetworkMode string
HostConfig *HostConfig
}
ContainerConfig represents configuration for creating a container
type ContainerInfo ¶ added in v1.5.0
ContainerInfo holds information about a container that can be used in variable replacements
type Context ¶
type Context struct {
Scheduler *Scheduler
Logger Logger
Job Job
Execution *Execution
// contains filtered or unexported fields
}
func NewContext ¶
NewContext creates a new Context
type CronUtils ¶
type CronUtils struct {
Logger Logger
}
Implement the cron logger interface
func NewCronUtils ¶
type DockerActor ¶ added in v1.7.0
DockerActor represents the actor in a Docker event
type DockerClient ¶ added in v1.7.0
type DockerClient interface {
// Container operations
ListContainers(filters map[string][]string) ([]Container, error)
InspectContainer(id string) (*Container, error)
CreateContainer(config *ContainerConfig) (*Container, error)
StartContainer(id string) error
StopContainer(id string) error
RemoveContainer(id string) error
WaitContainer(id string) (int, error)
// Exec operations
CreateExec(containerID string, cmd []string, config *ExecConfig) (string, error)
StartExec(execID string, attachStdout, attachStderr bool) (io.ReadCloser, error)
InspectExec(execID string) (*ExecInspect, error)
// Image operations
PullImage(image string) error
// Service operations
CreateService(config *ServiceConfig) (string, error)
InspectService(id string) (*Service, error)
ListTasks(serviceID string) ([]Task, error)
RemoveService(id string) error
// Event operations
WatchEvents(ctx context.Context, eventCh chan<- *DockerEvent, errCh chan<- error)
// Job creation operations
CreateExecJob() *OfficialExecJob
CreateRunJob() *OfficialRunJob
CreateServiceJob() *OfficialServiceJob
CreateLifecycleJob() *OfficialLifecycleJob
// Cleanup
Close() error
}
DockerClient is an interface for Docker client operations
func NewDockerClient ¶ added in v1.7.0
func NewDockerClient() (DockerClient, error)
NewDockerClient creates a new Docker client using the official Docker client
type DockerEvent ¶ added in v1.7.0
type DockerEvent struct {
Action string
ID string
Type string
Actor DockerActor
Attributes map[string]string
}
DockerEvent represents a Docker event
type ExecConfig ¶ added in v1.7.0
type ExecConfig struct {
User string
Tty bool
AttachStdin bool
AttachStdout bool
AttachStderr bool
Cmd []string
WorkingDir string
}
ExecConfig represents configuration for creating an exec instance
type ExecInspect ¶ added in v1.7.0
ExecInspect represents the result of inspecting an exec instance
type ExecJob ¶
type ExecJob struct {
BareJob `mapstructure:",squash"`
Client DockerClient `json:"-"`
Container string `hash:"true"`
User string `default:"root" hash:"true"`
TTY bool `default:"false" hash:"true"`
Workdir string `default:"" hash:"true"`
// ContainerName is used for variable processing and is not included in the hash
ContainerName string `hash:"-"`
}
ExecJob represents a job that executes a command in a running Docker container
func (*ExecJob) Middlewares ¶
func (c *ExecJob) Middlewares() []Middleware
func (*ExecJob) Use ¶
func (c *ExecJob) Use(ms ...Middleware)
type Execution ¶
type Execution struct {
ID string
Date time.Time
OutputStream *circbuf.Buffer
ErrorStream *circbuf.Buffer
// contains filtered or unexported fields
}
Execution contains all the information relative to a Job execution.
func NewExecution ¶
func NewExecution() *Execution
type HostConfig ¶ added in v1.7.0
HostConfig represents the container's host configuration
type Job ¶
type Job interface {
GetName() string
GetSchedule() string
GetCommand() string
GetProcessedCommand(VariableContext) string
Middlewares() []Middleware
Use(...Middleware)
Run(*Context) error
Running() int32
NotifyStart()
NotifyStop()
GetCronJobID() int
SetCronJobID(int)
SetVolumeMounts([]string)
}
type LifecycleEventType ¶ added in v1.6.0
type LifecycleEventType string
LifecycleEventType represents the type of container lifecycle event
const ( // ContainerStart represents a container start event ContainerStart LifecycleEventType = "start" // ContainerStop represents a container stop event ContainerStop LifecycleEventType = "stop" )
type LifecycleJob ¶ added in v1.6.0
type LifecycleJob struct {
BareJob `mapstructure:",squash"`
Client DockerClient `json:"-"`
Container string `hash:"true"` // Container ID or name to monitor
EventType LifecycleEventType `hash:"true"` // Type of event to trigger on (start, stop)
Executed bool `hash:"-"` // Whether this job has been executed
}
LifecycleJob represents a job that runs once on container lifecycle events
func NewLifecycleJob ¶ added in v1.6.0
func NewLifecycleJob(c DockerClient) *LifecycleJob
NewLifecycleJob creates a new LifecycleJob
func (*LifecycleJob) Hash ¶ added in v1.6.0
func (j *LifecycleJob) Hash() string
Returns a hash of all the job attributes. Used to detect changes
func (*LifecycleJob) Middlewares ¶ added in v1.6.0
func (c *LifecycleJob) Middlewares() []Middleware
func (*LifecycleJob) Reset ¶ added in v1.6.0
func (j *LifecycleJob) Reset()
Reset resets the executed state of the job
func (*LifecycleJob) Run ¶ added in v1.6.0
func (j *LifecycleJob) Run(ctx *Context) error
Run executes the job
func (*LifecycleJob) SetVolumeMounts ¶ added in v1.6.0
func (j *LifecycleJob) SetVolumeMounts(volumes []string)
SetVolumeMounts is a no-op for LifecycleJob
func (*LifecycleJob) ShouldRun ¶ added in v1.6.0
func (j *LifecycleJob) ShouldRun(eventType LifecycleEventType) bool
ShouldRun determines if the job should run based on the event type
func (*LifecycleJob) Use ¶ added in v1.6.0
func (c *LifecycleJob) Use(ms ...Middleware)
type LocalJob ¶
type LocalJob struct {
BareJob `mapstructure:",squash"`
Dir string
Environment []string
// Variables for command processing
ContainerName string `hash:"-"`
ContainerID string `hash:"-"`
}
func NewLocalJob ¶
func NewLocalJob() *LocalJob
func (*LocalJob) Hash ¶ added in v1.0.9
Returns a hash of all the job attributes. Used to detect changes
func (*LocalJob) Middlewares ¶
func (c *LocalJob) Middlewares() []Middleware
func (*LocalJob) Use ¶
func (c *LocalJob) Use(ms ...Middleware)
type Middleware ¶
type Middleware interface {
// Run is called instead of the original `Job.Run`, you MUST call to `ctx.Run`
// inside of the middleware `Run` function otherwise you will broken the
// Job workflow.
Run(*Context) error
// ContinueOnStop, If return true the Run function will be called even if
// the execution is stopped
ContinueOnStop() bool
}
Middleware can wrap any job execution, allowing to execution code before or/and after of each `Job.Run`
type MockDockerClient ¶ added in v1.7.0
type MockDockerClient struct {
}
MockDockerClient is a mock implementation of the DockerClient interface for testing
func (*MockDockerClient) Close ¶ added in v1.7.0
func (c *MockDockerClient) Close() error
Close closes the Docker client
func (*MockDockerClient) CreateContainer ¶ added in v1.7.0
func (c *MockDockerClient) CreateContainer(config *ContainerConfig) (*Container, error)
CreateContainer creates a new container
func (*MockDockerClient) CreateExec ¶ added in v1.7.0
func (c *MockDockerClient) CreateExec(containerID string, cmd []string, config *ExecConfig) (string, error)
CreateExec creates an exec instance in a container
func (*MockDockerClient) CreateExecJob ¶ added in v1.7.0
func (c *MockDockerClient) CreateExecJob() *OfficialExecJob
CreateExecJob creates a new ExecJob
func (*MockDockerClient) CreateLifecycleJob ¶ added in v1.7.0
func (c *MockDockerClient) CreateLifecycleJob() *OfficialLifecycleJob
CreateLifecycleJob creates a new LifecycleJob
func (*MockDockerClient) CreateRunJob ¶ added in v1.7.0
func (c *MockDockerClient) CreateRunJob() *OfficialRunJob
CreateRunJob creates a new RunJob
func (*MockDockerClient) CreateService ¶ added in v1.7.0
func (c *MockDockerClient) CreateService(config *ServiceConfig) (string, error)
CreateService creates a new service
func (*MockDockerClient) CreateServiceJob ¶ added in v1.7.0
func (c *MockDockerClient) CreateServiceJob() *OfficialServiceJob
CreateServiceJob creates a new ServiceJob
func (*MockDockerClient) InspectContainer ¶ added in v1.7.0
func (c *MockDockerClient) InspectContainer(id string) (*Container, error)
InspectContainer inspects a container by ID
func (*MockDockerClient) InspectExec ¶ added in v1.7.0
func (c *MockDockerClient) InspectExec(execID string) (*ExecInspect, error)
InspectExec inspects an exec instance
func (*MockDockerClient) InspectService ¶ added in v1.7.0
func (c *MockDockerClient) InspectService(id string) (*Service, error)
InspectService inspects a service
func (*MockDockerClient) ListContainers ¶ added in v1.7.0
func (c *MockDockerClient) ListContainers(filterMap map[string][]string) ([]Container, error)
ListContainers lists containers with the given filters
func (*MockDockerClient) ListTasks ¶ added in v1.7.0
func (c *MockDockerClient) ListTasks(serviceID string) ([]Task, error)
ListTasks lists tasks for a service
func (*MockDockerClient) PullImage ¶ added in v1.7.0
func (c *MockDockerClient) PullImage(imageName string) error
PullImage pulls an image from a registry
func (*MockDockerClient) RemoveContainer ¶ added in v1.7.0
func (c *MockDockerClient) RemoveContainer(id string) error
RemoveContainer removes a container
func (*MockDockerClient) RemoveService ¶ added in v1.7.0
func (c *MockDockerClient) RemoveService(id string) error
RemoveService removes a service
func (*MockDockerClient) StartContainer ¶ added in v1.7.0
func (c *MockDockerClient) StartContainer(id string) error
StartContainer starts a container
func (*MockDockerClient) StartExec ¶ added in v1.7.0
func (c *MockDockerClient) StartExec(execID string, attachStdout, attachStderr bool) (io.ReadCloser, error)
StartExec starts an exec instance
func (*MockDockerClient) StopContainer ¶ added in v1.7.0
func (c *MockDockerClient) StopContainer(id string) error
StopContainer stops a container
func (*MockDockerClient) WaitContainer ¶ added in v1.7.0
func (c *MockDockerClient) WaitContainer(id string) (int, error)
WaitContainer waits for a container to exit and returns its exit code
func (*MockDockerClient) WatchEvents ¶ added in v1.7.0
func (c *MockDockerClient) WatchEvents(ctx context.Context, eventCh chan<- *DockerEvent, errCh chan<- error)
WatchEvents watches Docker events and sends them to the provided channel
type OfficialDockerClient ¶ added in v1.7.0
type OfficialDockerClient struct {
// contains filtered or unexported fields
}
OfficialDockerClient implements DockerClient using the official Docker client
func (*OfficialDockerClient) Close ¶ added in v1.7.0
func (c *OfficialDockerClient) Close() error
Close closes the Docker client
func (*OfficialDockerClient) CreateContainer ¶ added in v1.7.0
func (c *OfficialDockerClient) CreateContainer(config *ContainerConfig) (*Container, error)
CreateContainer creates a new container
func (*OfficialDockerClient) CreateExec ¶ added in v1.7.0
func (c *OfficialDockerClient) CreateExec(containerID string, cmd []string, config *ExecConfig) (string, error)
CreateExec creates an exec instance in a container
func (*OfficialDockerClient) CreateExecJob ¶ added in v1.7.0
func (c *OfficialDockerClient) CreateExecJob() *OfficialExecJob
CreateExecJob creates a new OfficialExecJob
func (*OfficialDockerClient) CreateLifecycleJob ¶ added in v1.7.0
func (c *OfficialDockerClient) CreateLifecycleJob() *OfficialLifecycleJob
CreateLifecycleJob creates a new OfficialLifecycleJob
func (*OfficialDockerClient) CreateRunJob ¶ added in v1.7.0
func (c *OfficialDockerClient) CreateRunJob() *OfficialRunJob
CreateRunJob creates a new OfficialRunJob
func (*OfficialDockerClient) CreateService ¶ added in v1.7.0
func (c *OfficialDockerClient) CreateService(config *ServiceConfig) (string, error)
CreateService creates a new service
func (*OfficialDockerClient) CreateServiceJob ¶ added in v1.7.0
func (c *OfficialDockerClient) CreateServiceJob() *OfficialServiceJob
CreateServiceJob creates a new OfficialServiceJob
func (*OfficialDockerClient) InspectContainer ¶ added in v1.7.0
func (c *OfficialDockerClient) InspectContainer(id string) (*Container, error)
InspectContainer inspects a container by ID
func (*OfficialDockerClient) InspectExec ¶ added in v1.7.0
func (c *OfficialDockerClient) InspectExec(execID string) (*ExecInspect, error)
InspectExec inspects an exec instance
func (*OfficialDockerClient) InspectService ¶ added in v1.7.0
func (c *OfficialDockerClient) InspectService(id string) (*Service, error)
InspectService inspects a service
func (*OfficialDockerClient) ListContainers ¶ added in v1.7.0
func (c *OfficialDockerClient) ListContainers(filterMap map[string][]string) ([]Container, error)
ListContainers lists containers with the given filters
func (*OfficialDockerClient) ListTasks ¶ added in v1.7.0
func (c *OfficialDockerClient) ListTasks(serviceID string) ([]Task, error)
ListTasks lists tasks for a service
func (*OfficialDockerClient) PullImage ¶ added in v1.7.0
func (c *OfficialDockerClient) PullImage(imageName string) error
PullImage pulls an image from a registry
func (*OfficialDockerClient) RemoveContainer ¶ added in v1.7.0
func (c *OfficialDockerClient) RemoveContainer(id string) error
RemoveContainer removes a container
func (*OfficialDockerClient) RemoveService ¶ added in v1.7.0
func (c *OfficialDockerClient) RemoveService(id string) error
RemoveService removes a service
func (*OfficialDockerClient) StartContainer ¶ added in v1.7.0
func (c *OfficialDockerClient) StartContainer(id string) error
StartContainer starts a container
func (*OfficialDockerClient) StartExec ¶ added in v1.7.0
func (c *OfficialDockerClient) StartExec(execID string, attachStdout, attachStderr bool) (io.ReadCloser, error)
StartExec starts an exec instance
func (*OfficialDockerClient) StopContainer ¶ added in v1.7.0
func (c *OfficialDockerClient) StopContainer(id string) error
StopContainer stops a container
func (*OfficialDockerClient) WaitContainer ¶ added in v1.7.0
func (c *OfficialDockerClient) WaitContainer(id string) (int, error)
WaitContainer waits for a container to exit and returns its exit code
func (*OfficialDockerClient) WatchEvents ¶ added in v1.7.0
func (c *OfficialDockerClient) WatchEvents(ctx context.Context, eventCh chan<- *DockerEvent, errCh chan<- error)
WatchEvents watches Docker events and sends them to the provided channel
type OfficialExecJob ¶ added in v1.7.0
type OfficialExecJob struct {
BareJob `mapstructure:",squash"`
Client DockerClient `json:"-"`
Container string `hash:"true"`
User string `default:"root" hash:"true"`
TTY bool `default:"false" hash:"true"`
}
OfficialExecJob is an adapter for ExecJob that uses the DockerClient interface
func NewOfficialExecJob ¶ added in v1.7.0
func NewOfficialExecJob(c DockerClient) *OfficialExecJob
NewOfficialExecJob creates a new OfficialExecJob
func (*OfficialExecJob) Hash ¶ added in v1.7.0
func (j *OfficialExecJob) Hash() string
Hash returns a hash of all the job attributes
func (*OfficialExecJob) Middlewares ¶ added in v1.7.0
func (c *OfficialExecJob) Middlewares() []Middleware
func (*OfficialExecJob) Run ¶ added in v1.7.0
func (j *OfficialExecJob) Run(ctx *Context) error
Run executes the job
func (*OfficialExecJob) Use ¶ added in v1.7.0
func (c *OfficialExecJob) Use(ms ...Middleware)
type OfficialLifecycleJob ¶ added in v1.7.0
type OfficialLifecycleJob struct {
BareJob `mapstructure:",squash"`
Client DockerClient `json:"-"`
Container string `hash:"true"`
User string `default:"root" hash:"true"`
TTY bool `default:"false" hash:"true"`
EventType LifecycleEventType `hash:"true"`
Executed bool `hash:"-"`
}
OfficialLifecycleJob is an adapter for LifecycleJob that uses the DockerClient interface
func NewOfficialLifecycleJob ¶ added in v1.7.0
func NewOfficialLifecycleJob(c DockerClient) *OfficialLifecycleJob
NewOfficialLifecycleJob creates a new OfficialLifecycleJob
func (*OfficialLifecycleJob) Hash ¶ added in v1.7.0
func (j *OfficialLifecycleJob) Hash() string
Hash returns a hash of all the job attributes
func (*OfficialLifecycleJob) Middlewares ¶ added in v1.7.0
func (c *OfficialLifecycleJob) Middlewares() []Middleware
func (*OfficialLifecycleJob) Run ¶ added in v1.7.0
func (j *OfficialLifecycleJob) Run(ctx *Context) error
Run executes the job
func (*OfficialLifecycleJob) Use ¶ added in v1.7.0
func (c *OfficialLifecycleJob) Use(ms ...Middleware)
type OfficialRunJob ¶ added in v1.7.0
type OfficialRunJob struct {
BareJob `mapstructure:",squash"`
Client DockerClient `json:"-"`
Image string `hash:"true"`
Network string `default:"bridge" hash:"true"`
Pull string `default:"missing" hash:"true"`
User string `default:"root" hash:"true"`
TTY bool `default:"false" hash:"true"`
Environment []string `hash:"true"`
Volumes []string `hash:"true"`
WorkingDir string `hash:"true"`
}
OfficialRunJob is an adapter for RunJob that uses the DockerClient interface
func NewOfficialRunJob ¶ added in v1.7.0
func NewOfficialRunJob(c DockerClient) *OfficialRunJob
NewOfficialRunJob creates a new OfficialRunJob
func (*OfficialRunJob) Hash ¶ added in v1.7.0
func (j *OfficialRunJob) Hash() string
Hash returns a hash of all the job attributes
func (*OfficialRunJob) Middlewares ¶ added in v1.7.0
func (c *OfficialRunJob) Middlewares() []Middleware
func (*OfficialRunJob) Run ¶ added in v1.7.0
func (j *OfficialRunJob) Run(ctx *Context) error
Run executes the job
func (*OfficialRunJob) Use ¶ added in v1.7.0
func (c *OfficialRunJob) Use(ms ...Middleware)
type OfficialServiceJob ¶ added in v1.7.0
type OfficialServiceJob struct {
BareJob `mapstructure:",squash"`
Client DockerClient `json:"-"`
Container string `hash:"true"`
User string `default:"root" hash:"true"`
TTY bool `default:"false" hash:"true"`
}
OfficialServiceJob is an adapter for ServiceJob that uses the DockerClient interface
func NewOfficialServiceJob ¶ added in v1.7.0
func NewOfficialServiceJob(c DockerClient) *OfficialServiceJob
NewOfficialServiceJob creates a new OfficialServiceJob
func (*OfficialServiceJob) GetProcessedCommand ¶ added in v1.7.0
func (j *OfficialServiceJob) GetProcessedCommand(varContext VariableContext) string
GetProcessedCommand returns the processed command with variables replaced
func (*OfficialServiceJob) Hash ¶ added in v1.7.0
func (j *OfficialServiceJob) Hash() string
Hash returns a hash of all the job attributes
func (*OfficialServiceJob) Middlewares ¶ added in v1.7.0
func (c *OfficialServiceJob) Middlewares() []Middleware
func (*OfficialServiceJob) Run ¶ added in v1.7.0
func (j *OfficialServiceJob) Run(ctx *Context) error
Run executes the job
func (*OfficialServiceJob) Use ¶ added in v1.7.0
func (c *OfficialServiceJob) Use(ms ...Middleware)
type ReadCloserWrapper ¶ added in v1.7.0
ReadCloserWrapper wraps a bufio.Reader to implement io.ReadCloser
func (*ReadCloserWrapper) Close ¶ added in v1.7.0
func (r *ReadCloserWrapper) Close() error
Close calls the stored closer function
type RestartPolicy ¶ added in v1.7.0
RestartPolicy represents the restart policy for a service
type RunJob ¶
type RunJob struct {
BareJob `mapstructure:",squash"`
Client DockerClient `json:"-"`
Container string `hash:"true"`
Image string `hash:"true"`
User string `default:"root" hash:"true"`
TTY bool `default:"false" hash:"true"`
Delete bool `default:"true" hash:"true"`
Network string `hash:"true"`
Volume []string `hash:"true"`
}
RunJob represents a job that runs a command in a Docker container
func (*RunJob) Hash ¶ added in v1.5.0
Returns a hash of all the job attributes. Used to detect changes
func (*RunJob) Middlewares ¶
func (c *RunJob) Middlewares() []Middleware
func (*RunJob) Use ¶
func (c *RunJob) Use(ms ...Middleware)
type RunServiceJob ¶
type RunServiceJob struct {
BareJob `mapstructure:",squash"`
Client DockerClient `json:"-"`
User string `default:"root"`
TTY bool `default:"false"`
// do not use bool values with "default:true" because if
// user would set it to "false" explicitly, it still will be
// changed to "true" https://github.com/mcuadros/ofelia/issues/135
// so lets use strings here as workaround
Delete string `default:"true"`
Image string
Network string
}
RunServiceJob represents a job that runs a Docker service
func NewRunServiceJob ¶
func NewRunServiceJob(c DockerClient) *RunServiceJob
NewRunServiceJob creates a new RunServiceJob
func (*RunServiceJob) Middlewares ¶
func (c *RunServiceJob) Middlewares() []Middleware
func (*RunServiceJob) Run ¶
func (j *RunServiceJob) Run(ctx *Context) error
func (*RunServiceJob) Use ¶
func (c *RunServiceJob) Use(ms ...Middleware)
type Scheduler ¶
func NewScheduler ¶
func (*Scheduler) Middlewares ¶
func (c *Scheduler) Middlewares() []Middleware
func (*Scheduler) Use ¶
func (c *Scheduler) Use(ms ...Middleware)
type Service ¶ added in v1.7.0
type Service struct {
ID string
Name string
CreatedAt time.Time
UpdatedAt time.Time
Spec ServiceConfig
Endpoint ServiceEndpoint
UpdateState ServiceUpdateState
}
Service represents a Docker service
type ServiceConfig ¶ added in v1.7.0
type ServiceConfig struct {
Name string
Image string
Cmd []string
Env []string
Labels map[string]string
RestartPolicy *RestartPolicy
Networks []string
Mounts []ServiceMount
}
ServiceConfig represents configuration for creating a service
type ServiceEndpoint ¶ added in v1.7.0
type ServiceEndpoint struct {
Ports []ServicePort
}
ServiceEndpoint represents the endpoint of a service
type ServiceJob ¶ added in v1.5.0
type ServiceJob struct {
BareJob `mapstructure:",squash"`
Container string `hash:"true"`
Client DockerClient `json:"-"`
TTY bool `default:"false" hash:"true"`
User string `default:"root" hash:"true"`
}
ServiceJob represents a job that runs a command in a Docker container as a service
func NewServiceJob ¶ added in v1.5.0
func NewServiceJob(c DockerClient) *ServiceJob
NewServiceJob creates a new ServiceJob
func (*ServiceJob) GetProcessedCommand ¶ added in v1.5.0
func (j *ServiceJob) GetProcessedCommand(varContext VariableContext) string
func (*ServiceJob) Middlewares ¶ added in v1.5.0
func (c *ServiceJob) Middlewares() []Middleware
func (*ServiceJob) Run ¶ added in v1.5.0
func (j *ServiceJob) Run(ctx *Context) error
func (*ServiceJob) Use ¶ added in v1.5.0
func (c *ServiceJob) Use(ms ...Middleware)
type ServiceMount ¶ added in v1.7.0
ServiceMount represents a mount for a service
type ServicePort ¶ added in v1.7.0
ServicePort represents a port of a service
type ServiceUpdateState ¶ added in v1.7.0
ServiceUpdateState represents the update state of a service
type Task ¶ added in v1.7.0
type Task struct {
ID string
ServiceID string
NodeID string
Status TaskStatus
DesiredState string
CreatedAt time.Time
UpdatedAt time.Time
}
Task represents a Docker task
type TaskStatus ¶ added in v1.7.0
TaskStatus represents the status of a task
type VariableContext ¶ added in v1.5.0
type VariableContext struct {
Container ContainerInfo
}
VariableContext holds all the variables that can be used in replacements