config

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheDir added in v0.16.0

func CacheDir(configPath string) string

CacheDir returns the local cache directory for ssd-generated artifacts (manifests, build metadata, etc.) given the resolved config path.

For .ssd/ssd.yaml -> .ssd/.cache For ssd.yaml (legacy) -> .ssd-cache (avoids cluttering repo root with

an ambiguous ".cache" dir)

Generated artifacts must always live under this directory and never in the repo root or alongside the config files themselves.

func DefaultConfigPath added in v0.16.0

func DefaultConfigPath() (string, error)

DefaultConfigPath returns the first existing ssd config path under the current working directory, preferring .ssd/ssd.yaml over the legacy ssd.yaml. Returns "ssd.yaml" when neither exists so callers get a stable, predictable error message from the subsequent ReadFile.

func EnvConfigPath added in v0.16.0

func EnvConfigPath(basePath, env string) string

EnvConfigPath returns the overlay config path for an environment name, alongside the given base path. For base ".ssd/ssd.yaml" and env "prod" the result is ".ssd/ssd.prod.yaml". Returns "" when env is empty.

func ParseBuildArgRef added in v0.23.0

func ParseBuildArgRef(value string) (kind, key string, ok bool)

ParseBuildArgRef reports whether a build_args value is a reference to a stored value, and to which store ("secret" or "env") and key. Literal values return ok=false.

func ValidateDomain

func ValidateDomain(domain string) error

ValidateDomain validates a domain name for security and correctness

func ValidateEnvFile added in v0.14.0

func ValidateEnvFile(path string) error

ValidateEnvFile validates the env_file field: must be an existing file (not a dir), no path traversal, no shell metacharacters. Empty string is allowed (feature unused). Existence is only checked for relative paths (the file must exist on disk at parse time); for absolute paths we still block traversal but skip the existence check to keep config parsing decoupled from runtime filesystem.

func ValidateFiles added in v0.9.0

func ValidateFiles(files map[string]string) error

ValidateFiles validates the files mapping for security and correctness. Keys are local relative paths, values are absolute container mount paths.

func ValidateHealthCheck

func ValidateHealthCheck(hc *HealthCheck) error

ValidateHealthCheck validates a healthcheck configuration for security and correctness

func ValidateName

func ValidateName(name string) error

ValidateName validates a service name for security and correctness

func ValidatePath added in v0.1.0

func ValidatePath(path string) error

ValidatePath validates a URL path prefix for Traefik routing

func ValidatePortMapping added in v0.8.0

func ValidatePortMapping(mapping string) error

ValidatePortMapping validates a Docker port mapping string (e.g., "3000:3000", "8080:80", "127.0.0.1:9001:9001", "[fd7a::1]:9001:9001").

func ValidateRuntime added in v0.11.0

func ValidateRuntime(runtime string) error

ValidateRuntime validates the runtime field

func ValidateServer

func ValidateServer(server string) error

ValidateServer validates a server hostname/identifier Returns an error if the server name contains shell metacharacters or is invalid

func ValidateStackPath

func ValidateStackPath(path string) error

ValidateStackPath validates a stack path for security and correctness

func ValidateTarget added in v0.1.4

func ValidateTarget(target string) error

ValidateTarget validates a Docker build target stage name

func ValidateVolumeName

func ValidateVolumeName(name string) error

ValidateVolumeName validates a Docker volume name for security and correctness

Types

type CleanupConfig added in v0.15.0

type CleanupConfig struct {
	Retention *int `yaml:"retention,omitempty"`
}

CleanupConfig holds post-deploy image retention options. Retention is a pointer so we can distinguish "unset" (inherit/default 2) from "explicitly 0" (disable auto cleanup).

type Config

