Documentation
¶
Overview ¶
Package config manages Podplane CLI runtime configuration and stored auth state.
Index ¶
- Constants
- type AuthMetadata
- type AuthSecrets
- type Config
- func (c *Config) Arch() string
- func (c *Config) AuthDelete(sub, clusterID string) error
- func (c *Config) AuthGet(sub, clusterID string) (AuthMetadata, AuthSecrets, error)
- func (c *Config) AuthListByCluster(clusterID string) ([]AuthMetadata, error)
- func (c *Config) AuthSet(meta AuthMetadata, secrets AuthSecrets) error
- func (c *Config) CacheDirectory() string
- func (c *Config) CachePath(opts ...string) (string, error)
- func (c *Config) ConfigDirectory() string
- func (c *Config) DataDirectory() string
- func (c *Config) DepsBaseURL() string
- func (c *Config) DepsCacheDir() string
- func (c *Config) File() string
- func (c *Config) InitFile() error
- func (c *Config) InstanceKind() string
- func (c *Config) KeyringDelete(key string) error
- func (c *Config) KeyringRead(key string) ([]byte, error)
- func (c *Config) KeyringWrite(key string, value []byte) error
- func (c *Config) OIDCIssuerURL() string
- func (c *Config) ResolveCACert(subdir, spec string) (string, error)
- func (c *Config) RuntimeDirectory() string
- func (c *Config) SaveFile() error
- func (c *Config) Validate() error
- func (c *Config) Verbose() bool
Constants ¶
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 InitWithLocalKeyring ¶
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) Arch ¶
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 ¶
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 ¶
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 ¶
CachePath returns the absolute path of a file or directory under the cache directory (i.e. ~/.podplane/cache/something)
func (*Config) ConfigDirectory ¶
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 ¶
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 ¶
DepsBaseURL returns the URL used to fetch dependency manifests and artifacts.
func (*Config) DepsCacheDir ¶
DepsCacheDir returns the directory used to cache deps files (the manifest JSON and all downloaded dependency artifacts).
func (*Config) InitFile ¶
InitFile configures viper to work with a config file and ensure it exists, then loads it
func (*Config) InstanceKind ¶
InstanceKind returns the instance kind (always "knc" for now)
func (*Config) KeyringDelete ¶
func (*Config) OIDCIssuerURL ¶
OIDCIssuerURL returns Auth / OIDC Issuer URL
func (*Config) ResolveCACert ¶
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 ¶
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.