config

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package config loads and validates gitlab-reviewer settings with the precedence flags > environment variables > settings file > defaults.

Index

Constants

This section is empty.

Variables

View Source
var Categories = []string{"bug", "security", "performance", "docs", "style", "design"}

Categories of findings the reviewer can be asked to produce.

View Source
var Severities = []string{"info", "minor", "major", "critical"}

Severity levels a finding can carry, ordered weakest to strongest.

Functions

func DefaultCacheDir

func DefaultCacheDir() string

DefaultCacheDir is where repository clones and worktrees are cached.

func DefaultFile

func DefaultFile() string

DefaultFile is the default settings file location.

func DefaultLogFile

func DefaultLogFile() string

DefaultLogFile is the default log destination; the TUI owns stdout so logs always go to a file.

func DefaultStateDir

func DefaultStateDir() string

DefaultStateDir is where logs and raw review dumps are written.

Types

type Bedrock

type Bedrock struct {
	Region  string `koanf:"region"`
	Profile string `koanf:"profile"`
}

type Checkout

type Checkout struct {
	Mode         string `koanf:"mode"` // clone | path | root
	Path         string `koanf:"path"`
	Root         string `koanf:"root"`
	Transport    string `koanf:"transport"` // https | ssh
	CacheDir     string `koanf:"cache_dir"`
	CacheMaxMB   int    `koanf:"cache_max_mb"`
	Keep         bool   `koanf:"keep"`
	CloneMissing bool   `koanf:"clone_missing"`
	// LocalOverlay globs select untracked files in the local clone (path
	// and root modes) that are copied into the review worktree — team
	// standards kept out of the repo, e.g. via .git/info/exclude.
	LocalOverlay []string `koanf:"local_overlay"`
}

type Config

type Config struct {
	GitLab   GitLab   `koanf:"gitlab"`
	Review   Review   `koanf:"review"`
	Bedrock  Bedrock  `koanf:"bedrock"`
	Checkout Checkout `koanf:"checkout"`
	Publish  Publish  `koanf:"publish"`
	UI       UI       `koanf:"ui"`
	Log      Log      `koanf:"log"`
}

func Default

func Default() Config

Default returns the built-in defaults, the lowest-precedence layer.

func (Config) Validate

func (c Config) Validate() error

Validate checks internal consistency. It does not require a GitLab token; commands that talk to GitLab must additionally call ValidateGitLab.

func (Config) ValidateGitLab

func (c Config) ValidateGitLab() error

ValidateGitLab checks settings required to talk to GitLab at all. An empty project/group scope is fine: the TUI offers in-app selection.

type GitLab

type GitLab struct {
	BaseURL  string   `koanf:"base_url"`
	Token    string   `koanf:"token"`
	Projects []string `koanf:"projects"`
	Groups   []string `koanf:"groups"`
	PerPage  int      `koanf:"per_page"`
}

type Log

type Log struct {
	Level string `koanf:"level"`
	File  string `koanf:"file"`
}

type Options

type Options struct {
	// File is an explicit settings file path (--config). Empty = default
	// XDG location, which is allowed to be absent.
	File string
	// Flags is the parsed flag set; nil skips the flag layer.
	Flags *pflag.FlagSet
	// LookupEnv overrides os.LookupEnv in tests.
	LookupEnv func(string) (string, bool)
}

Options control loading; zero value means real environment and default paths.

type Publish

type Publish struct {
	Mode            string `koanf:"mode"` // draft | immediate
	AutoComment     bool   `koanf:"auto_comment"`
	AutoMinSeverity string `koanf:"auto_min_severity"`
	FallbackToNote  bool   `koanf:"fallback_to_note"`
	Attribution     bool   `koanf:"attribution"`
	// Template is a Go text/template for the comment body with fields
	// severity, category, title, body, file. Empty means the built-in
	// "**[severity · category] title**" layout; set e.g. "{{.body}}" for
	// comments with no machine-looking header.
	Template string `koanf:"template"`
}

type Result

type Result struct {
	Config Config
	// FilePath is the settings file that was read, "" if none existed.
	FilePath string
	// contains filtered or unexported fields
}

Result is a loaded configuration plus the merged koanf tree, kept so per-project overrides can be applied later.

func Load

func Load(opts Options) (*Result, error)

Load builds the effective configuration: defaults → file → env → flags.

func (*Result) ForProject

func (r *Result) ForProject(projectPath string) (Config, error)

ForProject returns the configuration with per-project overrides from the settings file's projects.<full/project/path> section merged over the review, checkout, and publish sections.

func (*Result) Redacted

func (r *Result) Redacted() map[string]any

Redacted returns the effective configuration as a YAML-ready map with secret values masked, for `config show`.

type Review

type Review struct {
	Provider         string        `koanf:"provider"` // anthropic | bedrock
	Model            string        `koanf:"model"`
	ClaudePath       string        `koanf:"claude_path"`
	Timeout          time.Duration `koanf:"timeout"`
	MaxBudgetUSD     float64       `koanf:"max_budget_usd"`
	Categories       []string      `koanf:"categories"`
	Instructions     string        `koanf:"instructions"`
	InstructionsFile string        `koanf:"instructions_file"`
	MaxDiffKB        int           `koanf:"max_diff_kb"`
	Exclude          []string      `koanf:"exclude"`
	Bare             bool          `koanf:"bare"`
	// UseAgents lets the reviewer delegate to Claude Code subagents
	// (project .claude/agents plus user-level ones). Write/exec tools
	// stay denied for the whole session, subagents included.
	UseAgents bool              `koanf:"use_agents"`
	Env       map[string]string `koanf:"env"`
}

type UI added in v1.2.0

type UI struct {
	// DiffView is the diff layout in the MR detail screen: unified or
	// split (side-by-side). Toggleable per session with `v`.
	DiffView string `koanf:"diff_view"`
}

Jump to

Keyboard shortcuts

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