Documentation
¶
Index ¶
- Constants
- func AliasLineNumbers(configPath string) map[string]int
- func SaveAppState(appName string, state *AppState) error
- type AddonConfig
- type AppConfig
- type AppEnvVar
- type AppState
- type BuildConfig
- type ConfigError
- type Diagnostic
- type DiskConfig
- type PortConfig
- type ServiceConcurrencyConfig
- type ServiceConfig
- type ValidationError
Constants ¶
const AppConfigPath = ".miren/app.toml"
Variables ¶
This section is empty.
Functions ¶
func AliasLineNumbers ¶ added in v0.7.0
AliasLineNumbers parses the TOML file at configPath and returns a map from alias name to the line number where it is defined. Uses the go-toml/v2 AST parser for accurate source locations.
func SaveAppState ¶ added in v0.4.0
SaveAppState writes the cluster state for the named app. Uses a file lock to make the read-modify-write atomic across processes.
Types ¶
type AddonConfig ¶ added in v0.4.0
AddonConfig represents configuration for an addon in app.toml.
type AppConfig ¶
type AppConfig struct {
Name string `toml:"name"`
PostImport string `toml:"post_import,omitempty"`
EnvVars []AppEnvVar `toml:"env,omitempty"`
Concurrency *int `toml:"concurrency,omitempty"`
Services map[string]*ServiceConfig `toml:"services,omitempty"`
Build *BuildConfig `toml:"build,omitempty"`
Include []string `toml:"include,omitempty"`
Addons map[string]*AddonConfig `toml:"addons,omitempty"`
Aliases map[string]string `toml:"aliases,omitempty"`
}
func GetDefaultsForServices ¶
GetDefaultsForServices returns an AppConfig with defaults resolved for given service names. This is useful for migration - it provides the same defaults used at build time.
func LoadAppConfig ¶
func LoadAppConfigUnder ¶
func LoadAppConfigWithPath ¶ added in v0.7.0
LoadAppConfigWithPath loads the app config and returns the file path it was loaded from. Returns (nil, "", nil) if no config file is found.
func (*AppConfig) ResolveDefaults ¶
ResolveDefaults populates Services map for all service names with fully-resolved defaults. If a service already has explicit config in app.toml, it is preserved. Otherwise, defaults are applied based on service name:
- "web": auto mode, requests_per_instance=10, scale_down_delay=15m
- others: fixed mode, num_instances=1
type AppEnvVar ¶
type AppEnvVar struct {
Key string `json:"key" toml:"key"`
Value string `json:"value,omitempty" toml:"value,omitempty"`
Required bool `json:"required,omitempty" toml:"required,omitempty"`
Sensitive bool `json:"sensitive,omitempty" toml:"sensitive,omitempty"`
Description string `json:"description,omitempty" toml:"description,omitempty"`
}
type AppState ¶ added in v0.4.0
type AppState struct {
Cluster string `toml:"cluster"`
}
func LoadAppState ¶ added in v0.4.0
LoadAppState reads the cluster state for the named app. Returns nil, nil if no state has been saved for this app.
type BuildConfig ¶
type ConfigError ¶ added in v0.7.0
type ConfigError struct {
FilePath string
Diagnostics []Diagnostic
}
ConfigError is returned from config loading when the TOML file has problems. It renders compiler-style diagnostics with file:line references.
func (*ConfigError) Error ¶ added in v0.7.0
func (e *ConfigError) Error() string
func (*ConfigError) WriteForTerminal ¶ added in v0.7.0
func (e *ConfigError) WriteForTerminal(w io.Writer)
WriteForTerminal renders a colorized, multi-line diagnostic to w. Implements ui.TerminalError.
Styling goes through pkg/theme rather than raw ANSI attributes so the output stays readable on light backgrounds. The source context in particular used to use the terminal's dim attribute, which disappears entirely on some light themes — exactly the failure theme's Muted role exists to avoid.
type Diagnostic ¶ added in v0.7.0
type Diagnostic struct {
Line int // 1-indexed, 0 if unknown
Column int // 1-indexed, 0 if unknown
Message string // the core error message
Context string // visual context from go-toml (if available)
Hint string // e.g. "did you mean \"command\"?"
}
Diagnostic represents a single error within a config file.
type DiskConfig ¶
type DiskConfig struct {
Name string `toml:"name"`
Provider string `toml:"provider"`
MountPath string `toml:"mount_path"`
ReadOnly bool `toml:"read_only"`
SizeGB int `toml:"size_gb"`
Filesystem string `toml:"filesystem"`
LeaseTimeout string `toml:"lease_timeout"`
Owner string `toml:"owner"`
}
DiskConfig represents a disk attachment for a service. Provider defaults to "miren" (network disk) when empty. Use provider = "local" for node-local persistent storage.
type PortConfig ¶ added in v0.5.0
type PortConfig struct {
Port int `toml:"port"`
Name string `toml:"name"`
Type string `toml:"type"`
NodePort int `toml:"node_port"`
}
PortConfig represents a network port for a service
type ServiceConcurrencyConfig ¶
type ServiceConcurrencyConfig struct {
Mode string `toml:"mode"` // "auto" or "fixed"
RequestsPerInstance int `toml:"requests_per_instance"`
ScaleDownDelay string `toml:"scale_down_delay"` // e.g. "2m", "15m"
NumInstances int `toml:"num_instances"`
ShutdownTimeout string `toml:"shutdown_timeout"` // e.g. "10s", "30s" - time to wait for graceful shutdown
}
ServiceConcurrencyConfig represents per-service concurrency configuration
type ServiceConfig ¶
type ServiceConfig struct {
Command string `toml:"command"`
Port int `toml:"port"`
PortName string `toml:"port_name"`
PortType string `toml:"port_type"`
Ports []PortConfig `toml:"ports"`
Image string `toml:"image"`
EnvVars []AppEnvVar `toml:"env"`
Concurrency *ServiceConcurrencyConfig `toml:"concurrency"`
Disks []DiskConfig `toml:"disks"`
// PortTimeout overrides the default 15s wait for the service to bind
// its port during startup. Accepts a Go duration string (e.g. "60s", "2m").
// Empty falls back to the default; invalid duration strings are rejected
// at parse time by Validate.
PortTimeout string `toml:"port_timeout,omitempty"`
}
ServiceConfig represents configuration for a specific service
type ValidationError ¶ added in v0.7.0
type ValidationError struct {
KeyPath string // e.g. "services.web.concurrency.mode"
Message string
}
ValidationError is a structured error from Validate() that carries the TOML key path for AST-based line number resolution.
func (*ValidationError) Error ¶ added in v0.7.0
func (e *ValidationError) Error() string