Documentation
¶
Overview ¶
Package docker provides a Docker-based implementation of the runner interface.
Index ¶
- type DockerClient
- type DockerConfig
- type DockerExecStream
- func (s *DockerExecStream) Close() error
- func (s *DockerExecStream) ExitCode() (int, error)
- func (s *DockerExecStream) Read(p []byte) (n int, err error)
- func (s *DockerExecStream) ResizeTerminal(width, height uint32) error
- func (s *DockerExecStream) Signal(sigName string) error
- func (s *DockerExecStream) Stderr() io.Reader
- func (s *DockerExecStream) Write(p []byte) (n int, err error)
- type DockerRunner
- func (r *DockerRunner) Create(ctx context.Context, instance *runetypes.Instance) error
- func (r *DockerRunner) Exec(ctx context.Context, instance *runetypes.Instance, options runner.ExecOptions) (runner.ExecStream, error)
- func (r *DockerRunner) GetLogs(ctx context.Context, instance *runetypes.Instance, options runner.LogOptions) (io.ReadCloser, error)
- func (r *DockerRunner) List(ctx context.Context, namespace string) ([]*runetypes.Instance, error)
- func (r *DockerRunner) Remove(ctx context.Context, instance *runetypes.Instance, force bool) error
- func (r *DockerRunner) Start(ctx context.Context, instance *runetypes.Instance) error
- func (r *DockerRunner) Status(ctx context.Context, instance *runetypes.Instance) (runetypes.InstanceStatus, error)
- func (r *DockerRunner) Stop(ctx context.Context, instance *runetypes.Instance, timeout time.Duration) error
- func (r *DockerRunner) Type() types.RunnerType
- type RegistryAuth
- type RegistryConfig
- type SliceStringer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DockerClient ¶
type DockerClient interface {
ContainerExecCreate(ctx context.Context, containerID string, config container.ExecOptions) (container.ExecCreateResponse, error)
ContainerExecAttach(ctx context.Context, execID string, config container.ExecStartOptions) (types.HijackedResponse, error)
ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error)
ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error
}
DockerClient defines the Docker API methods we need
type DockerConfig ¶
type DockerConfig struct {
// APIVersion is the Docker API version to use
// If empty, auto-negotiation will be used
APIVersion string
// FallbackAPIVersion is used when auto-negotiation fails
// Default is "1.43" which is widely compatible
FallbackAPIVersion string
// Timeout for API version negotiation in seconds
NegotiationTimeoutSeconds int
// Permissions for mounts created on the host before binding into containers
// If zero, sensible defaults will be used.
SecretDirMode os.FileMode
SecretFileMode os.FileMode
ConfigDirMode os.FileMode
ConfigFileMode os.FileMode
// Registry authentication configuration loaded from runefile
Registries []RegistryConfig
}
DockerConfig holds Docker runner configuration options
func DefaultDockerConfig ¶
func DefaultDockerConfig() *DockerConfig
DefaultDockerConfig returns the default Docker configuration
type DockerExecStream ¶
type DockerExecStream struct {
// contains filtered or unexported fields
}
DockerExecStream implements the runner.ExecStream interface for Docker containers.
func NewDockerExecStream ¶
func NewDockerExecStream( ctx context.Context, cli DockerClient, containerID string, instanceID string, options runner.ExecOptions, logger log.Logger, ) (*DockerExecStream, error)
NewDockerExecStream creates a new DockerExecStream.
func (*DockerExecStream) Close ¶
func (s *DockerExecStream) Close() error
Close terminates the exec session and releases resources.
func (*DockerExecStream) ExitCode ¶
func (s *DockerExecStream) ExitCode() (int, error)
ExitCode returns the exit code after the process has completed.
func (*DockerExecStream) Read ¶
func (s *DockerExecStream) Read(p []byte) (n int, err error)
Read reads data from the standard output of the process.
func (*DockerExecStream) ResizeTerminal ¶
func (s *DockerExecStream) ResizeTerminal(width, height uint32) error
ResizeTerminal resizes the terminal (if TTY was enabled).
func (*DockerExecStream) Signal ¶
func (s *DockerExecStream) Signal(sigName string) error
Signal sends a signal to the process.
func (*DockerExecStream) Stderr ¶
func (s *DockerExecStream) Stderr() io.Reader
Stderr provides access to the standard error stream of the process.
type DockerRunner ¶
type DockerRunner struct {
// contains filtered or unexported fields
}
DockerRunner implements the runner.Runner interface for Docker.
func NewDockerRunner ¶
func NewDockerRunner(logger log.Logger) (*DockerRunner, error)
NewDockerRunner creates a new DockerRunner instance.
func NewDockerRunnerWithConfig ¶
func NewDockerRunnerWithConfig(logger log.Logger, config *DockerConfig) (*DockerRunner, error)
NewDockerRunnerWithConfig creates a new DockerRunner with specific configuration.
func (*DockerRunner) Exec ¶
func (r *DockerRunner) Exec(ctx context.Context, instance *runetypes.Instance, options runner.ExecOptions) (runner.ExecStream, error)
Exec creates an interactive exec session with a running container.
func (*DockerRunner) GetLogs ¶
func (r *DockerRunner) GetLogs(ctx context.Context, instance *runetypes.Instance, options runner.LogOptions) (io.ReadCloser, error)
GetLogs retrieves logs from a container.
func (*DockerRunner) Status ¶
func (r *DockerRunner) Status(ctx context.Context, instance *runetypes.Instance) (runetypes.InstanceStatus, error)
Status retrieves the current status of a container.
func (*DockerRunner) Stop ¶
func (r *DockerRunner) Stop(ctx context.Context, instance *runetypes.Instance, timeout time.Duration) error
Stop stops a running container.
func (*DockerRunner) Type ¶
func (r *DockerRunner) Type() types.RunnerType
type RegistryAuth ¶
type RegistryAuth struct {
Type string `mapstructure:"type"` // basic | token | ecr
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
Token string `mapstructure:"token"`
Region string `mapstructure:"region"`
}
RegistryAuth defines supported auth types
type RegistryConfig ¶
type RegistryConfig struct {
Name string `mapstructure:"name"`
Registry string `mapstructure:"registry"`
Auth RegistryAuth `mapstructure:"auth"`
}
RegistryConfig defines a registry auth entry
type SliceStringer ¶
type SliceStringer []string
SliceStringer creates a string formatter for string slices.
func (SliceStringer) String ¶
func (s SliceStringer) String() string
String implements the fmt.Stringer interface.