runtime

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package runtime is a generated GoMock package.

Index

Constants

View Source
const (
	FlavorUnknown        = ""
	FlavorDockerDesktop  = "docker-desktop"
	FlavorRancherDesktop = "rancher-desktop"
	FlavorColima         = "colima"
	FlavorOrbstack       = "orbstack"
	FlavorLima           = "lima"
	FlavorPodman         = "podman"
	FlavorPodmanRootful  = "podman-rootful"
	FlavorPodmanRootless = "podman-rootless"
	FlavorDockerNative   = "docker"
)

Exported flavor identifiers returned by Runtime.Flavor, so packages outside runtime (e.g. internal/container) can tailor user-facing messages to the runtime in use without depending on the unexported classifier.

Variables

View Source
var ErrExternalRuntimeUnsupported = errors.New("not supported for an externally-managed emulator (--endpoint-url)")

ErrExternalRuntimeUnsupported is returned by externalRuntime methods that have no meaning for an emulator lstk did not start and does not manage.

View Source
var ErrNoImageVersion = errors.New("LOCALSTACK_BUILD_VERSION not found in image environment")

ErrNoImageVersion means the image has no LOCALSTACK_BUILD_VERSION, so it is not a LocalStack AWS emulator image.

Functions

func DetectInstalledFlavor added in v0.20.0

func DetectInstalledFlavor() string

DetectInstalledFlavor reports which container runtime appears to be installed on this machine from filesystem/PATH evidence alone (state directories, the podman CLI), independent of the daemon lstk is connected to. This matters for hints when socket classification comes up empty — e.g. on Windows the daemon host is a named pipe, which classifySocketFlavor cannot attribute to any runtime, so Flavor() alone would hide runtime-specific fixes there.

Types

type BindMount added in v0.5.1

type BindMount struct {
	HostPath      string
	ContainerPath string
	ReadOnly      bool
}

BindMount represents a host-to-container bind mount.

type ContainerBrief added in v0.20.0

type ContainerBrief struct {
	Exists        bool
	Running       bool
	Created       bool   // state "created": created but never started
	AutoRemove    bool   // created with --rm: removes itself once it exits
	Image         string // full image the container was created from
	Managed       bool   // carries the label Start stamps on every lstk container
	ImageOverride bool   // started with --image
}

ContainerBrief describes an existing container for pre-start checks, so callers can tell an lstk leftover (safe to self-heal) from a foreign container that happens to use the same name.

type ContainerConfig

type ContainerConfig struct {
	Image         string
	Name          string
	EmulatorType  config.EmulatorType
	Port          string
	ContainerPort string // internal port the emulator listens on inside the container (e.g. "4566/tcp")
	BindHost      string // host IP to bind published ports to (e.g. "127.0.0.1" or "0.0.0.0"); defaults to loopback when empty
	HealthPath    string
	Env           []string // e.g., ["KEY=value", "FOO=bar"]
	Tag           string
	ProductName   string
	Binds         []BindMount
	ExtraPorts    []PortMapping
	ImageOverride bool // started with --image
	// BundledLicense marks a local image with its own license. Used by the
	// start flow; ignored by the runtime.
	BundledLicense bool
}

type DockerRuntime

type DockerRuntime struct {
	// contains filtered or unexported fields
}

func NewDockerRuntime

func NewDockerRuntime(dockerHost string) (*DockerRuntime, error)

func (*DockerRuntime) ContainerEnv added in v0.9.0

func (d *DockerRuntime) ContainerEnv(ctx context.Context, containerName string) ([]string, error)

func (*DockerRuntime) ContainerStartedAt added in v0.5.0

func (d *DockerRuntime) ContainerStartedAt(ctx context.Context, containerName string) (time.Time, error)

func (*DockerRuntime) EmitUnhealthyError added in v0.2.0

func (d *DockerRuntime) EmitUnhealthyError(sink output.Sink, err error)

func (*DockerRuntime) FindRunningByImage added in v0.6.0

func (d *DockerRuntime) FindRunningByImage(ctx context.Context, imageRepos []string, containerPort string) (*RunningContainer, error)

func (*DockerRuntime) Flavor added in v0.20.0

func (d *DockerRuntime) Flavor() string

SocketPath returns the daemon-visible Unix socket path to bind-mount into containers so LocalStack can launch nested workloads such as Lambda functions. For VM-based Docker (Colima, OrbStack) returns /var/run/docker.sock as the socket is remapped inside the VM. For rootless or custom setups, returns the actual socket path extracted from the daemon host.

func (*DockerRuntime) GetBoundPort added in v0.5.2

func (d *DockerRuntime) GetBoundPort(ctx context.Context, containerName string, containerPort string) (string, error)

func (*DockerRuntime) GetImageVersion

