Documentation
¶
Overview ¶
Package config implements layered YAML configuration for SSU.
Configuration is loaded in priority order (highest wins):
- CLI flags (--jobs, --verbose, etc.)
- Environment variables (SSU_GIT_PARALLEL_JOBS, etc.)
- Project config (.ssu.yaml in project root)
- Global config (~/.ssu/config.yaml)
- Built-in defaults
The legacy PARALLEL_JOBS env var (without SSU_ prefix) is silently supported but SSU_GIT_PARALLEL_JOBS takes priority when both are set.
Index ¶
- func Load(projectRoot string) (*Config, *AnnotatedConfig, error)
- func WithAnnotated(ctx context.Context, ac *AnnotatedConfig) context.Context
- func WithConfig(ctx context.Context, cfg *Config) context.Context
- type AnnotatedConfig
- type AnnotatedValue
- type BackupConfig
- type BranchConfig
- type Config
- type GitConfig
- type LogConfig
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
func Load(projectRoot string) (*Config, *AnnotatedConfig, error)
Load reads configuration from defaults, global config, project config, and environment variables. It returns the merged Config and an AnnotatedConfig tracking which layer set each value.
The projectRoot parameter is the git repository root (or cwd if not in a repo). Missing config files are silently skipped. Malformed config files return an error.
func WithAnnotated ¶
func WithAnnotated(ctx context.Context, ac *AnnotatedConfig) context.Context
WithAnnotated stores an AnnotatedConfig in the context.
Types ¶
type AnnotatedConfig ¶
type AnnotatedConfig struct {
// contains filtered or unexported fields
}
AnnotatedConfig tracks which layer set each configuration key. Keys use flat dot-notation (e.g., "git.parallel_jobs").
func AnnotatedFromContext ¶
func AnnotatedFromContext(ctx context.Context) *AnnotatedConfig
AnnotatedFromContext retrieves the AnnotatedConfig from the context. Returns nil if no AnnotatedConfig is stored.
func NewAnnotatedConfig ¶
func NewAnnotatedConfig() *AnnotatedConfig
NewAnnotatedConfig creates an empty AnnotatedConfig.
func (*AnnotatedConfig) Get ¶
func (ac *AnnotatedConfig) Get(key string) AnnotatedValue
Get returns the annotated value for a config key. If the key is not found, it returns an AnnotatedValue with nil Value and SourceDefault.
func (*AnnotatedConfig) Keys ¶
func (ac *AnnotatedConfig) Keys() []string
Keys returns all tracked config keys in no particular order.
type AnnotatedValue ¶
AnnotatedValue pairs a configuration value with the source that set it.
type BackupConfig ¶
type BackupConfig struct {
Enabled bool `mapstructure:"enabled"`
MaxBackups int `mapstructure:"max_backups"`
}
BackupConfig holds backup behavior settings.
type BranchConfig ¶
type BranchConfig struct {
Priority []string `mapstructure:"priority"`
Override string `mapstructure:"override"`
}
BranchConfig holds branch detection settings.
type Config ¶
type Config struct {
Git GitConfig `mapstructure:"git"`
Branches BranchConfig `mapstructure:"branches"`
Backup BackupConfig `mapstructure:"backup"`
Log LogConfig `mapstructure:"log"`
}
Config holds all SSU configuration values.
func Defaults ¶
func Defaults() Config
Defaults returns a Config populated with built-in default values.
func FromContext ¶
FromContext retrieves the Config from the context. Returns nil if no Config is stored.
type GitConfig ¶
type GitConfig struct {
ParallelJobs int `mapstructure:"parallel_jobs"`
Skip []string `mapstructure:"skip"`
FailFast bool `mapstructure:"fail_fast"`
}
GitConfig holds git operation settings.
type LogConfig ¶
type LogConfig struct {
MaxSizeMB int `mapstructure:"max_size_mb"`
MaxBackups int `mapstructure:"max_backups"`
}
LogConfig holds logging settings.
type Source ¶
type Source string
Source identifies which configuration layer set a value.
const ( // SourceDefault means the value comes from built-in defaults. SourceDefault Source = "default" // SourceGlobal means the value was set in ~/.ssu/config.yaml. SourceGlobal Source = "global (~/.ssu/config.yaml)" // SourceProject means the value was set in .ssu.yaml. SourceProject Source = "project (.ssu.yaml)" // SourceEnv means the value was set via an SSU_ environment variable. SourceEnv Source = "env" // SourceFlag means the value was set via a CLI flag. SourceFlag Source = "flag" )