Documentation
¶
Overview ¶
Package config loads and persists darkubectl's kubeconfig-style settings.
The config file lives at $DARKUBE_CONFIG or ~/.darkube/config.yaml and models "tenants" (Hamravesh organizations) as switchable contexts, in the same spirit as kubectl contexts. A single account API key authenticates across all tenants; the active tenant is sent as the X-Organization header on every request.
Loading is layered with koanf: the YAML file first, then DARKUBE_* environment variables on top (env wins). Persisting is a plain YAML marshal, since koanf is a read/merge library and does not itself write files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoPath = errors.New("config has no path")
ErrNoPath is returned by Save when the config has no backing file path.
Functions ¶
func DefaultPath ¶
DefaultPath returns the config path, honoring $DARKUBE_CONFIG then ~/.darkube/config.yaml.
Types ¶
type Config ¶
type Config struct {
// Token is the Hamravesh account API key, sent as "Authorization: Api-key <token>".
Token string `koanf:"token"`
// CurrentTenant is the active organization slug (X-Organization).
CurrentTenant string `koanf:"current-tenant"`
// Tenants is the list of known organization slugs.
Tenants []string `koanf:"tenants"`
// BaseURL overrides the API host (defaults to the public Hamravesh API).
BaseURL string `koanf:"base-url"`
// RefreshToken is a Console JWT refresh token (from `darkubectl login`), used
// to mint short-lived access tokens for the terminal/exec websocket. The
// account API key cannot open the terminal, so this is a separate credential.
RefreshToken string `koanf:"refresh-token"`
// Tunnels maps a chisel tunnel's "<tenant>/<app>" key to its user:pass
// credential. It is stored here because the API cannot give it back: secret
// envs are write-only, so the value handed to the server at creation is
// readable exactly once, and a client that cannot reproduce it cannot
// connect. See cmd/tunnel.go.
Tunnels map[string]string `koanf:"tunnels"`
// contains filtered or unexported fields
}
Config is the on-disk configuration.
func (*Config) ForgetTunnel ¶ added in v0.5.0
ForgetTunnel drops a tunnel credential.
func (*Config) Save ¶
Save writes the config back to disk as YAML, creating the parent directory if needed.
func (*Config) SetTunnelAuth ¶ added in v0.5.0
SetTunnelAuth records a tunnel credential, allocating the map on first use.
func (*Config) TunnelAuth ¶ added in v0.5.0
TunnelAuth returns the stored credential for a tunnel key, empty if unknown.