Documentation
¶
Overview ¶
Package config provides configuration management for the CLI.
Package config provides configuration management for the CLI.
Package config provides configuration management for the CLI.
Package config provides configuration management for the CLI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidURL is returned when the URL is invalid. ErrInvalidURL = apperrors.NewValidation("invalid URL", apperrors.WithHint("URL must start with http:// or https://")) // ErrInvalidAPIKey is returned when the API key is invalid. ErrInvalidAPIKey = apperrors.NewValidation("invalid API key", apperrors.WithHint("API key must be at least 10 characters")) // ErrInstanceNotFound is returned when the instance is not found. ErrInstanceNotFound = apperrors.NewValidation("instance not found", apperrors.WithHint("check available instances with 'redmine config list'")) // ErrAPIKeyNotFound is returned when the API key is not found in keyring. ErrAPIKeyNotFound = apperrors.NewValidation("API key not found in keyring", apperrors.WithHint("run 'redmine login' to store your API key")) )
Functions ¶
func ValidateAPIKey ¶
ValidateAPIKey validates the given API key.
func ValidateInstance ¶
ValidateInstance validates the given instance configuration. If the API key is stored in a keyring (apiKeyFromKeyring=true), the API key check is skipped since the key is not in the Instance struct.
Types ¶
type Config ¶
type Config struct {
Default string `yaml:"default"`
Instances map[string]Instance `yaml:"instances"`
Settings Settings `yaml:"settings"`
Git GitConfig `yaml:"git"`
Report ReportConfig `yaml:"report"`
}
Config holds the CLI configuration.
func (*Config) CurrentInstance ¶
CurrentInstance returns the current default instance.
type GitConfig ¶
type GitConfig struct {
AutoLink bool `yaml:"auto_link"`
CommitPattern string `yaml:"commit_pattern"`
DefaultProject int `yaml:"default_project"`
}
GitConfig holds Git integration settings.
type Instance ¶
type Instance struct {
Name string `yaml:"-"`
URL string `yaml:"url"`
APIKey string `yaml:"api_key"`
}
Instance represents a Redmine instance configuration.
type Keyring ¶
type Keyring interface {
// Get 从密钥环获取 API Key
Get(instanceName string) (string, error)
// Set 将 API Key 存储到密钥环
Set(instanceName, apiKey string) error
// Delete 从密钥环删除 API Key
Delete(instanceName string) error
// IsAvailable 检查密钥环是否可用
IsAvailable() bool
}
Keyring 定义密钥环接口
type ReportConfig ¶
type ReportConfig struct {
TemplatesDir string `yaml:"templates_dir"`
DefaultFormat string `yaml:"default_format"`
}
ReportConfig holds report generation settings.
type Settings ¶
type Settings struct {
Timeout time.Duration `yaml:"timeout"`
Retries int `yaml:"retries"`
OutputFormat string `yaml:"output_format"`
PageSize int `yaml:"page_size"`
}
Settings holds general CLI settings.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store handles configuration persistence.
func NewStoreWithKeyring ¶
NewStoreWithKeyring creates a new config store with a specific keyring.
func (*Store) DeleteInstance ¶
DeleteInstance deletes an instance from the configuration and keyring.
func (*Store) Load ¶
Load loads the configuration from disk. If a keyring is available, API keys are resolved from the keyring instead of the YAML file (which stores them only as a fallback).
func (*Store) SaveInstance ¶
SaveInstance saves an instance to the configuration. If the keyring is available, the API key is stored securely in the keyring and the YAML file only contains an empty api_key field.
func (*Store) SetDefault ¶
SetDefault sets the default instance.