config

package
v0.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	BackendLocal  = "local"
	BackendK8s    = "k8s"
	BackendSSH    = "ssh"
	BackendDirect = "direct"
)

Backend names selectable per context.

View Source
const (
	StorageLocal  = "local"
	StorageRemote = "remote"
)

Storage modes for the helm chart's profileStorage value (PVC vs scratch).

View Source
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"`
	// Secrets maps a secret NAME to the command that resolves it on this host.
	// Global, not per-context, and deliberately so: a credential is a credential,
	// and per-context would mean registering the same vault reference twice. It
	// holds the recipe only - a resolved value never touches this file, or any
	// file. The command runs at set/refresh time, never at substitution time: the
	// daemon is in a container with no vault, no keychain and no biometrics, and
	// there is no daemon-to-host callback.
	//
	// Note this table is a one-way version floor: LoadFrom rejects unknown fields,
	// so a config carrying it will not load on a cuttle older than the release
	// that introduced it.
	Secrets map[string]string `toml:"secret,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

func Load() (*Config, error)

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

func LoadFrom(path string) (*Config, error)

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

func (c *Config) Active(flag, env string) (string, Context, error)

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

func (c *Config) Names() []string

Names returns the context names in a stable order (local first, then the rest sorted) for listing.

func (*Config) RemoveSecret added in v0.14.0

func (c *Config) RemoveSecret(name string) bool

RemoveSecret drops a name's resolver, reporting whether there was one.

func (*Config) Save added in v0.7.0

func (c *Config) Save(path string) error

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.

func (*Config) SecretExec added in v0.14.0

func (c *Config) SecretExec(name string) (string, bool)

SecretExec returns the resolver registered for a name.

func (*Config) SetSecretExec added in v0.14.0

func (c *Config) SetSecretExec(name, exec string)

SetSecretExec registers (or replaces) a name's resolver.

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.

type Resources

type Resources struct {
	Requests map[string]string `toml:"requests"`
	Limits   map[string]string `toml:"limits"`
}

Resources mirrors a Kubernetes resource requests/limits block.

type Toleration

type Toleration struct {
	Key      string `toml:"key"`
	Operator string `toml:"operator"`
	Value    string `toml:"value"`
	Effect   string `toml:"effect"`
}

Toleration mirrors a Kubernetes toleration passed through to the Helm chart.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL