Documentation
¶
Overview ¶
Package config handles configuration management for dodot. It supports loading configuration from multiple sources including TOML files, environment variables, and command-line flags.
Index ¶
- func FileExists(path string) bool
- func GenerateConfigContent() string
- func GetUserDefaultsContent() string
- func Initialize(cfg *Config)
- type Config
- type FilePermissions
- type IgnoreRule
- type LinkPaths
- type Mappings
- type OverrideRule
- type PackConfig
- type Paths
- type Patterns
- type Rule
- type Security
- type ShellIntegration
- type SpecialFiles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileExists ¶
FileExists is a helper to check if a file exists
func GenerateConfigContent ¶ added in v0.3.0
func GenerateConfigContent() string
GenerateConfigContent generates the configuration file content with commented values
func GetUserDefaultsContent ¶ added in v0.3.0
func GetUserDefaultsContent() string
GetUserDefaultsContent returns the content of the user defaults configuration file
func Initialize ¶ added in v0.3.0
func Initialize(cfg *Config)
Initialize sets up the global configuration
Types ¶
type Config ¶ added in v0.1.1
type Config struct {
Security Security `koanf:"security"`
Patterns Patterns `koanf:"patterns"`
Rules []Rule `koanf:"rules"`
FilePermissions FilePermissions `koanf:"file_permissions"`
ShellIntegration ShellIntegration `koanf:"shell_integration"`
Paths Paths `koanf:"paths"`
LinkPaths LinkPaths `koanf:"link_paths"`
Mappings Mappings `koanf:"mappings"`
}
Config is the main configuration structure
func LoadConfiguration ¶ added in v0.3.0
func LoadPackConfiguration ¶ added in v0.3.0
LoadPackConfiguration loads a pack-specific config and merges it with the base config
func (*Config) GenerateRulesFromMapping ¶ added in v0.3.0
GenerateRulesFromMapping creates rules based on mappings configuration
type FilePermissions ¶ added in v0.1.1
type FilePermissions struct {
Directory os.FileMode `koanf:"directory"`
File os.FileMode `koanf:"file"`
Executable os.FileMode `koanf:"executable"`
}
FilePermissions holds file and directory permission settings IMPORTANT: These permissions are intentionally NOT used throughout the codebase. File permissions (0755, 0644, etc.) should remain hardcoded where they are used as they are security-critical and context-specific. This struct exists only for potential future use cases where centralized permissions might be beneficial.
func GetFilePermissions ¶ added in v0.3.0
func GetFilePermissions() FilePermissions
GetFilePermissions returns file permission configuration
type IgnoreRule ¶ added in v0.3.0
type IgnoreRule struct {
Path string `toml:"path"`
}
IgnoreRule defines a file or pattern to be ignored
type LinkPaths ¶ added in v0.3.0
type LinkPaths struct {
// CoreUnixExceptions lists tools that should always deploy to $HOME
// These are typically security-critical or shell-expected locations
// Release C: Layer 2 - Exception List
CoreUnixExceptions map[string]bool `koanf:"force_home"`
}
LinkPaths holds link path mapping configuration
func GetLinkPaths ¶ added in v0.3.0
func GetLinkPaths() LinkPaths
GetLinkPaths returns link path configuration
type Mappings ¶ added in v0.3.0
type Mappings struct {
// Path specifies directory names that should be added to PATH
Path string `koanf:"path"`
// Install specifies the filename pattern for install scripts
Install string `koanf:"install"`
// Shell specifies filename patterns for shell scripts
Shell []string `koanf:"shell"`
// Homebrew specifies the filename pattern for Homebrew files
Homebrew string `koanf:"homebrew"`
}
Mappings holds file name to handler mappings
type OverrideRule ¶ added in v0.3.0
type OverrideRule struct {
Path string `toml:"path"`
Handler string `toml:"handler"`
With map[string]interface{} `toml:"with"`
}
OverrideRule defines a behavior override for a specific file or pattern
type PackConfig ¶ added in v0.3.0
type PackConfig struct {
Ignore []IgnoreRule `toml:"ignore"`
Override []OverrideRule `toml:"override"`
Mappings map[string]string `toml:"mappings"`
}
PackConfig represents configuration options for a pack from .dodot.toml
func LoadPackConfig ¶
func LoadPackConfig(configPath string) (PackConfig, error)
LoadPackConfig reads and parses a pack's .dodot.toml configuration file
func (*PackConfig) FindOverride ¶ added in v0.3.0
func (c *PackConfig) FindOverride(filename string) *OverrideRule
FindOverride returns the override rule that matches the given filename, if any. It prioritizes exact matches over pattern matches.
func (*PackConfig) IsIgnored ¶ added in v0.3.0
func (c *PackConfig) IsIgnored(filename string) bool
IsIgnored checks if a given file path should be ignored based on the pack's configuration. It matches the filename against the list of ignore rules.
type Paths ¶ added in v0.1.1
type Paths struct {
}
Paths holds path-related configuration NOTE: Internal datastore paths (StateDir, BackupsDir, etc.) are defined in pkg/paths/paths.go and are NOT user-configurable. They are part of dodot's internal structure and should remain consistent across all installations. This struct intentionally left empty for now but may hold user-configurable paths in the future.
type Patterns ¶ added in v0.1.1
type Patterns struct {
PackIgnore []string `koanf:"pack_ignore" yaml:"packIgnore" json:"packIgnore"`
CatchallExclude []string `koanf:"catchall_exclude" yaml:"catchallExclude" json:"catchallExclude"`
SpecialFiles SpecialFiles `koanf:"special_files" yaml:"specialFiles" json:"specialFiles"`
}
Patterns holds various ignore and exclude patterns
func GetPatterns ¶ added in v0.3.0
func GetPatterns() Patterns
GetPatterns returns pattern configuration
type Rule ¶ added in v0.3.0
type Rule struct {
Pattern string `koanf:"pattern" yaml:"pattern" json:"pattern"`
Handler string `koanf:"handler" yaml:"handler" json:"handler"`
Options map[string]interface{} `koanf:"options" yaml:"options" json:"options"`
}
Rule defines a pattern-to-handler mapping
type Security ¶ added in v0.1.1
type Security struct {
// ProtectedPaths defines paths that should not be symlinked for security reasons
// TODO: Implement in pkg/handlers/lib/symlink/symlink.go ProcessLinking()
ProtectedPaths map[string]bool `koanf:"protected_paths"`
}
Security holds security-related configuration
func GetSecurity ¶ added in v0.3.0
func GetSecurity() Security
GetSecurity returns security configuration
type ShellIntegration ¶ added in v0.1.1
type ShellIntegration struct {
BashZshSnippet string `koanf:"bash_zsh_snippet"`
BashZshSnippetWithCustom string `koanf:"bash_zsh_snippet_with_custom"`
FishSnippet string `koanf:"fish_snippet"`
}
ShellIntegration holds shell integration snippets
func GetShellIntegration ¶ added in v0.3.0
func GetShellIntegration() ShellIntegration
GetShellIntegration returns shell integration configuration
type SpecialFiles ¶ added in v0.1.1
type SpecialFiles struct {
PackConfig string `koanf:"pack_config"`
IgnoreFile string `koanf:"ignore_file"`
}
SpecialFiles holds names of special configuration files