func (d *DockerRuntime) GetImageVersion(ctx context.Context, imageName string) (string, error)

func (*DockerRuntime) ImageEnv added in v1.4.0

func (d *DockerRuntime) ImageEnv(ctx context.Context, image string) ([]string, error)

func (*DockerRuntime) ImageExists added in v0.14.0

func (d *DockerRuntime) ImageExists(ctx context.Context, image string) (bool, error)

func (*DockerRuntime) InspectBrief added in v0.20.0

func (d *DockerRuntime) InspectBrief(ctx context.Context, containerName string) (ContainerBrief, error)

func (*DockerRuntime) IsHealthy added in v0.2.0

func (d *DockerRuntime) IsHealthy(ctx context.Context) error

func (*DockerRuntime) IsRunning

func (d *DockerRuntime) IsRunning(ctx context.Context, containerID string) (bool, error)

func (*DockerRuntime) Logs

func (d *DockerRuntime) Logs(ctx context.Context, containerID string, tail int) (string, error)

func (*DockerRuntime) PullImage

func (d *DockerRuntime) PullImage(ctx context.Context, imageName string, progress chan<- PullProgress) error

func (*DockerRuntime) Remove

func (d *DockerRuntime) Remove(ctx context.Context, containerName string) error

func (*DockerRuntime) SocketPath added in v0.5.1

func (d *DockerRuntime) SocketPath() string

func (*DockerRuntime) Start

func (d *DockerRuntime) Start(ctx context.Context, config ContainerConfig) (string, <-chan ExitResult, error)

func (*DockerRuntime) Stop

func (d *DockerRuntime) Stop(ctx context.Context, containerName string) error

func (*DockerRuntime) StreamLogs

func (d *DockerRuntime) StreamLogs(ctx context.Context, containerID string, out io.Writer, follow bool, tail string) error

type ExitResult added in v0.18.0

type ExitResult struct {
	ExitCode int   // -1 when unknown
	Err      error // wait itself failed (exit code unknown)
}

ExitResult reports a container's exit as observed by the exit wait that Start registers.

type MockRuntime added in v0.2.0

type MockRuntime struct {
	// contains filtered or unexported fields
}

MockRuntime is a mock of Runtime interface.

func NewMockRuntime added in v0.2.0

func NewMockRuntime(ctrl *gomock.Controller) *MockRuntime

NewMockRuntime creates a new mock instance.

func (*MockRuntime) ContainerEnv added in v0.9.0

func (m *MockRuntime) ContainerEnv(ctx context.Context, containerName string) ([]string, error)

ContainerEnv mocks base method.

func (*MockRuntime) ContainerStartedAt added in v0.5.0

func (m *MockRuntime) ContainerStartedAt(ctx context.Context, containerName string) (time.Time, error)

ContainerStartedAt mocks base method.

func (*MockRuntime) EXPECT added in v0.2.0

func (m *MockRuntime) EXPECT() *MockRuntimeMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRuntime) EmitUnhealthyError added in v0.2.0

func (m *MockRuntime) EmitUnhealthyError(sink output.Sink, err error)

EmitUnhealthyError mocks base method.

func (*MockRuntime) FindRunningByImage added in v0.6.0

func (m *MockRuntime) FindRunningByImage(ctx context.Context, imageRepos []string, containerPort string) (*RunningContainer, error)

FindRunningByImage mocks base method.

func (*MockRuntime) Flavor added in v0.20.0

func (m *MockRuntime) Flavor() string

Flavor mocks base method.

func (*MockRuntime) GetBoundPort added in v0.5.2

func (m *MockRuntime) GetBoundPort(ctx context.Context, containerName, containerPort string) (string, error)

GetBoundPort mocks base method.

func (*MockRuntime) GetImageVersion added in v0.2.0

func (m *MockRuntime) GetImageVersion(ctx context.Context, imageName string) (string, error)

GetImageVersion mocks base method.

func (*MockRuntime) ImageEnv added in v1.4.0

func (m *MockRuntime) ImageEnv(ctx context.Context, image string) ([]string, error)

ImageEnv mocks base method.

func (*MockRuntime) ImageExists added in v0.14.0

func (m *MockRuntime) ImageExists(ctx context.Context, image string) (bool, error)

ImageExists mocks base method.

func (*MockRuntime) InspectBrief added in v0.20.0

func (m *MockRuntime) InspectBrief(ctx context.Context, containerName string) (ContainerBrief, error)

InspectBrief mocks base method.

func (*MockRuntime) IsHealthy added in v0.2.0

func (m *MockRuntime) IsHealthy(ctx context.Context) error

IsHealthy mocks base method.

func (*MockRuntime) IsRunning added in v0.2.0

func (m *MockRuntime) IsRunning(ctx context.Context, containerID string) (bool, error)

