config

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 9 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) and named profiles (= seeds). 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 a profile.

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       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

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) 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.

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"`
}

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"` // "local" (default) | "remote"
}

Profile is a named cuttle seed with a storage policy.

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