Documentation
¶
Index ¶
- Variables
- func MakeStackKey(context, stack string) string
- func ParseStackKey(key string) (context, stack string, err error)
- func Render(path string) (string, error)
- func RenderWithWarnings(path string) (string, []string, error)
- func RenderWithWarningsAndPath(path string) (string, string, []string, error)
- type Config
- func (c *Config) GetAllFilesets() map[string]FilesetSpec
- func (c *Config) GetAllSopsSecrets() []string
- func (c *Config) GetAllStacks() map[string]Stack
- func (c *Config) GetFilesetsForContext(contextName string) map[string]FilesetSpec
- func (c *Config) GetFirstContext() string
- func (c *Config) GetStacksForContext(contextName string) map[string]Stack
- type ContextConfig
- type DeploymentConfig
- type DiscoveryConfig
- type Environment
- type FilesetSpec
- type NetworkSpec
- type Ownership
- type Project
- type RestartTargets
- type Secrets
- type SopsAgeConfig
- type SopsConfig
- type SopsPgpConfig
- type Stack
- type TopLevelResourceSpec
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingRequired indicates a required field or value is missing. ErrMissingRequired = errors.New("missing required field") // ErrInvalidValue indicates a field has an invalid value. ErrInvalidValue = errors.New("invalid value") )
Functions ¶
func MakeStackKey ¶ added in v0.9.0
MakeStackKey creates a "context/stack" key from components.
func ParseStackKey ¶ added in v0.9.0
ParseStackKey splits a "context/stack" key into its components.
func Render ¶
Render reads the manifest file at the provided path (or discovers it like Load) and returns the YAML content with ${VAR} placeholders interpolated from the current environment. Missing variables are replaced with empty strings and a warning is emitted to stderr.
func RenderWithWarnings ¶
RenderWithWarnings reads the manifest file and returns interpolated YAML and the list of missing env var names.
Types ¶
type Config ¶
type Config struct {
// Project-wide identifier for resource labeling (io.dockform.identifier)
Identifier string `yaml:"identifier" validate:"required"`
// Global settings
Sops *SopsConfig `yaml:"sops"`
Discovery DiscoveryConfig `yaml:"discovery"`
// Multi-context support (maps context name to config)
Contexts map[string]ContextConfig `yaml:"contexts" validate:"required"`
Deployments map[string]DeploymentConfig `yaml:"deployments"`
// Explicit overrides (optional - discovery finds most of this automatically)
// Stack keys are in "context/stack" format (e.g., "hetzner-one/traefik")
Stacks map[string]Stack `yaml:"stacks" validate:"dive"`
// Computed
BaseDir string `yaml:"-"`
Targeted bool `yaml:"-"` // True when config was filtered by --stack/--context/--deployment
// Discovered resources (populated by convention discovery)
DiscoveredStacks map[string]Stack `yaml:"-"` // context/stack -> Stack
DiscoveredFilesets map[string]FilesetSpec `yaml:"-"` // context/stack/fileset -> FilesetSpec
}
Config is the root desired-state structure parsed from YAML. This is the new multi-context schema with convention-over-configuration support.
func Load ¶
Load reads and validates configuration from the provided path. When path is empty, it searches for manifest files in this order in the current working directory: dockform.yml, dockform.yaml, Dockform.yml, Dockform.yaml
func LoadWithWarnings ¶
LoadWithWarnings reads and validates configuration and returns missing env var names instead of printing.
func (*Config) GetAllFilesets ¶ added in v0.9.0
func (c *Config) GetAllFilesets() map[string]FilesetSpec
GetAllFilesets returns all filesets (discovered).
func (*Config) GetAllSopsSecrets ¶ added in v0.9.0
GetAllSopsSecrets collects all unique SOPS secret file paths from all stacks.
func (*Config) GetAllStacks ¶ added in v0.9.0
GetAllStacks returns all stacks (discovered + explicit merged). Discovery is preferred; explicit stacks can augment or provide fallback.
func (*Config) GetFilesetsForContext ¶ added in v0.9.0
func (c *Config) GetFilesetsForContext(contextName string) map[string]FilesetSpec
GetFilesetsForContext returns all filesets belonging to a specific context.
func (*Config) GetFirstContext ¶ added in v0.9.0
GetFirstContext returns the name of the first context in the config, or "default" if none. Used for backward compatibility with deprecated single-context APIs.
type ContextConfig ¶ added in v0.9.0
type ContextConfig struct {
Host string `yaml:"host"` // Optional Docker host override (e.g., ssh://user@host); when set, uses DOCKER_HOST instead of DOCKER_CONTEXT
Volumes map[string]TopLevelResourceSpec `yaml:"volumes"` // Explicit volumes to create
Networks map[string]NetworkSpec `yaml:"networks"` // Explicit networks to create
}
ContextConfig defines a Docker context to manage. The key in the Contexts map IS the docker context name.
type DeploymentConfig ¶ added in v0.9.0
type DeploymentConfig struct {
Description string `yaml:"description"`
Contexts []string `yaml:"contexts"` // Target all stacks in these contexts
Stacks []string `yaml:"stacks"` // Target specific stacks (context/stack format)
}
DeploymentConfig defines a named deployment group for targeting multiple contexts/stacks.
type DiscoveryConfig ¶ added in v0.9.0
type DiscoveryConfig struct {
ComposeFiles []string `yaml:"compose_files"` // Default: [compose.yaml, compose.yml, docker-compose.yaml, docker-compose.yml]
SecretsFile string `yaml:"secrets_file"` // Default: secrets.env
EnvironmentFile string `yaml:"environment_file"` // Default: environment.env
VolumesDir string `yaml:"volumes_dir"` // Default: volumes
}
DiscoveryConfig controls automatic resource discovery behavior. Discovery is always enabled; use explicit stacks: block to override discovered values.
func (DiscoveryConfig) GetComposeFiles ¶ added in v0.9.0
func (d DiscoveryConfig) GetComposeFiles() []string
GetComposeFiles returns the compose file patterns to search for.
func (DiscoveryConfig) GetEnvironmentFile ¶ added in v0.9.0
func (d DiscoveryConfig) GetEnvironmentFile() string
GetEnvironmentFile returns the environment file name to look for.
func (DiscoveryConfig) GetSecretsFile ¶ added in v0.9.0
func (d DiscoveryConfig) GetSecretsFile() string
GetSecretsFile returns the secrets file name to look for.
func (DiscoveryConfig) GetVolumesDir ¶ added in v0.9.0
func (d DiscoveryConfig) GetVolumesDir() string
GetVolumesDir returns the volumes directory name to look for.
type Environment ¶
Environment holds environment file references and inline variables.
type FilesetSpec ¶
type FilesetSpec struct {
Source string `yaml:"source"`
TargetVolume string `yaml:"target_volume"`
TargetPath string `yaml:"target_path"`
RestartServices RestartTargets `yaml:"restart_services"`
ApplyMode string `yaml:"apply_mode"`
Exclude []string `yaml:"exclude"`
Ownership *Ownership `yaml:"ownership"`
// Computed fields
SourceAbs string `yaml:"-"`
Context string `yaml:"-"` // Which context this belongs to
Stack string `yaml:"-"` // Which stack this belongs to (for restart discovery)
}
FilesetSpec defines a local directory to sync into a Docker volume at a target path.
type NetworkSpec ¶ added in v0.3.0
type NetworkSpec struct {
Driver string `yaml:"driver"`
Options map[string]string `yaml:"options"`
Internal bool `yaml:"internal"`
Attachable bool `yaml:"attachable"`
IPv6 bool `yaml:"ipv6"`
Subnet string `yaml:"subnet"`
Gateway string `yaml:"gateway"`
IPRange string `yaml:"ip_range"`
AuxAddresses map[string]string `yaml:"aux_addresses"`
}
NetworkSpec allows configuring Docker network driver and options.
type Ownership ¶ added in v0.6.0
type Ownership struct {
User string `yaml:"user"` // numeric UID string preferred; allow names
Group string `yaml:"group"` // numeric GID string preferred; allow names
FileMode string `yaml:"file_mode"` // octal string "0644" or "644"
DirMode string `yaml:"dir_mode"` // octal string "0755" or "755"
PreserveExisting bool `yaml:"preserve_existing"` // if true, only apply to new/updated paths
}
Ownership defines optional ownership and permission settings for fileset files.
type Project ¶
type Project struct {
Name string `yaml:"name"`
}
Project allows overriding the Compose project name.
type RestartTargets ¶ added in v0.4.0
RestartTargets represents either an explicit list of services to restart, or the sentinel value "attached" which means: discover services that mount the fileset's target_volume.
func (*RestartTargets) UnmarshalYAML ¶ added in v0.4.0
func (r *RestartTargets) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML supports either a string (must be "attached") or a list of strings. If omitted or null, it results in no restarts.
type Secrets ¶
type Secrets struct {
Sops []string `yaml:"sops"`
}
Secrets holds secret sources (SOPS-encrypted files).
type SopsAgeConfig ¶
type SopsAgeConfig struct {
KeyFile string `yaml:"key_file"`
Recipients []string `yaml:"recipients"`
}
SopsAgeConfig configures the Age backend for SOPS.
type SopsConfig ¶
type SopsConfig struct {
Age *SopsAgeConfig `yaml:"age"`
// Recipients is deprecated; kept for migration error messaging
Recipients []string `yaml:"recipients"`
Pgp *SopsPgpConfig `yaml:"pgp"`
}
SopsConfig configures SOPS provider(s) for secret decryption.
type SopsPgpConfig ¶ added in v0.5.0
type SopsPgpConfig struct {
KeyringDir string `yaml:"keyring_dir"`
UseAgent bool `yaml:"use_agent"`
PinentryMode string `yaml:"pinentry_mode"`
Recipients []string `yaml:"recipients"`
Passphrase string `yaml:"passphrase"`
}
SopsPgpConfig configures the PGP (GnuPG) backend for SOPS.
type Stack ¶ added in v0.6.0
type Stack struct {
// Core fields (set by discovery, can be overridden explicitly for non-standard setups)
Root string `yaml:"root"` // Stack directory (usually set by discovery)
Files []string `yaml:"files"` // Compose files (usually set by discovery)
EnvFile []string `yaml:"env-file"` // Env files
// Override fields (typically set in stacks: block to augment discovered stacks)
Profiles []string `yaml:"profiles"` // Compose profiles to activate
Environment *Environment `yaml:"environment"` // Additional environment config
Secrets *Secrets `yaml:"secrets"` // Additional SOPS secrets
Project *Project `yaml:"project"` // Compose project name override
Filesets map[string]FilesetSpec `yaml:"filesets"` // Fileset overrides/declarations
// Computed fields
Context string `yaml:"-"` // Which context this belongs to (from key prefix)
EnvInline []string `yaml:"-"` // Merged inline env vars
SopsSecrets []string `yaml:"-"` // Merged SOPS secret paths
RootAbs string `yaml:"-"` // Absolute path to stack root
}
Stack defines a Docker Compose stack to manage. Stacks are discovered automatically from context directories. The stacks: block can augment discovered stacks or define explicit stacks.
type TopLevelResourceSpec ¶
type TopLevelResourceSpec struct{}
TopLevelResourceSpec is an empty marker for explicitly declared volumes.