Documentation
¶
Overview ¶
Package config handles configuration loading and management using Viper
Index ¶
- Constants
- func DefaultLogDir() string
- func DrainWarnings() []string
- func EnsureDir(path, description string) error
- func EnsureDirMode(path, description string, perm os.FileMode) error
- func GenerateStarterConfig() string
- func ResetSuppressWarningsForTests()
- func ResolvePath(path string) string
- func ResolveWorktreePath(workspace string) string
- func ResolveWorktreesEnabled(workspace string, configOverride *bool) (bool, error)
- func ResolveYOLO(workspace string, configOverride *bool) (bool, error)
- func SanitizeHostname(path string) string
- func SetWarnWriter(w io.Writer) func()
- func SuppressWarnings()
- func UnsuppressWarnings()
- func XDGConfigHome() string
- func XDGDataHome() string
- func XDGStateHome() string
- type Config
- type HomeMount
- type PaneConfig
Constants ¶
const ( DefaultCPUs = 4 ImageNamePrefix = "bopca" DefaultMemory = "4g" )
Constants
const ( ExitBuildError = 5 ExitConfigError = 4 ExitInvalidArg = 2 ExitMissingDir = 3 ExitRequirements = 1 ExitSecretsFound = 6 )
Exit codes
Variables ¶
This section is empty.
Functions ¶
func DefaultLogDir ¶ added in v0.7.0
func DefaultLogDir() string
DefaultLogDir returns the default directory for bopca log files. Returns empty string if the state home cannot be determined.
func DrainWarnings ¶ added in v0.8.0
func DrainWarnings() []string
DrainWarnings returns and clears buffered config validation warnings. Call after logging is initialized to replay warnings to the log file.
func EnsureDirMode ¶ added in v0.7.0
EnsureDirMode creates a directory with a specific mode if it doesn't exist. If the directory already exists and is more permissive than perm, it tightens the permissions to match.
func GenerateStarterConfig ¶ added in v0.6.0
func GenerateStarterConfig() string
GenerateStarterConfig creates a starter configuration YAML string. Uses Default() values for defaults.
func ResetSuppressWarningsForTests ¶ added in v0.7.0
func ResetSuppressWarningsForTests()
ResetSuppressWarningsForTests resets warning suppression state for test isolation.
func ResolvePath ¶
ResolvePath resolves a path to an absolute path
func ResolveWorktreePath ¶ added in v0.8.0
ResolveWorktreePath resolves the worktree directory by following the workmux config chain. It reads project .workmux.yaml (if exists) then ~/.config/workmux/config.yaml and extracts the worktree_dir setting. Always returns the resolved absolute path, even if the directory doesn't exist yet.
func ResolveWorktreesEnabled ¶ added in v0.8.0
ResolveWorktreesEnabled determines whether worktrees mode is enabled for a workspace.
Resolution order:
- If configOverride is non-nil, return its value (--worktrees / --no-worktrees flags)
- Check stored per-repo state (~/.local/share/bopca/worktrees/<hash>)
- Prompt the user interactively and store the choice
func ResolveYOLO ¶ added in v0.8.0
ResolveYOLO determines whether YOLO mode is enabled for a workspace.
Resolution order:
- If configOverride is non-nil, return its value (--yolo / --bardo flags)
- Check stored per-repo state (~/.local/share/bopca/yolo/<hash>)
- Prompt the user interactively and store the choice
func SanitizeHostname ¶
SanitizeHostname generates a DNS-friendly name from a path
func SetWarnWriter ¶ added in v0.7.0
SetWarnWriter overrides the destination for config validation warnings. Returns a cleanup function that restores the previous writer.
func SuppressWarnings ¶ added in v0.7.0
func SuppressWarnings()
SuppressWarnings prevents config validation warnings from being printed. Call before config.Load() when quiet mode is requested.
func UnsuppressWarnings ¶ added in v0.7.0
func UnsuppressWarnings()
UnsuppressWarnings re-enables config validation warnings. Call when a verbosity flag overrides quiet mode.
func XDGConfigHome ¶ added in v0.6.0
func XDGConfigHome() string
XDGConfigHome returns XDG_CONFIG_HOME or falls back to ~/.config. Returns empty string if home directory cannot be determined or if XDG_CONFIG_HOME is set to a non-absolute path.
func XDGDataHome ¶ added in v0.6.0
func XDGDataHome() string
XDGDataHome returns XDG_DATA_HOME or falls back to ~/.local/share. Returns empty string if home directory cannot be determined or if XDG_DATA_HOME is set to a non-absolute path.
func XDGStateHome ¶ added in v0.7.0
func XDGStateHome() string
XDGStateHome returns XDG_STATE_HOME or falls back to ~/.local/state. Returns empty string if home directory cannot be determined or if XDG_STATE_HOME is set to a non-absolute path.
Types ¶
type Config ¶
type Config struct {
// Resources
CPUs int `mapstructure:"cpus"`
Memory string `mapstructure:"memory"`
// Tmux
Tmux bool `mapstructure:"tmux"`
// Startup panes (tmux mode only)
StartupPanes []PaneConfig `mapstructure:"startup_panes"`
// Container
ContainerName string `mapstructure:"container_name"`
ImageName string `mapstructure:"image_name"`
// Mounts
CustomMounts []string `mapstructure:"custom_mounts"`
HomeMounts []HomeMount `mapstructure:"home_mounts"`
// Environment
EnvVars []string `mapstructure:"environment"`
// Containerfile customization
ContainerfileEnv []string `mapstructure:"containerfile_env"`
ContainerfileInclude string `mapstructure:"containerfile_include"`
ContainerfilePackages []string `mapstructure:"containerfile_packages"`
ContainerfileRun string `mapstructure:"containerfile_run"`
// Scanner settings
ScannerEnabled bool `mapstructure:"scanner_enabled"`
ScannerExclude []string `mapstructure:"scanner_exclude"`
ScannerMaxFileSize int `mapstructure:"scanner_max_file_size"`
ScannerOnSecrets string `mapstructure:"scanner_on_secrets"`
ScannerScanCustomMounts bool `mapstructure:"scanner_scan_custom_mounts"`
// Output verbosity
Debug bool `mapstructure:"debug"`
DryRun bool `mapstructure:"dry_run"`
Quiet bool `mapstructure:"quiet"`
Verbosity int `mapstructure:"verbosity"`
// Logging
LogFile string `mapstructure:"log_file"`
LogMaxBackups int `mapstructure:"log_max_backups"`
LogMaxSize int `mapstructure:"log_max_size"` // MB
LogToFile bool `mapstructure:"log_to_file"`
// Worktrees mode (read-only workspace + read-write worktrees).
// nil = prompt on first use, non-nil = override stored/prompted value.
Worktrees *bool `mapstructure:"worktrees"`
// YOLO mode (skip agent permission prompts).
// nil = prompt on first use, non-nil = override stored/prompted value.
YOLO *bool `mapstructure:"yolo"`
// Toolchain installation.
// nil = auto-detect from workspace, empty = no toolchains, non-empty = explicit list.
Toolchains *[]string `mapstructure:"toolchains"`
// Build
BuildNoCache bool `mapstructure:"build_no_cache"`
// Internal
ConfigFile string `mapstructure:"-"` // Path to loaded config file
DataDir string `mapstructure:"-"` // Path to data directory (Containerfile, etc.)
Version string `mapstructure:"-"` // bopca version (set by cmd package)
}
Config holds all configuration settings
type HomeMount ¶ added in v0.8.0
type HomeMount struct {
Path string `mapstructure:"path" yaml:"path"`
ReadWrite bool `mapstructure:"read_write" yaml:"read_write"`
}
HomeMount defines a directory or file to mount from the host home directory.
func DefaultHomeMounts ¶ added in v0.8.0
func DefaultHomeMounts() []HomeMount
DefaultHomeMounts returns the default set of home directory mounts.
type PaneConfig ¶ added in v0.8.0
type PaneConfig struct {
Command string `mapstructure:"command" yaml:"command"`
Focus bool `mapstructure:"focus" yaml:"focus"`
Percentage int `mapstructure:"percentage" yaml:"percentage"` // 1-100
Size int `mapstructure:"size" yaml:"size"` // absolute lines/cells
Split string `mapstructure:"split" yaml:"split"` // horizontal, vertical
}
PaneConfig defines a tmux pane to create at startup.