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). 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"
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 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"`
}
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 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.