config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config defines the persistent on-disk model for kay: the set of keys, users (login users live on the server record) and servers the operator has registered. State is a single human-inspectable JSON file; private keys are never stored in it (only paths to PEM files on disk).

Index

Constants

View Source
const CurrentVersion = 1

CurrentVersion is the schema version stamped on save. Version 0 (absent) is the original v0.1 layout, which had no version field; it is read without migration.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key struct {
	Name        string    `json:"name"`
	Type        KeyType   `json:"type"`
	PrivatePath string    `json:"privatePath"`
	PublicPath  string    `json:"publicPath"`
	Fingerprint string    `json:"fingerprint"`
	CreatedAt   time.Time `json:"createdAt"`
}

Key is a locally generated key pair, referenced by servers via Name.

type KeyType

type KeyType string

KeyType enumerates the supported key algorithms.

const (
	KeyEd25519 KeyType = "ed25519"
	KeyRSA     KeyType = "rsa"
)

type PanelPref added in v0.2.0

type PanelPref struct {
	Name   string `json:"name"`
	Hidden bool   `json:"hidden,omitempty"`
}

PanelPref is one Overview panel's saved preference: its identifier plus whether the user hid it. Order in the slice is the display order.

type Server

type Server struct {
	Alias   string `json:"alias"`
	Host    string `json:"host"`
	Port    int    `json:"port"`
	User    string `json:"user"`
	KeyName string `json:"keyName"`
}

Server is a registered remote host plus the login user and key to use.

func (Server) Addr

func (s Server) Addr() string

Addr returns the host:port string used for dialing.

type Store

type Store struct {
	Version int         `json:"version"`
	Keys    []Key       `json:"keys"`
	Servers []Server    `json:"servers"`
	UI      *UISettings `json:"ui,omitempty"`
	// contains filtered or unexported fields
}

Store is the whole persisted state.

func Load

func Load() (*Store, error)

Load reads the store from disk, creating directories as needed. A missing config file is not an error: it yields an empty, ready-to-use store.

func LoadFrom

func LoadFrom(dir string) (*Store, error)

LoadFrom loads the store rooted at a specific directory (used by tests).

func (*Store) AddKey

func (s *Store) AddKey(k Key) error

AddKey appends a key, rejecting duplicate names.

func (*Store) AddServer

func (s *Store) AddServer(srv Server) error

AddServer appends a server, rejecting duplicate aliases and verifying the referenced key exists.

func (*Store) Dir

func (s *Store) Dir() string

Dir returns the resolved configuration directory.

func (*Store) FindKey

func (s *Store) FindKey(name string) (*Key, error)

FindKey returns the named key, or an error if it does not exist.

func (*Store) FindServer

func (s *Store) FindServer(alias string) (*Server, error)

FindServer returns the server with the given alias, or an error.

func (*Store) KeysDir

func (s *Store) KeysDir() string

KeysDir returns the directory where private/public key files live.

func (*Store) KnownHostsPath

func (s *Store) KnownHostsPath() string

KnownHostsPath returns the path to the TOFU known_hosts file.

func (*Store) OverviewPanels added in v0.2.0

func (s *Store) OverviewPanels() []PanelPref

OverviewPanels returns the saved Overview panel layout, or nil when the user has not customised it (callers then fall back to their built-in default order).

func (*Store) RemoveServer

func (s *Store) RemoveServer(alias string) error

RemoveServer deletes a server by alias.

func (*Store) Save

func (s *Store) Save() error

Save atomically writes the store to disk with restrictive permissions. It stamps the current schema version; older files (version 0) are upgraded in place on the next save without touching existing keys or servers.

func (*Store) SetOverviewPanels added in v0.2.0

func (s *Store) SetOverviewPanels(panels []PanelPref)

SetOverviewPanels records a customised Overview layout.

type UISettings added in v0.2.0

type UISettings struct {
	Overview []PanelPref `json:"overview,omitempty"` // Overview panel order + visibility
}

UISettings holds user interface preferences that persist across sessions.

Jump to

Keyboard shortcuts

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