IsRunning mocks base method.

func (*MockRuntime) Logs added in v0.2.0

func (m *MockRuntime) Logs(ctx context.Context, containerID string, tail int) (string, error)

Logs mocks base method.

func (*MockRuntime) PullImage added in v0.2.0

func (m *MockRuntime) PullImage(ctx context.Context, image string, progress chan<- PullProgress) error

PullImage mocks base method.

func (*MockRuntime) Remove added in v0.2.0

func (m *MockRuntime) Remove(ctx context.Context, containerName string) error

Remove mocks base method.

func (*MockRuntime) SocketPath added in v0.5.1

func (m *MockRuntime) SocketPath() string

SocketPath mocks base method.

func (*MockRuntime) Start added in v0.2.0

func (m *MockRuntime) Start(ctx context.Context, config ContainerConfig) (string, <-chan ExitResult, error)

Start mocks base method.

func (*MockRuntime) Stop added in v0.2.0

func (m *MockRuntime) Stop(ctx context.Context, containerName string) error

Stop mocks base method.

func (*MockRuntime) StreamLogs added in v0.2.0

func (m *MockRuntime) StreamLogs(ctx context.Context, containerID string, out io.Writer, follow bool, tail string) error

StreamLogs mocks base method.

type MockRuntimeMockRecorder added in v0.2.0

type MockRuntimeMockRecorder struct {
	// contains filtered or unexported fields
}

MockRuntimeMockRecorder is the mock recorder for MockRuntime.

func (*MockRuntimeMockRecorder) ContainerEnv added in v0.9.0

func (mr *MockRuntimeMockRecorder) ContainerEnv(ctx, containerName any) *gomock.Call

ContainerEnv indicates an expected call of ContainerEnv.

func (*MockRuntimeMockRecorder) ContainerStartedAt added in v0.5.0

func (mr *MockRuntimeMockRecorder) ContainerStartedAt(ctx, containerName any) *gomock.Call

ContainerStartedAt indicates an expected call of ContainerStartedAt.

func (*MockRuntimeMockRecorder) EmitUnhealthyError added in v0.2.0

func (mr *MockRuntimeMockRecorder) EmitUnhealthyError(sink, err any) *gomock.Call

EmitUnhealthyError indicates an expected call of EmitUnhealthyError.

func (*MockRuntimeMockRecorder) FindRunningByImage added in v0.6.0

func (mr *MockRuntimeMockRecorder) FindRunningByImage(ctx, imageRepos, containerPort any) *gomock.Call

FindRunningByImage indicates an expected call of FindRunningByImage.

func (*MockRuntimeMockRecorder) Flavor added in v0.20.0

func (mr *MockRuntimeMockRecorder) Flavor() *gomock.Call

Flavor indicates an expected call of Flavor.

func (*MockRuntimeMockRecorder) GetBoundPort added in v0.5.2

func (mr *MockRuntimeMockRecorder) GetBoundPort(ctx, containerName, containerPort any) *gomock.Call

GetBoundPort indicates an expected call of GetBoundPort.

func (*MockRuntimeMockRecorder) GetImageVersion added in v0.2.0

func (mr *MockRuntimeMockRecorder) GetImageVersion(ctx, imageName any) *gomock.Call

GetImageVersion indicates an expected call of GetImageVersion.

func (*MockRuntimeMockRecorder) ImageEnv added in v1.4.0

func (mr *MockRuntimeMockRecorder) ImageEnv(ctx, image any) *gomock.Call

ImageEnv indicates an expected call of ImageEnv.

func (*MockRuntimeMockRecorder) ImageExists added in v0.14.0

func (mr *MockRuntimeMockRecorder) ImageExists(ctx, image any) *gomock.Call

ImageExists indicates an expected call of ImageExists.

func (*MockRuntimeMockRecorder) InspectBrief added in v0.20.0

func (mr *MockRuntimeMockRecorder) InspectBrief(ctx, containerName any) *gomock.Call

InspectBrief indicates an expected call of InspectBrief.

func (*MockRuntimeMockRecorder) IsHealthy added in v0.2.0

func (mr *MockRuntimeMockRecorder) IsHealthy(ctx any) *gomock.Call

IsHealthy indicates an expected call of IsHealthy.

func (*MockRuntimeMockRecorder) IsRunning added in v0.2.0

func (mr *MockRuntimeMockRecorder) IsRunning(ctx, containerID any) *gomock.Call

IsRunning indicates an expected call of IsRunning.

func (*MockRuntimeMockRecorder) Logs added in v0.2.0

func (mr *MockRuntimeMockRecorder) Logs(ctx, containerID, tail any) *gomock.Call

Logs indicates an expected call of Logs.

func (*MockRuntimeMockRecorder) PullImage added in v0.2.0

