config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config manages Podplane CLI runtime configuration and stored auth state.

Index

Constants

View Source
const (
	// KeyringPassEnv is the environment variable used to force and unlock the
	// file-based keyring backend.
	KeyringPassEnv = "PODPLANE_KEYRING_PASS"

	// LocalKeyringPass is the fixed file-keyring password used by local kubectl
	// exec auth so kubectl can read local dev credentials non-interactively.
	LocalKeyringPass = "podplane-local"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMetadata

type AuthMetadata struct {
	Sub         string `mapstructure:"sub" json:"sub"`
	ClusterID   string `mapstructure:"cluster_id" json:"cluster_id"`
	ClusterName string `mapstructure:"cluster_name" json:"cluster_name"`
	Issuer      string `mapstructure:"issuer" json:"issuer"`
	ClientID    string `mapstructure:"client_id" json:"client_id"`
	UserEmail   string `mapstructure:"user_email" json:"user_email"`
}

AuthMetadata is the per-(sub, cluster) metadata the CLI needs to refresh tokens and emit kubectl ExecCredentials. It is stored in a viper config file under `auth.<sub>:<clusterID>`.

type AuthSecrets

type AuthSecrets struct {
	IDToken      string `json:"id_token"`
	RefreshToken string `json:"refresh_token"`
}

AuthSecrets holds the actual tokens. Stored in the OS keyring at `dev.podplane.auth.<sub>:<clusterID>`.

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config provides getters/setters for working with the config, and holds our viper instance for the config file and keyring instance.

func Init

func Init() (*Config, error)

Init initializes the Config struct

func InitWithLocalKeyring

func InitWithLocalKeyring() (*Config, func(), error)

InitWithLocalKeyring initializes a Config that uses the same file-based keyring backend as local kubectl exec auth. The returned restore function resets the process environment to its previous state.

func (*Config) ApiURL

func (c *Config) ApiURL() string

ApiURL returns API service URL

func (*Config) Arch

func (c *Config) Arch() string

Arch returns the target architecture for downloading deps. If the user has set PODPLANE_ARCH (or the equivalent config value), that takes precedence; otherwise it falls back to runtime.GOARCH (typically "arm64" or "amd64").

func (*Config) AuthDelete

func (c *Config) AuthDelete(sub, clusterID string) error

AuthDelete removes both the metadata and the keyring secrets for the given (sub, clusterID) pair. Missing entries are a no-op.

func (*Config) AuthGet

func (c *Config) AuthGet(sub, clusterID string) (AuthMetadata, AuthSecrets, error)

AuthGet returns the metadata + secrets for a given (sub, clusterID) pair. Returns zero values (and no error) if the entry does not exist.

func (*Config) AuthListByCluster

func (c *Config) AuthListByCluster(clusterID string) ([]AuthMetadata, error)

AuthListByCluster returns every AuthMetadata entry whose ClusterID matches.

func (*Config) AuthSet

func (c *Config) AuthSet(meta AuthMetadata, secrets AuthSecrets) error

AuthSet writes both metadata (to the viper config) and secrets (to the keyring) for a given (sub, clusterID). The pair is taken from meta.{Sub,ClusterID}.

func (*Config) CacheDirectory

func (c *Config) CacheDirectory() string

CacheDirectory returns the directory for downloaded or derived files.

Linux:   $XDG_CACHE_HOME/podplane   (default ~/.cache/podplane)
macOS:   ~/.podplane/cache
Windows: %USERPROFILE%\.podplane\cache

The XDG_CACHE_HOME env var overrides the default on all platforms.

func (*Config) CachePath

func (c *Config) CachePath(opts ...string) (string, error)

CachePath returns the absolute path of a file or directory under the cache directory (i.e. ~/.podplane/cache/something)

func (*Config) ConfigDirectory

func (c *Config) ConfigDirectory() string

ConfigDirectory returns the directory for long-term config and auth metadata.

Linux:   $XDG_CONFIG_HOME/podplane   (default ~/.config/podplane)
macOS:   ~/.podplane/config
Windows: %USERPROFILE%\.podplane\config

The XDG_CONFIG_HOME env var overrides the default on all platforms.

func (*Config) DataDirectory

func (c *Config) DataDirectory() string

DataDirectory returns the directory for durable local VM/cluster data.

Linux:   $XDG_DATA_HOME/podplane   (default ~/.local/share/podplane)
macOS:   ~/.podplane/data
Windows: %USERPROFILE%\.podplane\data

The XDG_DATA_HOME env var overrides the default on all platforms.

func (*Config) DepsBaseURL

func (c *Config) DepsBaseURL() string

DepsBaseURL returns the base URL used to fetch dependency manifests.

func (*Config) DepsCacheDir

func (c *Config) DepsCacheDir() string

DepsCacheDir returns the directory used to cache deps files (the manifest JSON and all downloaded dependency artifacts).

func (*Config) File

func (c *Config) File() string

File returns the filename of the config file

func (*Config) InitFile

func (c *Config) InitFile() error

InitFile configures viper to work with a config file and ensure it exists, then loads it

func (*Config) InstanceKind

func (c *Config) InstanceKind() string

InstanceKind returns the instance kind (always "knc" for now)

func (*Config) KeyringDelete

func (c *Config) KeyringDelete(key string) error

func (*Config) KeyringRead

func (c *Config) KeyringRead(key string) ([]byte, error)

func (*Config) KeyringWrite

func (c *Config) KeyringWrite(key string, value []byte) error

func (*Config) OIDCIssuerURL

func (c *Config) OIDCIssuerURL() string

OIDCIssuerURL returns Auth / OIDC Issuer URL

func (*Config) ResolveCACert

func (c *Config) ResolveCACert(subdir, spec string) (string, error)

ResolveCACert resolves a CA cert spec (inline PEM / http(s) URL / file path) to an absolute path on disk, caching URL fetches and inline PEMs under <CacheDirectory>/<subdir>. An empty spec returns ("", nil).

func (*Config) RuntimeDirectory

func (c *Config) RuntimeDirectory() string

RuntimeDirectory returns the directory for ephemeral process/session files.

Linux:   $XDG_RUNTIME_DIR/podplane   (default ~/.podplane/run)
macOS:   ~/.podplane/run
Windows: %USERPROFILE%\.podplane\run

The XDG_RUNTIME_DIR env var overrides the default on all platforms.

func (*Config) SaveFile

func (c *Config) SaveFile() error

SaveFile saves the config to a file

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the config once it has been loaded using runtimeConfig

func (*Config) Verbose

func (c *Config) Verbose() bool

Verbose returns true if debugging is enabled

Jump to

Keyboard shortcuts

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