Documentation
¶
Overview ¶
Package config loads the cuttle TOML config and resolves the active context.
The config is read-mostly: a single file at $XDG_CONFIG_HOME/cuttle/config.toml declares named contexts - where the browser runs. A missing file yields a built-in "local" context, so cuttle needs zero config to drive a local docker browser.
Index ¶
Constants ¶
const ( BackendLocal = "local" BackendK8s = "k8s" BackendSSH = "ssh" BackendDirect = "direct" )
Backend names selectable per context.
const ( StorageLocal = "local" StorageRemote = "remote" )
Storage modes for the helm chart's profileStorage value (PVC vs scratch).
const EnvContext = "CUTTLE_CONTEXT"
EnvContext is the environment variable that selects the active context.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath is $XDG_CONFIG_HOME/cuttle/config.toml, falling back to ~/.config/cuttle/config.toml.
Types ¶
type Config ¶
type Config struct {
DefaultContext string `toml:"default_context,omitempty"`
Contexts map[string]Context `toml:"context,omitempty"`
// Profiles is accepted and ignored: named profiles were removed when the CLI
// became session-only (one browser per container). Tolerating the key keeps
// an older config loading instead of failing on an unknown field.
Profiles map[string]Profile `toml:"profile,omitempty"`
}
Config is the parsed config file. Missing keys leave zero values. omitempty on the optional fields keeps a Save-written config free of empty-key noise.
func Load ¶
Load reads the config from the default XDG path. A missing file is not an error: it returns a Config carrying only the built-in local context.
func LoadFrom ¶
LoadFrom reads a specific config file. A missing file yields the built-in local context. Unknown keys are rejected (strict mode) so a typo surfaces instead of silently doing nothing.
func (*Config) Active ¶
Active resolves the active context by name. Precedence: flag > env > default_context > built-in "local". A named context that does not exist is an error (typo protection).
func (*Config) Names ¶
Names returns the context names in a stable order (local first, then the rest sorted) for listing.
func (*Config) Save ¶ added in v0.7.0
Save writes the config to path, creating the parent directory if needed. It round-trips only Config's own known schema: any key the current cuttle build does not model is dropped, so `context add` never has to preserve foreign keys (KISS). The built-in "local" context injected by Load is omitted so it is not persisted as an explicit stanza.
type Context ¶
type Context struct {
Backend string `toml:"backend"`
// k8s
Namespace string `toml:"namespace,omitempty"`
Release string `toml:"release,omitempty"`
KubeContext string `toml:"kube_context,omitempty"`
NodeSelector map[string]string `toml:"node_selector,omitempty"`
Tolerations []Toleration `toml:"tolerations,omitempty"`
Resources *Resources `toml:"resources,omitempty"`
// ssh
Host string `toml:"host,omitempty"`
// direct
CDPURL string `toml:"cdp_url,omitempty"`
VNCURL string `toml:"vnc_url,omitempty"`
// applied at browser startup regardless of backend
Proxy string `toml:"proxy,omitempty"`
// Screen is the "WxH" the browser claims and is sized to, from the image
// persona's table; empty = the daemon default (the largest, in session mode).
Screen string `toml:"screen,omitempty"`
}
Context describes where and how a browser runs. Which fields are meaningful depends on Backend; unused fields stay zero.
type Profile ¶
type Profile struct {
Storage string `toml:"storage"`
}
Profile is the retired named-profile entry; see Config.Profiles.