container

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const NoLicenseLabel = "LocalStack (No license)"

Variables

This section is empty.

Functions

func ApplyEmulatorType added in v0.18.0

func ApplyEmulatorType(ctx context.Context, rt runtime.Runtime, sink output.Sink, requested config.EmulatorType, containers []config.ContainerConfig, firstRun bool, configPath string) ([]config.ContainerConfig, error)

ApplyEmulatorType applies a non-interactive emulator selection (the --type flag) to the config before start, returning the resulting containers.

It is the scripted counterpart to the interactive picker (SelectEmulator):

  • First run (no config file yet): create the config and record the requested type, reusing the same path the picker writes.
  • Config already matches: no-op.
  • Config differs: switch the type in place via the surgical type-line rewrite (comments/formatting preserved), keeping the other block fields. A custom image is a hard error — it pins a specific product that cannot be reinterpreted under a different emulator type. A non-default tag or any volume mounts are kept with a warning, since they are often product-specific.

Messages are emitted through sink; configPath is the friendly config path used in those messages so a switch against a checked-in file is visible.

Before writing anything, it checks whether a different emulator type is already running on the port the requested type would use: rewriting the config to a type that is doomed to fail the port-conflict check in selectContainersToStart would leave the config pointing at an emulator that isn't running while the one that IS running becomes invisible to `status`, `stop`, and `logs` (which resolve from the configured type). The check degrades gracefully (like the offline/enterprise paths in start.go) when the runtime can't be queried, so an unreachable Docker daemon here doesn't block a switch — the real connectivity problem still surfaces later, from the start attempt itself.

func HandleNoRunningContainer added in v0.18.0

func HandleNoRunningContainer(sink output.Sink, c config.ContainerConfig) error

HandleNoRunningContainer emits the standard "not running" error for c through sink (naming it and pointing the user at how to start it), then returns a silent error for the caller to propagate. Callers that already resolved ResolveRunningContainerName to "" should use this instead of duplicating the ErrorEvent/Actions boilerplate.

func Logs

func Logs(ctx context.Context, rt runtime.Runtime, sink output.Sink, containers []config.ContainerConfig, follow bool, tail string, verbose bool) error

func ResolveAndCacheLabel added in v0.7.1

func ResolveAndCacheLabel(ctx context.Context, opts StartOptions, resolvedVersion string, labelCh chan<- string)

ResolveAndCacheLabel resolves the plan label using the version returned by Start and caches it for subsequent runs. resolvedVersion is the version extracted from image inspection; it may be empty if Start returned early (e.g. already running).

func ResolveEmulatorLabel added in v0.5.7

func ResolveEmulatorLabel(ctx context.Context, client api.PlatformAPI, containers []config.ContainerConfig, token, resolvedVersion string, logger log.Logger) (string, bool)

ResolveEmulatorLabel tries to fetch the plan name from the license API to build a label like "LocalStack Ultimate". Falls back to NoLicenseLabel when the plan cannot be determined. The returned bool is true only when a real plan was resolved (i.e. the result is worth caching). resolvedVersion is the version from post-pull image inspection for "latest" containers.

func ResolveRunningContainerName added in v0.7.1

func ResolveRunningContainerName(ctx context.Context, rt runtime.Runtime, c config.ContainerConfig) (string, error)

func Restart added in v0.5.8

func Restart(ctx context.Context, rt runtime.Runtime, sink output.Sink, stopOpts StopOptions, startOpts StartOptions, interactive bool) error

func RunningEmulators added in v0.7.0

func RunningEmulators(ctx context.Context, rt runtime.Runtime, containers []config.ContainerConfig) ([]config.ContainerConfig, error)

func SelectEmulator added in v0.7.1

func SelectEmulator(
	ctx context.Context,
	sink output.Sink,
	configPath string,
) ([]config.ContainerConfig, error)

func Start

func Start(ctx context.Context, rt runtime.Runtime, sink output.Sink, opts StartOptions, interactive bool) (string, error)

func Status added in v0.5.0

func Status(ctx context.Context, rt runtime.Runtime, containers []config.ContainerConfig, localStackHost string, clients map[config.EmulatorType]emulator.Client, sink output.Sink) error

func StatusExternal added in v0.21.0

func StatusExternal(ctx context.Context, target *endpoint.Target, clients map[config.EmulatorType]emulator.Client, sink output.Sink) error

StatusExternal renders status for an externally-managed endpoint (--endpoint-url/LSTK_ENDPOINT_URL/AWS_ENDPOINT_URL): reachability, detected type, reported version, and — for an AWS-typed target — deployed resources, without the Docker-derived facts (container name, uptime, persistence, bound port) that don't exist for an emulator lstk didn't start. Deployed resources are not Docker-derived (they're an ordinary emulator API call via FetchResources, identical to Status above), so there's no reason to omit them here. It emits the same events in the same order as Status, so both paths render identically through whichever sink the caller picked.

func StillRunningMessage added in v0.7.0

func StillRunningMessage(running []config.ContainerConfig) string

func Stop

func Stop(ctx context.Context, rt runtime.Runtime, sink output.Sink, containers []config.ContainerConfig, opts StopOptions) error

Types

type StartOptions added in v0.4.0

type StartOptions struct {
	PlatformClient   api.PlatformAPI
	AuthToken        string
	ForceFileKeyring bool
	WebAppURL        string
	LocalStackHost   string
	Containers       []config.ContainerConfig
	Env              map[string]map[string]string
	Persist          bool
	StartupTimeout   time.Duration // zero uses the per-mode default (resolveStartupTimeout)
	Logger           log.Logger
	Telemetry        *telemetry.Client
	// AuthOptions is passed through to auth.New; tests use it to inject a fake
	// browser opener so a re-login flow never opens a real tab.
	AuthOptions []auth.Option
}

StartOptions groups the user-provided options for starting an emulator.

type StopOptions added in v0.5.2

type StopOptions struct {
	Telemetry *telemetry.Client
}

StopOptions carries optional telemetry context for the stop command.

Jump to

Keyboard shortcuts

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