type Config struct {
	Name       string            `yaml:"name"`
	Server     string            `yaml:"server"`
	Stack      string            `yaml:"stack"`
	Dockerfile string            `yaml:"dockerfile"`
	Context    string            `yaml:"context"`
	Domain     string            `yaml:"domain"`      // optional, enables Traefik (single domain)
	Domains    []string          `yaml:"domains"`     // optional, multi-domain support
	RedirectTo string            `yaml:"redirect_to"` // optional, domain to redirect all others to (must be in Domains)
	Path       string            `yaml:"path"`        // optional, path prefix for Traefik routing
	HTTPS      *bool             `yaml:"https"`       // default true, pointer for nil check
	Port       int               `yaml:"port"`        // default 80
	Image      string            `yaml:"image"`       // if set, skip build (pre-built)
	Ports      []string          `yaml:"ports"`       // [ip:]host:container port mappings
	Target     string            `yaml:"target"`      // Docker build target stage
	BuildArgs  map[string]string `yaml:"build_args"`  // --build-arg K=V; values may be ${secret:KEY} / ${env:KEY}
	// BuildSecrets are the same shape as BuildArgs but reach the build via
	// BuildKit's --secret (RUN --mount=type=secret), so the value never
	// enters an image layer or the image history.
	BuildSecrets map[string]string `yaml:"build_secrets"`
	Deploy       *DeployConfig     `yaml:"deploy"` // deployment strategy options
	DependsOn    Dependencies      `yaml:"depends_on"`
	Volumes      map[string]string `yaml:"volumes"`  // name: mount_path
	Files        map[string]string `yaml:"files"`    // local_path: container_mount_path
	EnvFile      string            `yaml:"env_file"` // local path to .env file (relative to project root); overwrites {service}.env on deploy
	HealthCheck  *HealthCheck      `yaml:"healthcheck"`
	Cleanup      *CleanupConfig    `yaml:"cleanup"` // post-deploy image tag retention; inherits from root
	// RequireClean aborts the deploy when the build context has uncommitted
	// tracked changes. Pointer so a service can override an inherited true
	// with false. nil (default) warns instead of aborting.
	RequireClean *bool `yaml:"require_clean"`
	// PreDeploy are shell commands run locally in the build context before
	// the sync, in order. Inherits from root when unset.
	PreDeploy []string `yaml:"pre_deploy"`
	// PostDeploy are shell commands run locally in the build context after
	// the service has started/rolled out, in order. Inherits from root when
	// unset. Unlike PreDeploy it also runs for pre-built (image:) services.
	PostDeploy []string `yaml:"post_deploy"`
}

Config represents a single service configuration

func (*Config) AliasDomains added in v0.2.0

func (c *Config) AliasDomains() []string

AliasDomains returns domains that should redirect to the primary domain Returns nil if using single Domain field or if redirect_to is not set When redirect_to is set, returns all domains except redirect_to

func (*Config) CleanRequired added in v0.22.0

func (c *Config) CleanRequired() bool

CleanRequired reports whether a dirty build context must abort the deploy. Defaults to false (warn only) for backwards compatibility.

func (*Config) DeployStrategy added in v0.5.0

func (c *Config) DeployStrategy() string

DeployStrategy returns the deploy strategy for this config

func (*Config) ImageName

func (c *Config) ImageName() string

ImageName returns the Docker image name (without tag)

func (*Config) IsPrebuilt

func (c *Config) IsPrebuilt() bool

IsPrebuilt returns true if this config uses a pre-built image

func (*Config) PrimaryDomain added in v0.2.0

func (c *Config) PrimaryDomain() string

PrimaryDomain returns the primary domain for this config Returns redirect_to if set, otherwise Domain field, otherwise first domain from Domains array Returns empty string if none are set

func (*Config) Replicas added in v0.14.0

func (c *Config) Replicas() int

Replicas returns the number of replicas for this service; 1 when unset.

func (*Config) RetainTags added in v0.15.0

func (c *Config) RetainTags() int

RetainTags returns the number of image tags to keep on the server after a successful deploy. Defaults to 2 (current + rollback target) when unset. 0 disables auto cleanup on deploy.

func (*Config) StackPath

func (c *Config) StackPath() string

StackPath returns the full path to the stack directory on the server This is the directory containing compose.yaml

func (*Config) UseHTTPS

func (c *Config) UseHTTPS() bool

UseHTTPS returns true if HTTPS should be used for this config Returns true when HTTPS is nil (default) or explicitly set to true

type Dependencies added in v0.4.0

type Dependencies []Dependency

Dependencies can be unmarshaled from either a YAML sequence of strings or a YAML mapping with conditions.

func (Dependencies) HasConditions added in v0.4.0

func (d Dependencies) HasConditions() bool

HasConditions returns true if any dependency specifies a condition.

func (Dependencies) Names added in v0.4.0

func (d Dependencies) Names() []string

Names returns the dependency names as a string slice.

func (*Dependencies) UnmarshalYAML added in v0.4.0

func (d *Dependencies) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML handles both list and map forms of depends_on.

type Dependency added in v0.4.0

type Dependency struct {
	Name      string
	Condition string
}

