config

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const MaxPipelineTimeout = maxPipelineTimeout

MaxPipelineTimeout is the maximum allowed pipeline timeout (8 hours).

View Source
const MinPipelineTimeout = minPipelineTimeout

MinPipelineTimeout is the minimum allowed pipeline timeout (1 minute).

Variables

View Source
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

func Load() (*Config, error)

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

func (c *Config) Validate() error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL