Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearHostToken ¶
ClearHostToken removes the token for a specific host. Returns nil if the host is not in the config.
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns the directory where kh stores its configuration files. Defaults to ~/.config/kh; respects $XDG_CONFIG_HOME if set.
func SetHostToken ¶
SetHostToken updates the token for a specific host in the hosts config. If a bare-hostname entry already exists, the token is merged into it.
func StateDir ¶
func StateDir() string
StateDir returns the directory where kh stores runtime state. Defaults to ~/.local/state/kh; respects $XDG_STATE_HOME if set.
func WriteConfig ¶
WriteConfig serialises cfg to ConfigFile(), creating the directory if needed.
func WriteHosts ¶
func WriteHosts(cfg HostsConfig) error
WriteHosts serialises cfg to HostsFile(), creating the directory if needed.
Types ¶
type Config ¶
type Config struct {
ConfigVersion string `yaml:"config_version"`
DefaultHost string `yaml:"default_host,omitempty"`
}
Config holds the top-level application configuration stored in config.yml.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with built-in defaults applied.
func ReadConfig ¶
ReadConfig reads ConfigFile() and returns the parsed Config. If the file does not exist, it returns DefaultConfig() without error.
type HostConfig ¶
type HostConfig struct {
User string `yaml:"user,omitempty"`
Token string `yaml:"token,omitempty"`
Headers map[string]string `yaml:"headers,omitempty"`
}
HostConfig holds per-host authentication and connection details.
type HostsConfig ¶
type HostsConfig struct {
Hosts map[string]HostConfig `yaml:"hosts,omitempty"`
DefaultHost string `yaml:"default_host,omitempty"`
ConfigVersion string `yaml:"config_version,omitempty"`
}
HostsConfig is the top-level structure for hosts.yml.
func ReadHosts ¶
func ReadHosts() (HostsConfig, error)
ReadHosts reads HostsFile() and returns the parsed HostsConfig. If the file does not exist, it returns an empty HostsConfig without error.
func (*HostsConfig) ActiveHost ¶
func (h *HostsConfig) ActiveHost(flagHost, envHost string) string
ActiveHost resolves the active host using the priority chain: flagHost > envHost > h.DefaultHost > config.yml DefaultHost > "app.keeperhub.com"
func (*HostsConfig) HostEntry ¶
func (h *HostsConfig) HostEntry(hostname string) (HostConfig, bool)
HostEntry looks up the HostConfig for the given hostname. It tries the raw value first, then falls back to a bare hostname (scheme stripped) so that --host https://app-staging.keeperhub.com matches a hosts.yml key of app-staging.keeperhub.com.