config

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() string

func DeleteProfile

func DeleteProfile(name string, path string) error

DeleteProfile removes a profile from the config file.

func EffectiveProfileName

func EffectiveProfileName(pc *ProfileConfig, override string) string

EffectiveProfileName resolves which profile name should be displayed or used for commands that mirror Load's profile selection behavior.

func IsNoActiveProfileError

func IsNoActiveProfileError(err error) bool

IsNoActiveProfileError reports whether err is the missing-active-profile error.

func ProfileNameFromURL

func ProfileNameFromURL(serverURL string) string

ProfileNameFromURL derives a profile name from a server URL.

func Save

func Save(cfg *Config, path string) error

Save writes a single profile's configuration (used by auth login).

func SaveProfile

func SaveProfile(name string, cfg *Config, path string) error

SaveProfile writes a named profile to the config file.

func SaveProfiles

func SaveProfiles(pc *ProfileConfig, path string) error

SaveProfiles writes the full profile configuration to disk.

func SetActiveProfile

func SetActiveProfile(name string, path string) error

SetActiveProfile sets the active profile in the config file.

Types

type Config

type Config struct {
	Server         string `mapstructure:"server" yaml:"server,omitempty"`
	APIKey         string `mapstructure:"api_key" yaml:"api_key,omitempty"`
	Username       string `mapstructure:"username" yaml:"username,omitempty"`
	Password       string `mapstructure:"password" yaml:"password,omitempty"`
	AuthMethod     string `mapstructure:"auth_method" yaml:"auth_method,omitempty"` // "apikey" or "basic"
	DefaultProject string `mapstructure:"default_project" yaml:"default_project,omitempty"`
	OutputFormat   string `mapstructure:"output_format" yaml:"output_format,omitempty"` // "table", "json", "csv"
	NoColor        bool   `mapstructure:"no_color" yaml:"no_color,omitempty"`
}

Config holds the CLI configuration for a single profile.

func Load

func Load(configPath string, profileName string, log *debug.Logger) (*Config, error)

Load reads configuration and returns the active profile's Config. If profileName is non-empty, that profile is used instead of the active one. Environment variables (REDMINE_*) override file values.

func LoadAllowNoActiveProfile

func LoadAllowNoActiveProfile(configPath string, profileName string, log *debug.Logger) (*Config, error)

LoadAllowNoActiveProfile reads configuration while allowing the caller to recover with explicit CLI credentials when no active profile is selected.

type ProfileConfig

type ProfileConfig struct {
	ActiveProfile string            `yaml:"active_profile,omitempty"`
	Profiles      map[string]Config `yaml:"profiles,omitempty"`
}

ProfileConfig holds the top-level configuration with multiple profiles.

func LoadProfiles

func LoadProfiles(configPath string, log *debug.Logger) (*ProfileConfig, error)

LoadProfiles reads the full profile configuration from disk. It handles both legacy flat format and new profile format. If the config file does not exist, it returns an empty ProfileConfig.

Jump to

Keyboard shortcuts

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