config

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: GPL-3.0 Imports: 11 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 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

View Source
var ErrNoPath = errors.New("config has no path")

ErrNoPath is returned by Save when the config has no backing file path.

Functions

func DefaultPath

func DefaultPath() (string, error)

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 Load

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

Load reads the config at path (file optional) and layers DARKUBE_* env vars on top.

func (*Config) AddTenant

func (c *Config) AddTenant(name string)

AddTenant records a tenant slug if not already present.

func (*Config) ForgetTunnel added in v0.5.0

func (c *Config) ForgetTunnel(key string)

ForgetTunnel drops a tunnel credential.

func (*Config) Path

func (c *Config) Path() string

Path returns the file path backing this config.

func (*Config) Save

func (c *Config) Save() error

Save writes the config back to disk as YAML, creating the parent directory if needed.

func (*Config) SetTunnelAuth added in v0.5.0

func (c *Config) SetTunnelAuth(key, auth string)

SetTunnelAuth records a tunnel credential, allocating the map on first use.

func (*Config) TunnelAuth added in v0.5.0

func (c *Config) TunnelAuth(key string) string

TunnelAuth returns the stored credential for a tunnel key, empty if unknown.

Jump to

Keyboard shortcuts

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