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 ¶
var Categories = []string{"bug", "security", "performance", "docs", "style", "design"}
Categories of findings the reviewer can be asked to produce.
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 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 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) InstanceNames ¶ added in v1.5.0
InstanceNames returns the configured instance names in file order.
func (Config) Validate ¶
Validate checks internal consistency. It does not require a GitLab token; commands that talk to GitLab must additionally call ValidateGitLab.
func (Config) ValidateGitLab ¶
ValidateGitLab checks settings required to talk to GitLab at all. An empty project/group scope is fine: the TUI offers in-app selection.
func (Config) WithInstance ¶ added in v1.5.0
WithInstance returns a copy of the configuration narrowed to the named instance: its base URL and token replace the top-level gitlab settings. An instance with an empty token keeps gitlab.token as the fallback. Tokens named by token_env are resolved at load time; selecting an instance whose variable is unset is an error rather than a silent fallback to the shared token.
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"`
// Instances are named GitLab instances to choose between (settings file
// only). When set, one instance is selected at startup — via --instance,
// default_instance, or an interactive prompt — and its connection
// settings replace gitlab.base_url and gitlab.token.
Instances []Instance `koanf:"instances"`
// DefaultInstance names the instance to use without prompting; the
// --instance flag and GITLAB_REVIEWER_GITLAB_DEFAULT_INSTANCE override it.
DefaultInstance string `koanf:"default_instance"`
}
type Instance ¶ added in v1.5.0
type Instance struct {
Name string `koanf:"name"`
BaseURL string `koanf:"base_url"`
// Token is the access token for this instance; empty falls back to
// gitlab.token (useful when one env-provided token covers an instance).
Token string `koanf:"token"`
// TokenEnv names an environment variable holding the token for this
// instance (e.g. WORK_GITLAB_TOKEN), keeping the secret out of the
// settings file. Consulted only when token is empty; the variable must
// be set whenever this instance is selected.
TokenEnv string `koanf:"token_env"`
}
Instance is one named GitLab instance in gitlab.instances.
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 (*Result) ForProject ¶
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.
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"`
// FileExplorer is the initial state of the changed-files tree in the
// MR detail screen: open or closed. Toggleable per session with `e`.
FileExplorer string `koanf:"file_explorer"`
}