Documentation
¶
Index ¶
- Variables
- func EncodeBasicAuth(username, password string) string
- func EvalContainerFields(ctx context.Context, ct core.Container) (core.Container, error)
- func GetKeepaliveFile(platform specs.Platform) (string, error)
- func WithContainerClient(ctx context.Context, cli *Client) context.Context
- func WithRegistryAuth(ctx context.Context, auths map[string]*core.AuthConfig) context.Context
- type Client
- func (c *Client) Close(ctx context.Context)
- func (c *Client) CreateContainerKeepAlive(ctx context.Context) error
- func (c *Client) Exec(ctx context.Context, cmd []string, stdout, stderr io.Writer, opts ExecOptions) (int, error)
- func (c *Client) Run(ctx context.Context, cmd []string, stdout, stderr io.Writer) (int, error)
- func (c *Client) StartBackground(ctx context.Context) error
- func (c *Client) Stop(sig os.Signal) error
- func (c *Client) StopContainerKeepAlive(ctx context.Context)
- type Config
- type ExecOptions
- type RegistryAuthManager
Constants ¶
This section is empty.
Variables ¶
var ( ErrImageOrContainerShouldNotBeEmpty = errors.New("containerName or image must be specified") ErrImageRequired = errors.New("image is required") ErrInvalidVolumeFormat = errors.New("invalid volume format") ErrInvalidPortFormat = errors.New("invalid port format") ErrContainerIsNotRunning = errors.New("container is not running") // Validation errors for docker executor map config ErrExecOnlyWithContainerName = errors.New("'exec' options require 'containerName' (exec-in-existing mode)") ErrInvalidOptionsWithContainerName = errors.New("'container', 'host', 'network', 'pull', 'platform', or 'autoRemove' not supported with 'containerName'") )
Errors for container
var (
ErrExecutorConfigRequired = errors.New("executor config is required")
)
Functions ¶
func EncodeBasicAuth ¶
EncodeBasicAuth encodes username and password as base64(username:password)
func EvalContainerFields ¶ added in v1.30.0
EvalContainerFields evaluates environment variables in container fields at runtime. Only fields that commonly use variables are evaluated: - Exec, Image, Name, User, WorkingDir, Network (string fields) - Volumes, Ports, Env, Command (slice fields) Fields like PullPolicy, Startup, WaitFor, KeepContainer are NOT evaluated as they have specific enum/boolean values.
func GetKeepaliveFile ¶
GetKeepaliveFile copies the embedded keepalive binary to a temp file and returns its path
func WithContainerClient ¶
WithContainerClient creates a new context with a client for container
func WithRegistryAuth ¶
WithRegistryAuth creates a new context with registry authentication.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func GetContainerClient ¶
GetContainerClient retrieves the container client from the context.
func InitializeClient ¶
InitializeClient creates a new container client
func (*Client) CreateContainerKeepAlive ¶
CreateContainerKeepAlive creates the container that lives while the DAG running
func (*Client) Exec ¶
func (c *Client) Exec(ctx context.Context, cmd []string, stdout, stderr io.Writer, opts ExecOptions) (int, error)
Exec executes the command in the running container
func (*Client) StartBackground ¶ added in v1.29.0
StartBackground starts a container in the background without waiting for it to exit. This is useful for starting containers that should stay running while multiple commands are executed via Exec. The container uses the configured startup command (StartCmd) when startup mode is "command", or the default keepalive when in "keepalive" mode. This delegates to CreateContainerKeepAlive which handles all startup modes properly.
func (*Client) StopContainerKeepAlive ¶
StopContainerKeepAlive stops the container running keep alive command
type Config ¶
type Config struct {
// Image is the Docker image to use for creating a new container.
Image string
// Platform is the target platform for the container (e.g., linux/amd64).
Platform string
// ContainerName is the name or ID of an existing container to exec into.
ContainerName string
// Pull is the image pull policy for new containers.
Pull core.PullPolicy
// Container is the container configuration for new containers.
// See https://pkg.go.dev/github.com/docker/docker/api/types/container#Config
Container *container.Config
// Host is the host configuration for new containers.
// See https://pkg.go.dev/github.com/docker/docker/api/types/container#HostConfig
Host *container.HostConfig
// Network is the network configuration for new containers.
// See https://pkg.go.dev/github.com/docker/docker@v27.5.1+incompatible/api/types/network#NetworkingConfig
Network *network.NetworkingConfig
// ExecOptions are the options for executing a command in the container.
// See https://pkg.go.dev/github.com/docker/docker/api/types/container#ExecOptions
ExecOptions *container.ExecOptions
// AutoRemove indicates whether to automatically remove the container after it exits.
AutoRemove bool
// AuthManager is responsible for managing registry authentication.
AuthManager *RegistryAuthManager
// Startup mode for DAG-level container: "keepalive" (default) | "entrypoint" | "command"
Startup string
// WaitFor readiness gate: "running" (default) | "healthy"
WaitFor string
// StartCmd command for startup when startup == "command"
StartCmd []string
// LogPattern optional regex to wait for in logs before proceeding (if empty, no wait)
LogPattern string
// ShouldStart indicates whether the container should be started (for DAG-level containers)
ShouldStart bool
}
Config holds the configuration for creating or using a container.
func LoadConfig ¶
func LoadConfig(workDir string, ct core.Container, registryAuths map[string]*core.AuthConfig) (*Config, error)
NewFromContainerConfigWithAuth parses core.Container into Container struct with registry auth
func LoadConfigFromMap ¶
func LoadConfigFromMap(data map[string]any, registryAuths map[string]*core.AuthConfig) (*Config, error)
LoadConfig parses executorConfig into Container struct with registry auth
type ExecOptions ¶
type ExecOptions struct {
// WorkingDir overrides the working directory for the exec command.
WorkingDir string
}
ExecOptions specifies options to execute commands in the container.
type RegistryAuthManager ¶
type RegistryAuthManager struct {
// contains filtered or unexported fields
}
RegistryAuthManager handles authentication for container registries
func NewRegistryAuthManager ¶
func NewRegistryAuthManager(auths map[string]*core.AuthConfig) *RegistryAuthManager
NewRegistryAuthManager creates a new registry authentication manager
func (*RegistryAuthManager) GetAuthHeader ¶
func (r *RegistryAuthManager) GetAuthHeader(imageName string) (string, error)
GetAuthHeader returns the X-Registry-Auth header value for the given image
func (*RegistryAuthManager) GetPullOptions ¶
func (r *RegistryAuthManager) GetPullOptions(imageName string, platform string) (image.PullOptions, error)
GetPullOptions returns ImagePullOptions with authentication for the given image