config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 12 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 manages mistctl contexts: a named combination of Mist cloud, API token and default org/site, stored in a kubeconfig-style file.

Index

Constants

View Source
const DefaultCacheTTL = 10 * time.Minute

DefaultCacheTTL is used when cache-ttl is not set.

Variables

View Source
var ErrChanged = errors.New("the config file was changed by another process; run the command again")

ErrChanged is returned by Save when the file changed on disk after it was loaded (another mistctl process saved it in the meantime).

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the config path, honouring $MISTCTL_CONFIG.

Types

type Config

type Config struct {
	CurrentContext string              `yaml:"current-context,omitempty" json:"current-context,omitempty"`
	Contexts       map[string]*Context `yaml:"contexts,omitempty" json:"contexts,omitempty"`
	// CacheTTL is how long cached name/ID indexes stay fresh, in Go duration
	// syntax (default 10m).
	CacheTTL string `yaml:"cache-ttl,omitempty" json:"cache-ttl,omitempty"`
	// contains filtered or unexported fields
}

Config is the on-disk configuration.

func Load

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

Load reads and validates the config at path. A missing file yields an empty config. Unknown keys, null contexts and an invalid cache-ttl are errors, so a typo never silently changes which org or token is used.

func (*Config) Names

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

Names returns the sorted context names.

func (*Config) Path

func (c *Config) Path() string

Path returns where the config is stored.

func (*Config) PermissionWarning

func (c *Config) PermissionWarning() string

PermissionWarning returns a message when the file holds a token and other users can read it (mistctl writes it 0600, a hand-made file may not be).

func (*Config) Save

func (c *Config) Save() error

Save writes the config atomically with 0600 permissions, since it can hold tokens. It refuses to overwrite a file that changed since Load, so two concurrent commands cannot silently drop each other's update.

func (*Config) TTL

func (c *Config) TTL() (time.Duration, error)

TTL returns the cache TTL (DefaultCacheTTL when unset).

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the structure of the config.

type Context

type Context struct {
	Cloud    string `yaml:"cloud" json:"cloud"`
	Token    string `yaml:"token,omitempty" json:"token,omitempty"`
	TokenEnv string `yaml:"token_env,omitempty" json:"token_env,omitempty"`
	Org      string `yaml:"org,omitempty" json:"org,omitempty"`
	Site     string `yaml:"site,omitempty" json:"site,omitempty"`
}

Context is one named target. The JSON tags match the YAML ones so that `config view -o json` uses the same field names as the file.

func (*Context) ResolveToken

func (ctx *Context) ResolveToken() string

ResolveToken returns the token for a context, reading token_env if set.

Jump to

Keyboard shortcuts

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