config

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 8 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 provides configuration loading for the krci CLI. It uses Viper for layered config: flags > env vars > config file > defaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFlags added in v0.20.0

func AddFlags(fs *pflag.FlagSet)

AddFlags registers the configuration flags on fs.

func DefaultConfigDir

func DefaultConfigDir() string

DefaultConfigDir returns ~/.config/krci.

func Save

func Save(cfg *Config) error

Save persists resolved configuration values to the config file. Non-empty values (including those resolved from env vars) are written so they survive across sessions without requiring env vars again.

Types

type Config

type Config struct {
	IssuerURL      string `mapstructure:"issuer-url"`
	ClientID       string `mapstructure:"client-id"`
	Scopes         string `mapstructure:"scopes"`
	PortalURL      string `mapstructure:"portal-url"`
	ClusterName    string `mapstructure:"cluster-name"`
	Namespace      string `mapstructure:"namespace"`
	TokenPath      string
	KeyringService string
	ConfigDir      string
}

Config holds all resolved configuration values.

type Loader added in v0.20.0

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

Loader resolves a Config from flags, env vars, the config file, and defaults.

func New added in v0.20.0

func New(fs *pflag.FlagSet, w io.Writer) *Loader

New builds a Loader over fs: flags > env > file > defaults. Register the flags on fs before calling New; flags added later are not bound. New reads the config file once; a file that exists but cannot be read or parsed is reported on w and ignored. Flag values are read when Resolve runs. w must be non-nil.

func (*Loader) Resolve added in v0.20.0

func (l *Loader) Resolve() (*Config, error)

Resolve returns the merged configuration. Call it after the flags are parsed.

Jump to

Keyboard shortcuts

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