Documentation
¶
Overview ¶
Package config handles loading and validation of user configuration from ~/.config/auto-mr/config.yml.
The configuration file uses YAML format with required fields for both GitLab and GitHub platforms (assignee and reviewer usernames). Forgejo is an optional third platform: validation is skipped when no URL is provided, so existing gitlab/github-only configs keep working unchanged. Optional pipeline_timeout fields accept Go duration strings (e.g., "45m", "1h30m") with bounds of 1 minute to 8 hours.
Usage:
cfg, err := config.Load() fmt.Println(cfg.GitLab.Assignee) // "john-doe" fmt.Println(cfg.GitHub.PipelineTimeout) // "1h" fmt.Println(cfg.Forgejo.URL) // "https://codeberg.org"
Index ¶
Constants ¶
const MaxPipelineTimeout = maxPipelineTimeout
MaxPipelineTimeout is the maximum allowed pipeline timeout (8 hours).
const MinPipelineTimeout = minPipelineTimeout
MinPipelineTimeout is the minimum allowed pipeline timeout (1 minute).
Variables ¶
var ( ErrConfigNotFound = errConfigNotFound ErrGitLabAssigneeEmpty = errGitLabAssigneeEmpty ErrGitLabReviewerEmpty = errGitLabReviewerEmpty ErrGitHubAssigneeEmpty = errGitHubAssigneeEmpty ErrGitHubReviewerEmpty = errGitHubReviewerEmpty ErrGitLabAssigneeInvalid = errGitLabAssigneeInvalid ErrGitLabReviewerInvalid = errGitLabReviewerInvalid ErrGitHubAssigneeInvalid = errGitHubAssigneeInvalid ErrGitHubReviewerInvalid = errGitHubReviewerInvalid ErrForgejoAssigneeEmpty = errForgejoAssigneeEmpty ErrForgejoReviewerEmpty = errForgejoReviewerEmpty ErrForgejoAssigneeInvalid = errForgejoAssigneeInvalid ErrForgejoReviewerInvalid = errForgejoReviewerInvalid ErrForgejoURLInvalid = errForgejoURLInvalid ErrInvalidTimeout = errInvalidTimeout ErrTimeoutTooSmall = errTimeoutTooSmall ErrTimeoutTooLarge = errTimeoutTooLarge )
Export for external error checking with errors.Is().
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
GitLab GitLabConfig `yaml:"gitlab"`
GitHub GitHubConfig `yaml:"github"`
Forgejo ForgejoConfig `yaml:"forgejo"`
}
Config represents the complete configuration for auto-mr.
func Load ¶
Load reads and parses the configuration file from ~/.config/auto-mr/config.yml. The configuration is validated automatically after parsing.
Returns ErrConfigNotFound if the config file does not exist. Returns a validation error if any required field is missing or invalid.
func (*Config) Validate ¶
Validate checks that all required configuration fields are set and valid. It trims whitespace from all fields before validation and performs format checks.
Validation includes:
- Required fields: assignee and reviewer for both platforms
- Username format: alphanumeric, hyphens, underscores, 1-39 chars
- Timeout format: valid Go duration, MinPipelineTimeout to MaxPipelineTimeout
Returns the first validation error encountered.
type ForgejoConfig ¶ added in v0.14.0
type ForgejoConfig struct {
URL string `yaml:"url"`
Assignee string `yaml:"assignee"`
Reviewer string `yaml:"reviewer"`
PipelineTimeout string `yaml:"pipeline_timeout,omitempty"`
}
ForgejoConfig contains Forgejo-specific configuration. Forgejo is an optional platform: when URL is empty the entire section is skipped during validation, preserving backward compatibility with gitlab/github-only config files.
type GitHubConfig ¶
type GitHubConfig struct {
Assignee string `yaml:"assignee"`
Reviewer string `yaml:"reviewer"`
PipelineTimeout string `yaml:"pipeline_timeout,omitempty"`
}
GitHubConfig contains GitHub-specific configuration.
type GitLabConfig ¶
type GitLabConfig struct {
Assignee string `yaml:"assignee"`
Reviewer string `yaml:"reviewer"`
PipelineTimeout string `yaml:"pipeline_timeout,omitempty"`
}
GitLabConfig contains GitLab-specific configuration.