Dependency represents a service dependency with an optional condition.

type DeployConfig added in v0.5.0

type DeployConfig struct {
	Strategy string `yaml:"strategy"`           // "rollout" (default) or "recreate"
	Replicas *int   `yaml:"replicas,omitempty"` // number of replicas (default: 1); nil means unset
}

DeployConfig holds deployment strategy options

type HealthCheck

type HealthCheck struct {
	Cmd      string   `yaml:"cmd,omitempty"`
	Exec     []string `yaml:"exec,omitempty"`
	Interval string   `yaml:"interval"`
	Timeout  string   `yaml:"timeout"`
	Retries  int      `yaml:"retries"`
}

HealthCheck represents Docker healthcheck configuration.

Use Cmd for a shell-evaluated probe (rendered as ["CMD","sh","-c",cmd]). Use Exec for a direct exec probe (rendered as ["CMD",exec...]). Exec is required for scratch and other images that ship no shell. Exactly one of Cmd or Exec must be set.

type Layout added in v0.16.0

type Layout struct {
	HasModern bool // .ssd/ssd.yaml exists
	HasLegacy bool // ./ssd.yaml exists
}

Layout describes which config files exist in the working directory. Used to decide whether to nudge the user toward the modern layout.

func DetectLayout added in v0.16.0

func DetectLayout() Layout

DetectLayout inspects the current working directory and reports which of the two layouts are present.

func (Layout) HasBoth added in v0.16.0

func (l Layout) HasBoth() bool

HasBoth returns true when both files exist — typically the result of a half-finished migration that left the legacy file behind.

func (Layout) IsLegacyOnly added in v0.16.0

func (l Layout) IsLegacyOnly() bool

IsLegacyOnly returns true when the project only has the legacy ssd.yaml at the repo root and has not been migrated yet.

type PortMapping added in v0.25.0

type PortMapping struct {
	HostIP        string
	HostPort      int
	ContainerPort int
}

PortMapping is a parsed Docker port publish spec. HostIP is empty when the mapping binds every host interface.

func ParsePortMapping added in v0.25.0

func ParsePortMapping(mapping string) (PortMapping, error)

ParsePortMapping parses "[host_ip:]host_port:container_port". The host IP must be a literal (IPv6 in brackets): Docker resolves hostnames on the server at container start, so a bad name would only surface as a failed deploy instead of a config error.

type RootConfig

type RootConfig struct {
	Runtime      string             `yaml:"runtime"`
	Server       string             `yaml:"server"`
	Stack        string             `yaml:"stack"`
	Deploy       *DeployConfig      `yaml:"deploy"`
	Cleanup      *CleanupConfig     `yaml:"cleanup"`
	RequireClean *bool              `yaml:"require_clean"`
	PreDeploy    []string           `yaml:"pre_deploy"`
	PostDeploy   []string           `yaml:"post_deploy"`
	Services     map[string]*Config `yaml:"services"`
}

RootConfig represents the ssd.yaml file structure

func Load

func Load(path string) (*RootConfig, error)

Load reads and parses an ssd config from disk.

When path is empty, the loader searches in this order:

  1. .ssd/ssd.yaml (preferred layout, keeps repo root clean)
  2. ssd.yaml (legacy layout, kept for back-compat)

An explicit non-empty path is read verbatim with no fallback.

func LoadFromBytes

func LoadFromBytes(data []byte) (*RootConfig, error)

LoadFromBytes parses raw YAML bytes into RootConfig Does not panic on any input, returns error instead Enables fuzz testing without file system

func Resolve added in v0.16.0

func Resolve(configPath, env string) (*RootConfig, string, error)

Resolve loads the base config (and an optional environment overlay), returning the merged RootConfig and the base path it was loaded from.

configPath: explicit path or "" to auto-detect (see DefaultConfigPath). env: environment name; when set, ".ssd/ssd.<env>.yaml" is deep-merged onto the base. Missing overlay file is an error (explicit env requested but not provided is almost certainly a typo).

func (*RootConfig) GetService

func (r *RootConfig) GetService(serviceName string) (*Config, error)

GetService returns the configuration for a specific service serviceName is required when Services map exists

func (*RootConfig) IsSingleService

func (r *RootConfig) IsSingleService() bool

IsSingleService returns true if this is a single-service config

func (*RootConfig) ListServices

func (r *RootConfig) ListServices() []string

ListServices returns all service names in a multi-service config

Jump to

Keyboard shortcuts

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