Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CliCommand contextKey
CliCommand is the context key to pass cli context to backends if needed.
var ErrNoCliContextFound = errors.New("no CliContext in context found")
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
Auth defines registry authentication credentials.
type Backend ¶
type Backend interface {
// Name returns the name of the backend.
Name() string
// IsAvailable check if the backend is available.
IsAvailable(ctx context.Context) bool
// Flags return the configuration flags of the backend.
Flags() []cli.Flag
// Load loads the backend engine.
Load(ctx context.Context) (*BackendInfo, error)
// SetupWorkflow sets up the workflow environment.
SetupWorkflow(ctx context.Context, conf *Config, taskUUID string) error
// StartStep starts the workflow step.
StartStep(ctx context.Context, step *Step, taskUUID string) error
// WaitStep waits for the workflow step to complete and returns
// the completion results.
WaitStep(ctx context.Context, step *Step, taskUUID string) (*State, error)
// TailStep tails the workflow step logs.
TailStep(ctx context.Context, step *Step, taskUUID string) (io.ReadCloser, error)
// DestroyStep destroys the workflow step.
DestroyStep(ctx context.Context, step *Step, taskUUID string) error
// DestroyWorkflow destroys the workflow environment.
DestroyWorkflow(ctx context.Context, conf *Config, taskUUID string) error
}
Backend defines a container orchestration backend and is used to create and manage container resources.
type BackendInfo ¶
type BackendInfo struct {
Platform string
}
BackendInfo represents the reported information of a loaded backend.
type Config ¶
type Config struct {
Stages []*Stage `json:"pipeline"` // workflow stages
Network string `json:"network"` // network definition
Volume string `json:"volume"` // volume definition
Secrets []*Secret `json:"secrets"` // secret definitions
}
Config defines the runtime configuration of a workflow.
type DiscoveredStep ¶
type DiscoveredStep struct {
// UUID is the step's unique identifier.
UUID string
// Name is the human-readable step name.
Name string
// ContainerID is the backend-specific container/pod identifier.
ContainerID string
}
DiscoveredStep represents a step found during workflow discovery.
type DiscoveredWorkflow ¶
type DiscoveredWorkflow struct {
// TaskUUID is the unique identifier for the workflow/task.
TaskUUID string
// Steps contains information about the running steps in this workflow.
Steps []*DiscoveredStep
}
DiscoveredWorkflow represents a workflow found during discovery that may be eligible for adoption by a restarted agent.
type Stage ¶
type Stage struct {
Steps []*Step `json:"steps,omitempty"`
}
Stage denotes a collection of one or more steps.
type State ¶
type State struct {
// Container exit code
ExitCode int `json:"exit_code"`
// Container exited, true or false
Exited bool `json:"exited"`
// Container is oom killed, true or false
OOMKilled bool `json:"oom_killed"`
// Container error
Error error
}
State defines a container state.
type Step ¶
type Step struct {
Name string `json:"name"`
OrgID int64 `json:"org_id,omitempty"`
UUID string `json:"uuid"`
Type StepType `json:"type,omitempty"`
Image string `json:"image,omitempty"`
Pull bool `json:"pull,omitempty"`
Detached bool `json:"detach,omitempty"`
Privileged bool `json:"privileged,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
WorkspaceBase string `json:"workspace_base,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
SecretMapping map[string]string `json:"secret_mapping,omitempty"`
Entrypoint []string `json:"entrypoint,omitempty"`
Commands []string `json:"commands,omitempty"`
ExtraHosts []HostAlias `json:"extra_hosts,omitempty"`
Volumes []string `json:"volumes,omitempty"`
Tmpfs []string `json:"tmpfs,omitempty"`
Devices []string `json:"devices,omitempty"`
Networks []Conn `json:"networks,omitempty"`
DNS []string `json:"dns,omitempty"`
DNSSearch []string `json:"dns_search,omitempty"`
OnFailure bool `json:"on_failure,omitempty"`
OnSuccess bool `json:"on_success,omitempty"`
Failure string `json:"failure,omitempty"`
AuthConfig Auth `json:"auth_config,omitempty"`
NetworkMode string `json:"network_mode,omitempty"`
Ports []Port `json:"ports,omitempty"`
BackendOptions map[string]any `json:"backend_options,omitempty"`
WorkflowLabels map[string]string `json:"workflow_labels,omitempty"`
ContainerNameScheme string `json:"container_name_scheme,omitempty"`
DependsOn []string `json:"depends_on,omitempty"`
}
Step defines a container process.
type WorkflowDiscoverer ¶
type WorkflowDiscoverer interface {
// DiscoverWorkflows finds orphaned workflows that can be adopted.
// Returns a list of discovered workflows with their task UUIDs and running steps.
DiscoverWorkflows(ctx context.Context) ([]*DiscoveredWorkflow, error)
}
WorkflowDiscoverer is an optional interface that backends can implement to support discovering orphaned workflows for adoption after agent restart. Backends that cannot support this (like local) should not implement it.
type WorkflowResumer ¶
type WorkflowResumer interface {
// ResumeStep resumes monitoring of an already-running step (for adopted workflows).
// Unlike StartStep, this does not create a new container - it attaches to an existing one.
// The step parameter should have its UUID set to match the running container.
ResumeStep(ctx context.Context, step *Step, taskUUID string) error
}
WorkflowResumer is an optional interface that backends can implement to support resuming monitoring of adopted workflows after agent restart. This is used in conjunction with WorkflowDiscoverer.