Documentation
¶
Index ¶
- Constants
- Variables
- func CachePlanLabel(label string)
- func CachedPlanLabel() string
- func ConfigDir() (string, error)
- func ConfigFilePath() (string, error)
- func EnsureCreated() error
- func FriendlyConfigPath() (string, error)
- func HasFile() bool
- func InitFromPath(path string) error
- func KnownImageRepos() []string
- func KnownImageReposForType(t EmulatorType) []string
- func LicenseFilePath() (string, error)
- func Load() (firstRun bool, err error)
- func NormalizeTag(tag string) string
- func ParseCheckForUpdateOnStartup(s string) (bool, error)
- func Set(key string, value any) error
- func SetCheckForUpdateOnStartup(enabled bool) error
- func SetEmulatorType(to EmulatorType) error
- func TagSuggestion() string
- type CLIConfig
- type Config
- type ContainerConfig
- func (c *ContainerConfig) ContainerPort() (string, error)
- func (c *ContainerConfig) DisplayName() string
- func (c *ContainerConfig) ExposedPorts() ([]PortSpec, error)
- func (c *ContainerConfig) ExtraVolumes() ([]VolumeMount, error)
- func (c *ContainerConfig) HealthPath() (string, error)
- func (c *ContainerConfig) Image() (string, error)
- func (c *ContainerConfig) Name() string
- func (c *ContainerConfig) ProductName() (string, error)
- func (c *ContainerConfig) ResolvedEnv(namedEnvs map[string]map[string]string) ([]string, error)
- func (c *ContainerConfig) Validate() error
- func (c *ContainerConfig) VolumeDir() (string, error)
- type EmulatorType
- type PortSpec
- type VolumeMount
Constants ¶
const CheckForUpdateOnStartupDefault = true
CheckForUpdateOnStartupDefault applies when neither the `[cli] check_for_update_on_startup` key nor LSTK_CHECK_FOR_UPDATE_ON_STARTUP is set.
Variables ¶
var SelectableEmulatorTypes = []EmulatorType{EmulatorAWS, EmulatorSnowflake, EmulatorAzure}
SelectableEmulatorTypes lists the emulator types available for interactive selection, in the order they should be presented.
Functions ¶
func CachePlanLabel ¶ added in v0.5.7
func CachePlanLabel(label string)
func CachedPlanLabel ¶ added in v0.5.7
func CachedPlanLabel() string
func ConfigFilePath ¶
func EnsureCreated ¶ added in v0.12.0
func EnsureCreated() error
func FriendlyConfigPath ¶ added in v0.5.7
FriendlyConfigPath returns a human-readable config path: relative for project-local configs, ~-prefixed for paths under $HOME, absolute otherwise.
func HasFile ¶ added in v1.2.0
func HasFile() bool
HasFile reports whether a config file has been resolved, i.e. whether settings can be persisted at all. The command boundary uses it to decide whether to offer options that write config.
func InitFromPath ¶ added in v0.3.1
func KnownImageRepos ¶ added in v0.7.0
func KnownImageRepos() []string
func KnownImageReposForType ¶ added in v0.7.0
func KnownImageReposForType(t EmulatorType) []string
func LicenseFilePath ¶ added in v0.5.8
LicenseFilePath returns the path where the license file is cached on the host. This file is written after a successful license validation and mounted read-only into containers so they can activate offline.
func Load ¶ added in v0.12.0
Load reads config.toml without creating it; callers that need to create the default config on first run should call EnsureCreated once ready to persist it (e.g. after an emulator-selection prompt, or after a successful default start).
func NormalizeTag ¶ added in v0.9.0
NormalizeTag strips a leading zero from the month in calendar-versioned tags so they are accepted by the license API (e.g. "2026.04" → "2026.4"). Other tags pass through unchanged.
func ParseCheckForUpdateOnStartup ¶ added in v1.2.0
ParseCheckForUpdateOnStartup parses the environment variable's raw value. Anything strconv.ParseBool rejects is reported rather than coerced, so a typo cannot silently disable update checks.
func SetCheckForUpdateOnStartup ¶ added in v1.2.0
SetCheckForUpdateOnStartup persists the update-check setting. Unlike Set, it fails when there is no config file rather than succeeding in memory only: it backs the prompt's opt-out, where a dropped write would tell the user their choice was saved and then prompt them again next run.
func SetEmulatorType ¶ added in v0.7.1
func SetEmulatorType(to EmulatorType) error
SetEmulatorType rewrites the emulator type in the config file and reloads. No-op if the requested type is already set.
func TagSuggestion ¶ added in v0.17.0
func TagSuggestion() string
TagSuggestion returns an actionable hint naming a recent calendar tag and "latest", for messages about tags the license server cannot parse.
Types ¶
type CLIConfig ¶ added in v0.5.8
type CLIConfig struct {
// Pointer so an unset key is distinguishable from an explicit false.
CheckForUpdateOnStartup *bool `mapstructure:"check_for_update_on_startup"`
}
type Config ¶
type Config struct {
Containers []ContainerConfig `mapstructure:"containers"`
Env map[string]map[string]string `mapstructure:"env"`
CLI CLIConfig `mapstructure:"cli"`
}
type ContainerConfig ¶
type ContainerConfig struct {
Type EmulatorType `mapstructure:"type"`
Tag string `mapstructure:"tag"`
Port string `mapstructure:"port"`
// CustomImage overrides the default Docker image for this emulator. Set it to use an
// image from an internal registry or a locally loaded offline image instead of pulling
// the default localstack image from Docker Hub. If it carries no tag, Tag (or "latest")
// is appended; if it already carries a tag, Tag is dropped.
CustomImage string `mapstructure:"image"`
// CustomName overrides the derived container name (see Name). It is also exported into
// the container as MAIN_CONTAINER_NAME, which the emulator uses to introspect itself over
// the Docker socket and to name the containers it spawns (e.g. Lambda, as
// <main-container-name>-lambda-<fn>-<id>). Set it when something outside lstk has to
// address the emulator by a fixed name, such as a sidecar proxy on a CI agent.
//
// The key is container_name rather than a bare name because the block already carries an
// image and a type name, against which an unqualified name reads ambiguously; the field is
// CustomName because Name is already a method (the same pairing as CustomImage/Image).
CustomName string `mapstructure:"container_name"`
// Volume is the legacy single-host-directory knob for the persistence mount
// (target /var/lib/localstack). It is still honored; new configs can express the
// same mount as a Volumes entry targeting persistenceTarget instead.
Volume string `mapstructure:"volume"`
// Volumes is the umbrella list of "host:container[:ro]" bind specs. It covers
// arbitrary mounts (e.g. Snowflake init hooks) and may also contain the persistence
// mount (the entry targeting /var/lib/localstack).
Volumes []string `mapstructure:"volumes"`
// ExposePorts publishes additional container ports on the host, beyond the gateway
// and service ports lstk publishes by default — e.g. port 53 so the emulator's DNS
// server can be used as the host's resolver. Each entry is a bare port number
// (published on the same host port) or a Docker-style "[host:]container[/proto]"
// string. See ExposedPorts for the protocol rules.
//
// This replaces the v1 CLI's --host-dns flag; there is deliberately no CLI flag, since
// every consumer of the value is the start path. TOML integers are accepted alongside
// strings (expose_ports = [53, "5354:5353/udp"]) because viper's decoder is
// WeaklyTypedInput.
ExposePorts []string `mapstructure:"expose_ports"`
// Env is a list of named environment references defined in the top-level [env.*] config sections.
Env []string `mapstructure:"env"`
// Snapshot is an optional snapshot REF (e.g. "pod:my-baseline" or a local path)
// auto-loaded after the emulator starts. AWS emulator only. Never written by lstk:
// `snapshot save` does not persist its destination here.
Snapshot string `mapstructure:"snapshot"`
}
func (*ContainerConfig) ContainerPort ¶ added in v0.5.0
func (c *ContainerConfig) ContainerPort() (string, error)
func (*ContainerConfig) DisplayName ¶ added in v0.2.0
func (c *ContainerConfig) DisplayName() string
func (*ContainerConfig) ExposedPorts ¶ added in v0.22.0
func (c *ContainerConfig) ExposedPorts() ([]PortSpec, error)
ExposedPorts returns the publications requested via expose_ports, in config order and de-duplicated. An entry that names no protocol expands to both tcp and udp: the motivating case is the emulator's DNS server (port 53), which serves both, and publishing a protocol nothing listens on is harmless.
func (*ContainerConfig) ExtraVolumes ¶ added in v0.14.1
func (c *ContainerConfig) ExtraVolumes() ([]VolumeMount, error)
ExtraVolumes returns the parsed bind mounts EXCLUDING the persistence entry (target /var/lib/localstack), which start.go mounts separately via VolumeDir.
func (*ContainerConfig) HealthPath ¶
func (c *ContainerConfig) HealthPath() (string, error)
func (*ContainerConfig) Image ¶
func (c *ContainerConfig) Image() (string, error)
func (*ContainerConfig) Name ¶
func (c *ContainerConfig) Name() string
Name returns the container name: CustomName when set, otherwise the derived defaultName.
func (*ContainerConfig) ProductName ¶
func (c *ContainerConfig) ProductName() (string, error)
func (*ContainerConfig) ResolvedEnv ¶ added in v0.3.1
ResolvedEnv resolves the container's named environment references into KEY=value pairs. namedEnvs is the top-level [env.*] map from Config.
func (*ContainerConfig) Validate ¶ added in v0.5.1
func (c *ContainerConfig) Validate() error
func (*ContainerConfig) VolumeDir ¶ added in v0.5.2
func (c *ContainerConfig) VolumeDir() (string, error)
VolumeDir returns the host directory to mount into the container for persistence/caching (the mount targeting /var/lib/localstack). Resolution precedence:
- A Volumes entry targeting persistenceTarget — its resolved host source.
- The legacy Volume field, if set — returned as-is.
- The default os.UserCacheDir()/lstk/volume/<derived container name>.
The default deliberately uses defaultName rather than Name: keying it to the derived name means setting or changing the container's `container_name` never silently orphans existing state, and the default path stays byte-identical to the one already-installed users have. Per-instance state is still expressible explicitly via Volume/Volumes.
type EmulatorType ¶
type EmulatorType string
const ( EmulatorAWS EmulatorType = "aws" EmulatorSnowflake EmulatorType = "snowflake" EmulatorAzure EmulatorType = "azure" DefaultPort = "4566" )
func EmulatorTypeForImage ¶ added in v0.7.0
func EmulatorTypeForImage(image string) EmulatorType
func ParseEmulatorType ¶ added in v0.18.0
func ParseEmulatorType(s string) (EmulatorType, error)
ParseEmulatorType validates a raw emulator type string against the selectable types and returns the corresponding EmulatorType.
func (EmulatorType) DisplayName ¶ added in v0.7.1
func (e EmulatorType) DisplayName() string
func (EmulatorType) SelectionKey ¶ added in v0.7.1
func (e EmulatorType) SelectionKey() string
func (EmulatorType) SelfValidatesLicense ¶ added in v0.11.0
func (e EmulatorType) SelfValidatesLicense() bool
SelfValidatesLicense reports whether the emulator container performs its own license activation on startup. For these emulators lstk skips its pre-flight platform license check (the LocalStack platform API has no catalog entry for them), and lets the container validate the token against the licensing server.
func (EmulatorType) ShortName ¶ added in v0.7.1
func (e EmulatorType) ShortName() string
type PortSpec ¶ added in v0.22.0
PortSpec is one parsed expose_ports publication: a host port bound to a container port for a single protocol.
type VolumeMount ¶ added in v0.14.1
VolumeMount is a parsed bind specification with the host source resolved to an absolute path.