Documentation
¶
Index ¶
- Constants
- func ApplyEmulatorType(ctx context.Context, rt runtime.Runtime, sink output.Sink, ...) ([]config.ContainerConfig, error)
- func EmulatorURL(t config.EmulatorType, resolvedHost string) string
- func HandleNoRunningContainer(sink output.Sink, c config.ContainerConfig) error
- func Logs(ctx context.Context, rt runtime.Runtime, sink output.Sink, ...) error
- func NeedsAuthToken(ctx context.Context, rt runtime.Runtime, opts StartOptions) bool
- func RejectImageOfOtherType(sink output.Sink, image string, target config.EmulatorType) error
- func ResolveAndCacheLabel(ctx context.Context, opts StartOptions, resolvedVersion string, ...)
- func ResolveEmulatorLabel(ctx context.Context, client api.PlatformAPI, ...) (string, bool)
- func ResolveRunningContainerName(ctx context.Context, rt runtime.Runtime, c config.ContainerConfig) (string, error)
- func Restart(ctx context.Context, rt runtime.Runtime, sink output.Sink, ...) error
- func RunningEmulators(ctx context.Context, rt runtime.Runtime, containers []config.ContainerConfig) ([]config.ContainerConfig, error)
- func SelectEmulator(ctx context.Context, sink output.Sink, configPath string) ([]config.ContainerConfig, error)
- func Status(ctx context.Context, rt runtime.Runtime, containers []config.ContainerConfig, ...) error
- func StatusExternal(ctx context.Context, target *endpoint.Target, ...) error
- func StatusExternalJSON(ctx context.Context, target *endpoint.Target, ...) error
- func StatusJSON(ctx context.Context, rt runtime.Runtime, containers []config.ContainerConfig, ...) error
- func StillRunningMessage(running []config.ContainerConfig) string
- func Stop(ctx context.Context, rt runtime.Runtime, sink output.Sink, ...) error
- type StartOptions
- type StartResult
- type StopOptions
Constants ¶
const BundledLicenseLabel = "LocalStack"
BundledLicenseLabel replaces the user's plan, which says nothing about a bundled license.
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 EmulatorURL ¶ added in v1.4.0
func EmulatorURL(t config.EmulatorType, resolvedHost string) string
EmulatorURL returns the URL at which an emulator of type t is served, given the host:port from endpoint.ResolveHost. Snowflake and Azure are routed by subdomain, and Azure is served over https. An IP host gets no subdomain, since a subdomain of an IP is not a valid host; the scheme is kept.
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 NeedsAuthToken ¶ added in v1.4.0
NeedsAuthToken reports whether starting opts.Containers needs an auth token: true unless every image is a local bundled-license image.
func RejectImageOfOtherType ¶ added in v1.3.0
RejectImageOfOtherType fails when image is a known image of another emulator type. Unknown images pass.
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 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 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 StatusExternalJSON ¶ added in v0.23.0
func StatusExternalJSON(ctx context.Context, target *endpoint.Target, clients map[config.EmulatorType]emulator.Client, sink output.Sink, includeResources bool) error
StatusExternalJSON is StatusJSON for an --endpoint-url target. Running is always true: endpoint.Resolve already confirmed the target is reachable before returning it.
func StatusJSON ¶ added in v0.23.0
func StatusJSON(ctx context.Context, rt runtime.Runtime, containers []config.ContainerConfig, localStackHost string, clients map[config.EmulatorType]emulator.Client, sink output.Sink, includeResources bool) error
StatusJSON reports each configured emulator's health, one EmulatorStatusEvent per container. Stops at the first not-running emulator, same as Status above, returning EMULATOR_NOT_RUNNING. Resources are only fetched when includeResources is set, since this path is also polled for readiness.
func StillRunningMessage ¶ added in v0.7.0
func StillRunningMessage(running []config.ContainerConfig) string
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
// FirstRun reports that lstk had no config.toml when this run began.
FirstRun bool
// DetectorTips to add to the rotating post-start tips. Might require data that's
// only available at the cmd level.
DetectorTips []tips.Tip
// ImageOverride is the --image value. It is never saved to config. It is applied
// here so it also covers the first-run emulator picker.
ImageOverride string
}
StartOptions groups the user-provided options for starting an emulator.
type StartResult ¶ added in v0.23.0
type StartResult struct {
Type config.EmulatorType
Container string
Endpoint string
Version string
AlreadyRunning bool
Persistence bool
// BundledLicense reports a start from an image with its own license.
BundledLicense bool
}
StartResult is the outcome of a Start call: which emulator ended up running, whether it was already running, and how to reach it.
func Start ¶
func Start(ctx context.Context, rt runtime.Runtime, sink output.Sink, opts StartOptions, interactive bool) (StartResult, error)
Start brings up the configured emulator, recovering from a definitive license rejection with an in-place re-login when interactive. The single post-start tip is emitted here, so a run can only ever show one.
type StopOptions ¶ added in v0.5.2
StopOptions carries optional telemetry context for the stop command.