config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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 BindFlags

func BindFlags(cmd *cobra.Command)

BindFlags registers persistent flags on the root command and binds them to Viper.

func DefaultConfigDir

func DefaultConfigDir() string

DefaultConfigDir returns ~/.config/krci.

func Init

func Init()

Init sets up Viper defaults and reads the config file. Call this early — before Cobra parses flags.

func Save

func Save(cfg *Config) error

Save persists user-provided values to the config file. Only writes non-empty values so defaults and env vars are not baked in.

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"`
	Namespace      string `mapstructure:"namespace"`
	APIServer      string `mapstructure:"api-server"`
	CAData         string `mapstructure:"ca-data"`
	TokenPath      string
	KeyringService string
	ConfigDir      string
}

Config holds all resolved configuration values.

func Resolve

func Resolve() (*Config, error)

Resolve reads the merged config AFTER Cobra has parsed flags. Call this from PersistentPreRunE so flags are available.

Jump to

Keyboard shortcuts

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