config

package
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const CredentialStoreKeyring = "keyring"

CredentialStoreKeyring is the credential_store value that stores the secret fields in the OS keyring instead of the plaintext config file.

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 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"
	// CredentialStore selects where the secret fields live: "" or "file" keeps
	// them plaintext in this file (legacy default); "keyring" stores them in the
	// OS keyring and omits them from the file.
	CredentialStore string `mapstructure:"credential_store" yaml:"credential_store,omitempty"`
	// KeyringID is the opaque account under which this profile's secrets are
	// stored in the OS keyring. It is generated on first keyring save and keeps
	// entries unique across config files and stable across profile renames.
	KeyringID      string    `mapstructure:"keyring_id" yaml:"keyring_id,omitempty"`
	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"`
	ReadOnly       bool      `mapstructure:"read_only" yaml:"read_only,omitempty"`
	MCP            MCPConfig `mapstructure:"mcp" yaml:"mcp,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.

func LoadWithOverrides added in v2.9.0

func LoadWithOverrides(configPath string, profileName string, ov Overrides, log *debug.Logger) (*Config, error)

LoadWithOverrides reads configuration and applies CLI-flag overrides before the keyring is consulted, so a flag-supplied secret short-circuits the keyring lookup. It allows recovery without an active profile, mirroring LoadAllowNoActiveProfile.

type MCPConfig added in v2.5.0

type MCPConfig struct {
	// EnableWrites, when set, becomes the default for `--enable-writes` on
	// the MCP server. A nil pointer means "fall back to the flag default".
	EnableWrites *bool `mapstructure:"enable_writes" yaml:"enable_writes,omitempty"`
	// EnableGroups restricts the server to the listed tool groups.
	EnableGroups []string `mapstructure:"enable_groups" yaml:"enable_groups,omitempty"`
	// DisableGroups removes groups from the active set.
	DisableGroups []string `mapstructure:"disable_groups" yaml:"disable_groups,omitempty"`
	// EnableTools is an explicit allow-list of tool names.
	EnableTools []string `mapstructure:"enable_tools" yaml:"enable_tools,omitempty"`
	// DisableTools is a deny-list of tool names applied last.
	DisableTools []string `mapstructure:"disable_tools" yaml:"disable_tools,omitempty"`
	// AuthToken, when non-empty, becomes the default for `--auth-token` on
	// the MCP HTTP transport. Bearer tokens supplied here are used as the
	// shared secret clients must present in the Authorization header.
	AuthToken string `mapstructure:"auth_token" yaml:"auth_token,omitempty"`
}

MCPConfig holds per-profile defaults for the `redmine mcp serve` command. Empty slices and a nil EnableWrites mean "no preference"; the CLI flags and environment variables take precedence over these values.

type Overrides added in v2.9.0

type Overrides struct {
	Server string
	APIKey string
}

Overrides carries CLI-flag credential values that outrank both the config file and the keyring. They are resolved before any keyring lookup so an explicit --server/--api-key never triggers a keyring read.

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