config

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

package config manages the local cli state: orchestrator contexts (base url + token) and the per-context active host. it is persisted to a yaml file under the user's config dir. it knows nothing about the api.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoContext = errors.New("no active context: run `fuse connect <url> --token <token>` first")

ErrNoContext is returned when an operation needs an active context but none is selected.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the config file path, honoring XDG_CONFIG_HOME and falling back to ~/.config/fuse/config.yaml.

Types

type Config

type Config struct {
	CurrentContext string    `yaml:"current_context,omitempty"`
	Contexts       []Context `yaml:"contexts,omitempty"`
	// contains filtered or unexported fields
}

Config is the whole cli state.

func Load

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

Load reads the config from path. if path is empty, DefaultPath is used. a missing file is not an error: an empty config (with path set) is returned so the caller can add a context and Save.

func (*Config) Add

func (c *Config) Add(ctx Context)

Add inserts or replaces a context by name and makes it current.

func (*Config) Current

func (c *Config) Current(override string) (*Context, error)

Current returns the active context. if name is non-empty it overrides the stored current context (used for a per-invocation --context flag).

func (*Config) Get

func (c *Config) Get(name string) (*Context, error)

Get returns the named context or an error.

func (*Config) Path

func (c *Config) Path() string

Path returns the file this config is bound to.

func (*Config) Remove

func (c *Config) Remove(name string) error

Remove deletes a context. if it was current, the current selection is cleared.

func (*Config) Save

func (c *Config) Save() error

Save writes the config to its path with restrictive permissions (it holds tokens). the parent directory is created if needed.

func (*Config) SetActiveHost

func (c *Config) SetActiveHost(override, hostID string) error

SetActiveHost records the selected host for the current context.

func (*Config) Use

func (c *Config) Use(name string) error

Use sets the current context, validating it exists.

type Context

type Context struct {
	Name string `yaml:"name"`
	// BaseURL is the orchestrator root (scheme://host:port), no /v1 suffix.
	BaseURL string `yaml:"base_url"`
	// Token is the bearer token. empty is allowed for dev/insecure mode.
	Token string `yaml:"token,omitempty"`
	// Master marks a context whose token is the master token (required for
	// api-key commands). informational only; the server is the source of truth.
	Master bool `yaml:"master,omitempty"`
	// ActiveHost is the host id selected via `fuse host <id>`. it scopes the
	// host-scoped commands for this context.
	ActiveHost string `yaml:"active_host,omitempty"`
}

Context is a single orchestrator the cli can talk to. one orchestrator is one control plane (base url + bearer token). hosts live inside it.

Jump to

Keyboard shortcuts

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