Documentation
¶
Index ¶
- Constants
- Variables
- func Get(key string) interface{}
- func GetBool(key string) bool
- func GetProjectConfigPath() string
- func GetString(key string) string
- func HasProjectConfig() bool
- func Init(cfgFile string) error
- func InitProjectConfig() error
- func IsCredentialKey(key string) bool
- func Save() error
- func SaveProjectConfig(settings map[string]interface{}) error
- func Set(key string, value interface{})
- func TestInitProjectConfig_Unix(t *testing.T)
- type Config
- type Provider
- func (p *Provider) AllSettings() map[string]interface{}
- func (p *Provider) Get(key string) interface{}
- func (p *Provider) GetBool(key string) bool
- func (p *Provider) GetInt(key string) int
- func (p *Provider) GetProjectConfigPath() string
- func (p *Provider) GetString(key string) string
- func (p *Provider) GetStringMap(key string) map[string]interface{}
- func (p *Provider) GetStringSlice(key string) []string
- func (p *Provider) HasProjectConfig() bool
- func (p *Provider) InitProjectConfig() error
- func (p *Provider) IsSet(key string) bool
- func (p *Provider) Save() error
- func (p *Provider) Set(key string, value interface{})
Constants ¶
const RedactedValue = "<redacted — cu authenticates via the system keyring, not this file>"
RedactedValue is substituted for credential values in any bulk output. It deliberately does not claim where the value lives: a key found here is a plaintext leftover, not the keyring entry cu actually authenticates with.
Variables ¶
var ( // DefaultConfigDir is the default configuration directory DefaultConfigDir = filepath.Join(os.Getenv("HOME"), ".config", "cu") // ConfigFileName is the name of the config file ConfigFileName = "config" // ConfigType is the type of the config file ConfigType = "yaml" // ProjectConfigFileName is the name of the project config file ProjectConfigFileName = ".cu.yml" )
Functions ¶
func GetProjectConfigPath ¶
func GetProjectConfigPath() string
GetProjectConfigPath returns the path to the project config file
func HasProjectConfig ¶
func HasProjectConfig() bool
HasProjectConfig returns true if a project config file was found
func InitProjectConfig ¶
func InitProjectConfig() error
InitProjectConfig creates a new project config file in the current directory
func IsCredentialKey ¶ added in v0.2.1
IsCredentialKey reports whether a config key holds a credential.
func Save ¶
func Save() error
Save writes the global config file. Only values that came from that file or were written through Set are persisted — project .cu.yml values, environment variables and flags are deliberately excluded, so running `cu config set` inside a project can no longer bake that project's settings into the global config.
func SaveProjectConfig ¶
SaveProjectConfig saves configuration to the project config file
func Set ¶
func Set(key string, value interface{})
Set sets a configuration value for this process and stages it for the global config file, so a following Save persists it there.
Credential keys are applied in-process but never staged: writing them to ~/.config/cu/config.yaml would put a secret on disk in plaintext, and nothing reads it back — authentication goes through the OS keyring. Callers that take a key from the user should refuse it outright via IsCredentialKey rather than relying on this backstop, so the user gets told instead of silently ignored.
Types ¶
type Config ¶
type Config struct {
DefaultSpace string `mapstructure:"default_space"`
DefaultFolder string `mapstructure:"default_folder"`
DefaultList string `mapstructure:"default_list"`
Output string `mapstructure:"output"`
Debug bool `mapstructure:"debug"`
APIToken string `mapstructure:"api_token"`
Workspaces map[string]string `mapstructure:"workspaces"`
}
Config represents the application configuration
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider wraps viper to implement the ConfigProvider interface
func NewWithViper ¶
NewWithViper creates a new config provider with a specific viper instance
func (*Provider) AllSettings ¶
AllSettings returns all settings
func (*Provider) GetProjectConfigPath ¶
GetProjectConfigPath returns the path to the project config file
func (*Provider) GetStringMap ¶
GetStringMap returns a string map configuration value
func (*Provider) GetStringSlice ¶
GetStringSlice returns a string slice configuration value
func (*Provider) HasProjectConfig ¶
HasProjectConfig returns true if a project config file was found
func (*Provider) InitProjectConfig ¶
InitProjectConfig creates a new project config file