Documentation
¶
Index ¶
- Variables
- func AddRepo(configPath, repoPath string) error
- func AllSettings() map[string]interface{}
- func ConfigFileUsed() string
- func DefaultAIModel() string
- func FindConfigYAMLPath() (string, error)
- func GetBool(key string) bool
- func GetCustomStatusesFromYAML() []string
- func GetCustomTypesFromYAML() []string
- func GetDirectoryLabels() []string
- func GetDuration(key string) time.Duration
- func GetExternalProjects() map[string]string
- func GetIdentity(flagValue string) string
- func GetInfraTypesFromYAML() []string
- func GetInt(key string) int
- func GetNamedRoles() []string
- func GetRigLevelRoles() []string
- func GetString(key string) string
- func GetStringFromDir(beadsDir, key string) string
- func GetStringMapString(key string) map[string]string
- func GetStringSlice(key string) []string
- func GetTownLevelRoles() []string
- func GetYamlConfig(key string) string
- func Initialize() error
- func IsValidSovereignty(sovereignty string) bool
- func IsYamlOnlyKey(key string) bool
- func LogOverride(override ConfigOverride)
- func MetadataSchemaFields() map[string]interface{}
- func MetadataValidationMode() string
- func RemoveRepo(configPath, repoPath string) error
- func ResetForTesting()
- func ResolveExternalProjectPath(projectName string) string
- func SaveConfigValue(key string, value interface{}, beadsDir string) error
- func Set(key string, value interface{})
- func SetReposInYAML(configPath string, repos *ReposConfig) error
- func SetYamlConfig(key, value string) error
- func ValidSovereigntyTiers() []string
- type ConfigOverride
- type ConfigSource
- type FederationConfig
- type MultiRepoConfig
- type ReposConfig
- type Sovereignty
Constants ¶
This section is empty.
Variables ¶
var ConfigWarningWriter io.Writer = os.Stderr
ConfigWarningWriter is the destination for config warnings. Defaults to os.Stderr. Can be replaced for testing or custom logging.
var ConfigWarnings = true
ConfigWarnings controls whether warnings are logged for invalid config values. Set to false to suppress warnings (useful for tests or scripts).
var YamlOnlyKeys = map[string]bool{ "no-db": true, "json": true, "db": true, "actor": true, "identity": true, "git.author": true, "git.no-gpg-sign": true, "no-push": true, "no-git-ops": true, "sync.git-remote": true, "sync.require_confirmation_on_mass_delete": true, "routing.mode": true, "routing.default": true, "routing.maintainer": true, "routing.contributor": true, "create.require-description": true, "validation.on-create": true, "validation.on-sync": true, "hierarchy.max-depth": true, "backup.enabled": true, "backup.interval": true, "backup.git-push": true, "backup.git-repo": true, "dolt.idle-timeout": true, "dolt.shared-server": true, }
YamlOnlyKeys are configuration keys that must be stored in config.yaml rather than the database. These are "startup" settings that are read before the database is opened.
This fixes GH#536: users were confused when `bd config set no-db true` appeared to succeed but had no effect (because no-db is read from yaml at startup, not from the database).
Functions ¶
func AddRepo ¶
AddRepo adds a repository to the repos.additional list in config.yaml If primary is not set, it defaults to "."
func AllSettings ¶
func AllSettings() map[string]interface{}
AllSettings returns all configuration settings as a map
func ConfigFileUsed ¶
func ConfigFileUsed() string
ConfigFileUsed returns the path to the config file that was loaded. Returns empty string if no config file was found or viper is not initialized. This is useful for resolving relative paths from the config file's directory.
func DefaultAIModel ¶
func DefaultAIModel() string
DefaultAIModel returns the configured AI model identifier. Override via: bd config set ai.model "model-name" or BD_AI_MODEL=model-name
func FindConfigYAMLPath ¶
FindConfigYAMLPath finds the config.yaml file in .beads directory Walks up from CWD to find .beads/config.yaml
func GetCustomStatusesFromYAML ¶
func GetCustomStatusesFromYAML() []string
GetCustomStatusesFromYAML retrieves custom statuses from config.yaml. This is used as a fallback when the database doesn't have status.custom set yet or when the database connection is temporarily unavailable. Returns nil if no custom statuses are configured in config.yaml.
func GetCustomTypesFromYAML ¶
func GetCustomTypesFromYAML() []string
GetCustomTypesFromYAML retrieves custom issue types from config.yaml. This is used as a fallback when the database doesn't have types.custom set yet (e.g., during bd init auto-import before the database is fully configured). Returns nil if no custom types are configured in config.yaml.
func GetDirectoryLabels ¶
func GetDirectoryLabels() []string
GetDirectoryLabels returns labels for the current working directory based on config. It checks directory.labels config for matching patterns. Returns nil if no labels are configured for the current directory.
func GetDuration ¶
GetDuration retrieves a duration configuration value
func GetExternalProjects ¶
GetExternalProjects returns the external_projects configuration. Maps project names to paths for cross-project dependency resolution. Example config.yaml:
external_projects: beads: ../beads gastown: /absolute/path/to/gastown
func GetIdentity ¶
GetIdentity resolves the user's identity for messaging. Priority chain:
- flagValue (if non-empty, from --identity flag)
- BEADS_IDENTITY env var / config.yaml identity field (via viper)
- git config user.name
- hostname
This is used as the sender field in bd mail commands.
func GetInfraTypesFromYAML ¶
func GetInfraTypesFromYAML() []string
GetInfraTypesFromYAML retrieves infrastructure type names from config.yaml. Infrastructure types are routed to the wisps table instead of the versioned issues table. Returns nil if no infra types are configured in config.yaml (caller should use defaults).
func GetNamedRoles ¶
func GetNamedRoles() []string
GetNamedRoles returns roles that can have multiple named instances per rig. These roles include a name suffix: <prefix>-<rig>-<role>-<name>
func GetRigLevelRoles ¶
func GetRigLevelRoles() []string
GetRigLevelRoles returns roles that are rig-level singletons. These roles have one instance per rig: <prefix>-<rig>-<role>
func GetStringFromDir ¶
GetStringFromDir reads a single string configuration value directly from <beadsDir>/config.yaml without using or modifying global viper state. This is intended for library consumers that call NewFromConfigWithOptions without first invoking config.Initialize().
The key uses dotted notation (e.g. "dolt.auto-start"). YAML booleans and numbers are coerced to their string representations ("true", "false", etc.). Returns "" if the file is absent, the key is not found, or any error occurs.
func GetStringMapString ¶
GetStringMapString retrieves a map[string]string configuration value
func GetStringSlice ¶
GetStringSlice retrieves a string slice configuration value
func GetTownLevelRoles ¶
func GetTownLevelRoles() []string
GetTownLevelRoles returns roles that are town-level singletons. These roles have no rig association and appear as: <prefix>-<role>
func GetYamlConfig ¶
GetYamlConfig gets a configuration value from config.yaml. Returns empty string if key is not found or is commented out. Keys are normalized to their canonical yaml format (e.g., sync.branch -> sync-branch).
func Initialize ¶
func Initialize() error
Initialize sets up the viper configuration singleton Should be called once at application startup
func IsValidSovereignty ¶
IsValidSovereignty returns true if the given string is a valid sovereignty tier. Empty string is valid (means no restriction).
func IsYamlOnlyKey ¶
IsYamlOnlyKey returns true if the given key should be stored in config.yaml rather than the Dolt database.
func LogOverride ¶
func LogOverride(override ConfigOverride)
LogOverride logs a message about a configuration override in verbose mode.
func MetadataSchemaFields ¶
func MetadataSchemaFields() map[string]interface{}
MetadataSchemaFields returns the raw field definitions from config. Returns nil if config is not initialized or no fields are defined. Each entry maps field name → map of properties (type, values, required, min, max).
func MetadataValidationMode ¶
func MetadataValidationMode() string
MetadataValidationMode returns the metadata schema validation mode. Returns "none" if config is not initialized or mode is empty/unknown.
func RemoveRepo ¶
RemoveRepo removes a repository from the repos.additional list in config.yaml
func ResetForTesting ¶
func ResetForTesting()
ResetForTesting clears the config state, allowing Initialize() to be called again. This is intended for tests that need to change config.yaml between test steps. WARNING: Not thread-safe. Only call from single-threaded test contexts.
func ResolveExternalProjectPath ¶
ResolveExternalProjectPath resolves a project name to its absolute path. Returns empty string if project not configured or path doesn't exist.
func SaveConfigValue ¶
SaveConfigValue sets a key-value pair and writes it to the config file. If no config file is currently loaded, it creates config.yaml in the given beadsDir. Only the specified key is modified; other file contents are preserved.
func SetReposInYAML ¶
func SetReposInYAML(configPath string, repos *ReposConfig) error
SetReposInYAML writes the repos configuration to config.yaml It preserves other config sections and comments where possible
func SetYamlConfig ¶
SetYamlConfig sets a configuration value in the project's config.yaml file. It handles both adding new keys and updating existing (possibly commented) keys. Keys are normalized to their canonical yaml format (e.g., sync.branch -> sync-branch).
func ValidSovereigntyTiers ¶
func ValidSovereigntyTiers() []string
ValidSovereigntyTiers returns the list of valid sovereignty tier values.
Types ¶
type ConfigOverride ¶
type ConfigOverride struct {
Key string
EffectiveValue interface{}
OverriddenBy ConfigSource
OriginalSource ConfigSource
OriginalValue interface{}
}
ConfigOverride represents a detected configuration override
func CheckOverrides ¶
func CheckOverrides(flagOverrides map[string]struct { Value interface{} WasSet bool }) []ConfigOverride
CheckOverrides checks for configuration overrides and returns a list of detected overrides. This is useful for informing users when env vars or flags override config file values. flagOverrides is a map of key -> (flagValue, flagWasSet) for flags that were explicitly set.
type ConfigSource ¶
type ConfigSource string
ConfigSource represents where a configuration value came from
const ( SourceDefault ConfigSource = "default" SourceConfigFile ConfigSource = "config_file" SourceEnvVar ConfigSource = "env_var" SourceFlag ConfigSource = "flag" )
func GetValueSource ¶
func GetValueSource(key string) ConfigSource
GetValueSource returns the source of a configuration value. Priority (highest to lowest): env var > config file > default Note: Flag overrides are handled separately in main.go since viper doesn't know about cobra flags.
type FederationConfig ¶
type FederationConfig struct {
Remote string // dolthub://org/beads, gs://bucket/beads, s3://bucket/beads
Sovereignty Sovereignty // T1, T2, T3, T4
}
FederationConfig holds the federation (Dolt remote) configuration.
func GetFederationConfig ¶
func GetFederationConfig() FederationConfig
GetFederationConfig returns the current federation configuration.
type MultiRepoConfig ¶
type MultiRepoConfig struct {
Primary string // Primary repo path (where canonical issues live)
Additional []string // Additional repos to hydrate from
}
MultiRepoConfig contains configuration for multi-repo support
func GetMultiRepoConfig ¶
func GetMultiRepoConfig() *MultiRepoConfig
GetMultiRepoConfig retrieves multi-repo configuration Returns nil if multi-repo is not configured (single-repo mode)
type ReposConfig ¶
type ReposConfig struct {
Primary string `yaml:"primary,omitempty"`
Additional []string `yaml:"additional,omitempty,flow"`
}
ReposConfig represents the repos section of config.yaml
func GetReposFromYAML ¶
func GetReposFromYAML(configPath string) (*ReposConfig, error)
GetReposFromYAML reads the repos configuration from config.yaml Returns an empty ReposConfig if repos section doesn't exist
func ListRepos ¶
func ListRepos(configPath string) (*ReposConfig, error)
ListRepos returns the current repos configuration from YAML
type Sovereignty ¶
type Sovereignty string
Sovereignty represents the federation sovereignty tier
const ( // SovereigntyNone means no sovereignty restriction (empty value) SovereigntyNone Sovereignty = "" // SovereigntyT1 is the most open tier (public repos) SovereigntyT1 Sovereignty = "T1" // SovereigntyT2 is organization-level SovereigntyT2 Sovereignty = "T2" // SovereigntyT3 is pseudonymous SovereigntyT3 Sovereignty = "T3" // SovereigntyT4 is anonymous SovereigntyT4 Sovereignty = "T4" )
func GetSovereignty ¶
func GetSovereignty() Sovereignty
GetSovereignty retrieves the federation sovereignty tier configuration. Returns the configured tier, or SovereigntyNone (empty, no restriction) if not set. Returns SovereigntyT1 and logs a warning if an invalid non-empty value is configured.
Config key: federation.sovereignty Valid values: T1, T2, T3, T4 (empty means no restriction)
func (Sovereignty) String ¶
func (s Sovereignty) String() string
String returns the string representation of the Sovereignty.