Documentation
¶
Index ¶
- func CacheDir(configPath string) string
- func DefaultConfigPath() (string, error)
- func EnvConfigPath(basePath, env string) string
- func ParseBuildArgRef(value string) (kind, key string, ok bool)
- func ValidateDomain(domain string) error
- func ValidateEnvFile(path string) error
- func ValidateFiles(files map[string]string) error
- func ValidateHealthCheck(hc *HealthCheck) error
- func ValidateName(name string) error
- func ValidatePath(path string) error
- func ValidatePortMapping(mapping string) error
- func ValidateRuntime(runtime string) error
- func ValidateServer(server string) error
- func ValidateStackPath(path string) error
- func ValidateTarget(target string) error
- func ValidateVolumeName(name string) error
- type CleanupConfig
- type Config
- func (c *Config) AliasDomains() []string
- func (c *Config) CleanRequired() bool
- func (c *Config) DeployStrategy() string
- func (c *Config) ImageName() string
- func (c *Config) IsPrebuilt() bool
- func (c *Config) PrimaryDomain() string
- func (c *Config) Replicas() int
- func (c *Config) RetainTags() int
- func (c *Config) StackPath() string
- func (c *Config) UseHTTPS() bool
- type Dependencies
- type Dependency
- type DeployConfig
- type HealthCheck
- type Layout
- type PortMapping
- type RootConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheDir ¶ added in v0.16.0
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
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
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
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 ¶
ValidateDomain validates a domain name for security and correctness
func ValidateEnvFile ¶ added in v0.14.0
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
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 ¶
ValidateName validates a service name for security and correctness
func ValidatePath ¶ added in v0.1.0
ValidatePath validates a URL path prefix for Traefik routing
func ValidatePortMapping ¶ added in v0.8.0
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
ValidateRuntime validates the runtime field
func ValidateServer ¶
ValidateServer validates a server hostname/identifier Returns an error if the server name contains shell metacharacters or is invalid
func ValidateStackPath ¶
ValidateStackPath validates a stack path for security and correctness
func ValidateTarget ¶ added in v0.1.4
ValidateTarget validates a Docker build target stage name
func ValidateVolumeName ¶
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
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
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
DeployStrategy returns the deploy strategy for this config
func (*Config) IsPrebuilt ¶
IsPrebuilt returns true if this config uses a pre-built image
func (*Config) PrimaryDomain ¶ added in v0.2.0
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
Replicas returns the number of replicas for this service; 1 when unset.
func (*Config) RetainTags ¶ added in v0.15.0
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.
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
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
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
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
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
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:
- .ssd/ssd.yaml (preferred layout, keeps repo root clean)
- 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