Documentation
¶
Index ¶
- Constants
- func AliasLineNumbers(configPath string) map[string]int
- func RemoveDeployConfigUnder(dir string) error
- func SaveAppState(appName string, state *AppState) error
- func SaveDeployConfigUnder(dir string, dc *DeployConfig) error
- type AddonConfig
- type AppConfig
- type AppEnvVar
- type AppState
- type BuildConfig
- type BuildSecret
- type ConfigError
- type DeployConfig
- func (dc *DeployConfig) AddTarget(target DeployTarget, makeDefault bool) error
- func (dc *DeployConfig) RemoveTarget(name string) error
- func (dc *DeployConfig) SetDefaultTarget(name string) error
- func (dc *DeployConfig) Target(name string) (*DeployTarget, error)
- func (dc *DeployConfig) Validate() error
- type DeployTarget
- type Diagnostic
- type DiskConfig
- type PortConfig
- type ServiceConcurrencyConfig
- type ServiceConfig
- type ServiceMetricsConfig
- type StaticConfig
- type TaskConfig
- type ValidationError
Constants ¶
const ( DiskProviderMiren = "miren" DiskProviderLocal = "local" )
Disk providers accepted in app.toml.
const ( DefaultMetricsPath = "/metrics" DefaultMetricsInterval = "30s" MinimumMetricsInterval = 30 * time.Second )
const ( TriggerManual = "manual" TriggerDeploy = "deploy" TriggerSchedule = "schedule" )
Task trigger values. A task's trigger says what starts it; the default is TriggerManual, meaning it runs only when someone asks.
const AppConfigPath = ".miren/app.toml"
const ConsoleMaxConcurrent = 10
ConsoleMaxConcurrent caps simultaneous console runs when the app has not declared [tasks.console].
The conservative default is wrong here. `miren app run` had no limit at all before tasks absorbed it, and most apps will never declare the task, so falling back to 1 would silently make the second person to open a console wait behind the first -- a new restriction on an existing command rather than a bound on new functionality. Set well past what anyone reaches by hand; an app that wants a different number can declare the task and say so.
const ConsoleName = "console"
ConsoleName is the task `miren app run` resolves when none is named. The convention predates tasks -- the exec server already looked for a service with this name -- so it is shared rather than spelled out in both places.
const DefaultSqliteDbFile = "data.db"
DefaultSqliteDbFile is the database name used when a sqlite disk does not set db_file.
const DefaultSqliteId = "default"
DefaultSqliteId is the database identity used when a sqlite disk does not set id.
const DefaultTaskMaxConcurrent = 1
DefaultTaskMaxConcurrent caps simultaneous runs of a task. Runs consume cluster capacity on request, so the default is the conservative one.
const DeployConfigPath = ".miren/deploy.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 RemoveDeployConfigUnder ¶ added in v0.16.0
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.
func SaveDeployConfigUnder ¶ added in v0.16.0
func SaveDeployConfigUnder(dir string, dc *DeployConfig) error
Types ¶
type AddonConfig ¶ added in v0.4.0
type AddonConfig struct {
Variant string `toml:"variant"`
Version string `toml:"version"`
// Services names the services an addon's storage attaches to. Empty means
// every service, matching how addon variables reach every service.
//
// It exists because storage an addon supplies can carry constraints that
// the rest of the app should not have to inherit. A SQLite database allows
// one writer, so a service holding it must run a single fixed instance;
// without this an app could not also run a worker at three.
Services []string `toml:"services"`
}
AddonConfig represents configuration for an addon in app.toml.
type AppConfig ¶
type AppConfig struct {
Name string `toml:"name"`
Static *StaticConfig `toml:"static,omitempty"`
EnvVars []AppEnvVar `toml:"env,omitempty"`
Concurrency *int `toml:"concurrency,omitempty"`
Services map[string]*ServiceConfig `toml:"services,omitempty"`
Tasks map[string]*TaskConfig `toml:"tasks,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"`
WorkloadRole string `toml:"workload_role,omitempty"`
// Web says whether the app has a long-running web process. It is a pointer
// because `false` is the zero value and "unset" has to stay distinguishable
// from "explicitly false": unset preserves the historical behavior of
// synthesizing a web service from the image entrypoint, while `web = false`
// is how a task-only app opts out.
Web *bool `toml:"web,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. The path is also returned alongside a parse error, so a caller can tell which file was at fault. 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
func (*AppConfig) StaticDirectory ¶ added in v0.16.0
StaticDirectory returns the configured static output directory, if any.
func (*AppConfig) Validate ¶
Validate checks that the AppConfig has valid values. Returns *ValidationError with a key path for AST-based line resolution.
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"`
// Backend names the secret backend the value comes from, and Ref addresses
// the secret within it. Together they replace Value: the credential itself
// never appears in app.toml, only a pointer to it, so the file stays safe to
// commit.
//
// A reference authored here floats: each new ConfigVersion resolves it to
// whatever is current, which is how a rotation reaches the app. Note that
// this is about minting a config, not running one — deploying or rolling
// back to an existing version keeps the reference that version recorded, so
// a rotation reaches an app only once a new config is created for it.
// Appending @version to Ref holds it at that exact version regardless.
Backend string `json:"backend,omitempty" toml:"backend,omitempty"`
Ref string `json:"ref,omitempty" toml:"ref,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 BuildConfig struct {
Dockerfile string `toml:"dockerfile"`
OnBuild []string `toml:"onbuild"`
Version string `toml:"version"`
AlpineImage string `toml:"alpine_image"`
// Secrets names secret backends to expose to the build. Each entry is mounted
// into the build via BuildKit's secret session, so a `RUN --mount=type=secret,id=<id>`
// step can read the decrypted value without it ever landing in an image layer
// or build log. This is distinct from a runtime [[env]] reference: a build
// secret reaches only the build and never becomes an environment variable in
// the running container.
Secrets []BuildSecret `toml:"secrets,omitempty"`
}
type BuildSecret ¶ added in v0.14.0
type BuildSecret struct {
ID string `json:"id" toml:"id"`
Backend string `json:"backend,omitempty" toml:"backend,omitempty"`
Ref string `json:"ref" toml:"ref"`
}
BuildSecret exposes a secret to the build. ID is the mount identifier a Dockerfile references with `--mount=type=secret,id=<id>`; Backend and Ref address the secret the same way a runtime [[env]] reference does. Backend is optional and defaults to the built-in "cluster" store when omitted, matching the `--backend` CLI flag.
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 DeployConfig ¶ added in v0.16.0
type DeployConfig struct {
Targets []DeployTarget `toml:"targets"`
}
func LoadDeployConfigUnder ¶ added in v0.16.0
func LoadDeployConfigUnder(dir string) (*DeployConfig, error)
func (*DeployConfig) AddTarget ¶ added in v0.16.0
func (dc *DeployConfig) AddTarget(target DeployTarget, makeDefault bool) error
func (*DeployConfig) RemoveTarget ¶ added in v0.16.0
func (dc *DeployConfig) RemoveTarget(name string) error
func (*DeployConfig) SetDefaultTarget ¶ added in v0.16.0
func (dc *DeployConfig) SetDefaultTarget(name string) error
func (*DeployConfig) Target ¶ added in v0.16.0
func (dc *DeployConfig) Target(name string) (*DeployTarget, error)
Target resolves a named target, or the first target when name is empty.
func (*DeployConfig) Validate ¶ added in v0.16.0
func (dc *DeployConfig) Validate() error
type DeployTarget ¶ added in v0.16.0
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.
A SQLite database is not declared here. It comes from the miren-sqlite addon, which attaches its own storage; see docs/docs/addons.md.
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"`
Args []string `toml:"args"`
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"`
Metrics *ServiceMetricsConfig `toml:"metrics,omitempty"`
// 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 ServiceMetricsConfig ¶ added in v0.15.0
type ServiceMetricsConfig struct {
Enabled bool `toml:"enabled"`
Path string `toml:"path"`
Port int `toml:"port"`
Interval string `toml:"interval"`
Public bool `toml:"public"`
}
ServiceMetricsConfig describes an application's Prometheus-compatible scrape endpoint. Metrics are opt-in. When enabled, the runtime resolves Path, Port, and Interval before persisting the service configuration in a ConfigVersion.
type StaticConfig ¶ added in v0.16.0
type StaticConfig struct {
Dir string `toml:"dir"`
}
StaticConfig selects build output that HTTP ingress serves directly.
type TaskConfig ¶ added in v0.14.0
type TaskConfig struct {
// Command is the default command. An invoke can override it, which is what
// makes a manually-triggered task useful for ad-hoc work.
Command string `json:"command" toml:"command"`
// Trigger is one of "manual", "deploy", or "schedule". Empty means manual.
Trigger string `json:"trigger,omitempty" toml:"trigger,omitempty"`
// Every is a Go duration and is pure sugar over Schedule: it is desugared
// to a day-aligned calendar expression at parse time, so only the calendar
// form is ever stored. Mutually exclusive with Schedule.
Every string `json:"every,omitempty" toml:"every,omitempty"`
// Schedule is a systemd OnCalendar expression. Mutually exclusive with Every.
Schedule string `json:"schedule,omitempty" toml:"schedule,omitempty"`
// Timeout bounds the run, after which the sandbox is killed and the run is
// marked TIMED_OUT. Empty means the platform default.
Timeout string `json:"timeout,omitempty" toml:"timeout,omitempty"`
// Retries applies to the deploy and schedule triggers, where nobody is
// watching to retry by hand. A manually-triggered run that fails just
// fails, and the caller decides.
Retries int `json:"retries,omitempty" toml:"retries,omitempty"`
// MaxConcurrent caps simultaneous runs. Zero means DefaultTaskMaxConcurrent.
MaxConcurrent int `json:"max_concurrent,omitempty" toml:"max_concurrent,omitempty"`
EnvVars []AppEnvVar `json:"env,omitempty" toml:"env,omitempty"`
}
TaskConfig represents a command the app knows how to run: what to run, what starts it, and how it ends.
A task deliberately has no ports, concurrency, image, or disks. Those are absent from the schema rather than present-and-rejected, so the grammar never admits a configuration the validator has to refuse. Per-task image and disks are v1 cuts tracked as open questions in RFD-97, not oversights: a per-task image raises version-pinning questions RFD-91 is still settling, and a per-task disk collides with the single-writer lease model.
func (*TaskConfig) ResolvedMaxConcurrent ¶ added in v0.14.0
func (tc *TaskConfig) ResolvedMaxConcurrent() int
ResolvedMaxConcurrent returns the task's concurrency cap, defaulting to 1.
func (*TaskConfig) ResolvedSchedule ¶ added in v0.14.0
func (tc *TaskConfig) ResolvedSchedule() (string, error)
ResolvedSchedule returns the calendar expression this task fires on, with Every already desugared. It returns "" for a task that isn't scheduled.
Callers can rely on Validate having rejected anything unparseable, so the only error here is a programming one.
func (*TaskConfig) ResolvedTrigger ¶ added in v0.14.0
func (tc *TaskConfig) ResolvedTrigger() string
ResolvedTrigger returns the task's trigger, defaulting to manual.
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