store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 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 store persists komando state (inventory, keys, snippets, jobs, tunnels, settings) as JSON files under $KOMANDO_HOME (default ~/.komando).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureHome

func EnsureHome() error

EnsureHome creates the state directory tree.

func Home

func Home() string

func Path

func Path(parts ...string) string

func Update

func Update(fn func(s *State) error) error

Update loads state under an exclusive file lock, applies fn and saves atomically. Safe for concurrent komando processes (parallel agents).

func WriteFileAtomic

func WriteFileAtomic(path string, b []byte, mode os.FileMode) error

Types

type Host

type Host struct {
	Name        string            `json:"name"`
	Address     string            `json:"address"`
	Port        int               `json:"port,omitempty"`
	User        string            `json:"user,omitempty"`
	Key         string            `json:"key,omitempty"`          // name of a key in the keychain
	Identity    string            `json:"identity,omitempty"`     // path to a private key file
	PasswordRef string            `json:"password_ref,omitempty"` // secret:<name> or env:<VAR>
	SudoRef     string            `json:"sudo_ref,omitempty"`     // sudo password ref (secret:/env:)
	Jump        string            `json:"jump,omitempty"`         // host name or comma-separated chain
	Groups      []string          `json:"groups,omitempty"`
	Tags        []string          `json:"tags,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"`
	Env         map[string]string `json:"env,omitempty"` // exported before every command
	Protected   bool              `json:"protected,omitempty"`
	Notes       string            `json:"notes,omitempty"`
	CreatedAt   time.Time         `json:"created_at"`
	UpdatedAt   time.Time         `json:"updated_at"`
}

func (*Host) EffectivePort

func (h *Host) EffectivePort() int

func (*Host) HasTag

func (h *Host) HasTag(t string) bool

func (*Host) InGroup

func (h *Host) InGroup(g string) bool

type Job

type Job struct {
	ID        string    `json:"id"`
	Host      string    `json:"host"`
	Command   string    `json:"command"`
	PID       int       `json:"pid"`
	RemoteDir string    `json:"remote_dir"`
	StartedAt time.Time `json:"started_at"`
}

type Key

type Key struct {
	Name          string    `json:"name"`
	Path          string    `json:"path"`
	Type          string    `json:"type,omitempty"`
	PublicKey     string    `json:"public_key,omitempty"`
	Fingerprint   string    `json:"fingerprint,omitempty"`
	PassphraseRef string    `json:"passphrase_ref,omitempty"`
	Managed       bool      `json:"managed"` // generated/stored by komando
	CreatedAt     time.Time `json:"created_at"`
}

type Settings

type Settings struct {
	HostKeyPolicy    string   `json:"host_key_policy"` // accept-new | strict | off
	DefaultUser      string   `json:"default_user,omitempty"`
	DefaultTimeout   string   `json:"default_timeout"`
	ConnectTimeout   string   `json:"connect_timeout"`
	Parallel         int      `json:"parallel"`
	MaxOutputBytes   int      `json:"max_output_bytes"`
	ExtraDenyPattern []string `json:"extra_deny_patterns,omitempty"`
	Audit            bool     `json:"audit"`
}

func DefaultSettings

func DefaultSettings() Settings

type Snippet

type Snippet struct {
	Name        string    `json:"name"`
	Command     string    `json:"command"`
	Description string    `json:"description,omitempty"`
	Sudo        bool      `json:"sudo,omitempty"`
	Mutating    bool      `json:"mutating,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
}

type State

type State struct {
	Hosts    map[string]*Host    `json:"hosts"`
	Keys     map[string]*Key     `json:"keys"`
	Snippets map[string]*Snippet `json:"snippets"`
	Jobs     map[string]*Job     `json:"jobs"`
	Tunnels  map[string]*Tunnel  `json:"tunnels"`
	Settings Settings            `json:"settings"`
}

func Load

func Load() (*State, error)

Load reads state. Callers that mutate must use Update for locking.

func (*State) SortedHosts

func (s *State) SortedHosts() []*Host

type Tunnel

type Tunnel struct {
	ID        string    `json:"id"`
	Host      string    `json:"host"`
	Kind      string    `json:"kind"` // local | remote | dynamic
	Spec      string    `json:"spec"`
	PID       int       `json:"pid"`
	LogFile   string    `json:"log_file"`
	StartedAt time.Time `json:"started_at"`
}

Jump to

Keyboard shortcuts

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