func (mr *MockRuntimeMockRecorder) PullImage(ctx, image, progress any) *gomock.Call

PullImage indicates an expected call of PullImage.

func (*MockRuntimeMockRecorder) Remove added in v0.2.0

func (mr *MockRuntimeMockRecorder) Remove(ctx, containerName any) *gomock.Call

Remove indicates an expected call of Remove.

func (*MockRuntimeMockRecorder) SocketPath added in v0.5.1

func (mr *MockRuntimeMockRecorder) SocketPath() *gomock.Call

SocketPath indicates an expected call of SocketPath.

func (*MockRuntimeMockRecorder) Start added in v0.2.0

func (mr *MockRuntimeMockRecorder) Start(ctx, config any) *gomock.Call

Start indicates an expected call of Start.

func (*MockRuntimeMockRecorder) Stop added in v0.2.0

func (mr *MockRuntimeMockRecorder) Stop(ctx, containerName any) *gomock.Call

Stop indicates an expected call of Stop.

func (*MockRuntimeMockRecorder) StreamLogs added in v0.2.0

func (mr *MockRuntimeMockRecorder) StreamLogs(ctx, containerID, out, follow, tail any) *gomock.Call

StreamLogs indicates an expected call of StreamLogs.

type PortMapping added in v0.5.1

type PortMapping struct {
	ContainerPort string
	HostPort      string
	Protocol      string // "tcp" (default) or "udp"
	// Optional marks a best-effort publication: when the host port is already
	// taken, the mapping is dropped with a warning instead of failing the start.
	// Used for ports lstk adds on its own (e.g. 443 from the default
	// GATEWAY_LISTEN) — ports the user asked for explicitly are never optional.
	Optional bool
}

PortMapping represents a container-to-host port mapping.

type PullProgress

type PullProgress struct {
	LayerID string
	Status  string
	Current int64
	Total   int64
}

type RunningContainer added in v0.6.0

type RunningContainer struct {
	Name      string
	Image     string // full image with tag, e.g. "localstack/localstack-pro:3.5.0"
	BoundPort string // host port bound to the queried container port
}

type Runtime

type Runtime interface {
	IsHealthy(ctx context.Context) error
	EmitUnhealthyError(sink output.Sink, err error)
	PullImage(ctx context.Context, image string, progress chan<- PullProgress) error
	// Start creates and starts the container. The returned channel receives
	// exactly one ExitResult when the container exits. The exit wait is
	// registered between create and start so that even an instantly-exiting
	// container's exit code is observed — with AutoRemove the container is
	// removed the moment it exits, after which a wait can no longer be
	// registered.
	Start(ctx context.Context, config ContainerConfig) (string, <-chan ExitResult, error)
	Stop(ctx context.Context, containerName string) error
	Remove(ctx context.Context, containerName string) error
	IsRunning(ctx context.Context, containerID string) (bool, error)
	// InspectBrief reports whether a container with the given name exists and
	// the facts pre-start checks need about it. A missing container is
	// (ContainerBrief{}, nil), not an error.
	InspectBrief(ctx context.Context, containerName string) (ContainerBrief, error)
	ContainerStartedAt(ctx context.Context, containerName string) (time.Time, error)
	ContainerEnv(ctx context.Context, containerName string) ([]string, error)
	Logs(ctx context.Context, containerID string, tail int) (string, error)
	StreamLogs(ctx context.Context, containerID string, out io.Writer, follow bool, tail string) error
	GetImageVersion(ctx context.Context, imageName string) (string, error)
	// ImageExists reports whether the given image is already present locally.
	ImageExists(ctx context.Context, image string) (bool, error)
	// ImageEnv returns the env of a locally present image. It never pulls.
	ImageEnv(ctx context.Context, image string) ([]string, error)
	// GetBoundPort returns the host port bound to the given container port (e.g. "4566/tcp").
	GetBoundPort(ctx context.Context, containerName string, containerPort string) (string, error)
	FindRunningByImage(ctx context.Context, imageRepos []string, containerPort string) (*RunningContainer, error)
	SocketPath() string
	// Flavor identifies the runtime backing the daemon connection (one of the
	// Flavor* constants, e.g. FlavorRancherDesktop) so callers can tailor
	// user-facing messages. FlavorUnknown (empty) when unrecognized.
	Flavor() string
}

Runtime abstracts container runtime operations (Docker, Podman, Kubernetes, etc.)

func NewExternalRuntime added in v0.21.0

func NewExternalRuntime(containerName string) Runtime

NewExternalRuntime returns a Runtime standing in for an externally-managed emulator, matching the container name of the config.ContainerConfig the caller constructs for it (so container.ResolveRunningContainerName's rt.IsRunning(ctx, c.Name()) check finds it "running"). See externalRuntime.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL