config

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 ConfigDir

func ConfigDir() (string, error)

func ConfigFilePath

func ConfigFilePath() (string, error)

func EnsureCreated added in v0.12.0

func EnsureCreated() error

func FriendlyConfigPath added in v0.5.7

func FriendlyConfigPath() (string, error)

FriendlyConfigPath returns a human-readable config path: relative for project-local configs, ~-prefixed for paths under $HOME, absolute otherwise.

func InitFromPath added in v0.3.1

func InitFromPath(path string) error

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

func LicenseFilePath() (string, error)

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

func Load() (firstRun bool, err error)

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

func NormalizeTag(tag string) string

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 Set added in v0.5.2

func Set(key string, value any) error

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 SetUpdateSkippedVersion added in v0.5.8

func SetUpdateSkippedVersion(version string) error

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 {
	UpdateSkippedVersion string `mapstructure:"update_skipped_version"`
}

type Config

type Config struct {
	Containers []ContainerConfig            `mapstructure:"containers"`
	Env        map[string]map[string]string `mapstructure:"env"`
	CLI        CLIConfig                    `mapstructure:"cli"`
}

func Get

func Get() (*Config, error)

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

func (c *ContainerConfig) ResolvedEnv(namedEnvs map[string]map[string]string) ([]string, error)

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:

  1. A Volumes entry targeting persistenceTarget — its resolved host source.
  2. The legacy Volume field, if set — returned as-is.
  3. 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

type PortSpec struct {
	HostPort      string
	ContainerPort string
	Protocol      string // "tcp" or "udp"
}

PortSpec is one parsed expose_ports publication: a host port bound to a container port for a single protocol.

func (PortSpec) String added in v0.22.0

func (p PortSpec) String() string

type VolumeMount added in v0.14.1

type VolumeMount struct {
	Source   string
	Target   string
	ReadOnly bool
}

VolumeMount is a parsed bind specification with the host source resolved to an absolute path.

Jump to

Keyboard shortcuts

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