config

package
v1.5.2-0...-4d0c20d Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAppToGroup

func AddAppToGroup(groupName string, appName string) error

AddAppToGroup adds an app to a group, creating the group if it doesn't exist

func AddCustomGroup

func AddCustomGroup(name string, tools []string) error

AddCustomGroup adds a new custom group

func AddInstalledApp

func AddInstalledApp(appName string) error

AddInstalledApp adds an app to the installed apps list if it's not already there

func CheckEnvironmentConfigurations

func CheckEnvironmentConfigurations() []string

CheckEnvironmentConfigurations checks local environment configurations

func CreateDirectories

func CreateDirectories() error

CreateDirectories creates necessary directories for anvil

func GenerateDefaultSettings

func GenerateDefaultSettings() error

GenerateDefaultSettings generates the default settings.yaml file

func GenerateDefaultSettingsWithVersion

func GenerateDefaultSettingsWithVersion(version string) error

GenerateDefaultSettingsWithVersion generates the default settings.yaml file with a specific version

func GetAnvilConfigDirectory

func GetAnvilConfigDirectory() string

GetAnvilConfigDirectory returns the path to the anvil config directory

func GetAnvilConfigPath

func GetAnvilConfigPath() string

GetAnvilConfigPath returns the path to the anvil config file

func GetAppConfigPath

func GetAppConfigPath(appName string) (string, bool, error)

GetAppConfigPath checks if an app has a configured local path in the configs section

func GetAvailableGroups

func GetAvailableGroups() (map[string][]string, error)

GetAvailableGroups returns all available groups

func GetBuiltInGroups

func GetBuiltInGroups() []string

GetBuiltInGroups returns the list of built-in group names

func GetConfiguredApps

func GetConfiguredApps() ([]string, error)

GetConfiguredApps returns a list of all apps that have configured paths

func GetGroupTools

func GetGroupTools(groupName string) ([]string, error)

GetGroupTools returns the tools for a specific group

func GetInstalledApps

func GetInstalledApps() ([]string, error)

GetInstalledApps returns the list of individually installed applications

func GetTempAppPath

func GetTempAppPath(appName string) (string, bool, error)

GetTempAppPath checks if an app directory exists in the temp directory (from previous pull)

func IsAppTracked

func IsAppTracked(appName string) (bool, error)

IsAppTracked checks if an app is being tracked in any category

func IsBuiltInGroup

func IsBuiltInGroup(groupName string) bool

IsBuiltInGroup checks if a group name is a built-in group

func PopulateGitConfigFromSystem

func PopulateGitConfigFromSystem(gitConfig *GitConfig) error

PopulateGitConfigFromSystem populates git configuration from local git settings and auto-detects SSH keys

func RemoveInstalledApp

func RemoveInstalledApp(appName string) error

RemoveInstalledApp removes an app from the installed apps list

func SaveConfig

func SaveConfig(config *AnvilConfig) error

SaveConfig saves the anvil configuration to settings.yaml

func SetAppConfigPath

func SetAppConfigPath(appName, configPath string) error

SetAppConfigPath sets the config path for an app in the configs section

func UpdateGroupTools

func UpdateGroupTools(groupName string, tools []string) error

UpdateGroupTools updates the tools list for an existing group

func ValidateAndFixGitHubConfig

func ValidateAndFixGitHubConfig(config *AnvilConfig) bool

ValidateAndFixGitHubConfig validates and automatically fixes GitHub configuration

func ValidateFileAccess

func ValidateFileAccess(filePath string) error

ValidateFileAccess validates that a file exists and is accessible

Types

type AnvilConfig

type AnvilConfig struct {
	Version string            `yaml:"version"`
	Tools   AnvilTools        `yaml:"tools"`
	Groups  AnvilGroups       `yaml:"groups"`
	Configs map[string]string `yaml:"configs"` // Maps app names to their local config paths
	Sources map[string]string `yaml:"sources"` // Maps app names to their download URLs
	Git     GitConfig         `yaml:"git"`
	GitHub  GitHubConfig      `yaml:"github"`
}

AnvilConfig represents the main anvil configuration

func LoadConfig

func LoadConfig() (*AnvilConfig, error)

LoadConfig loads the anvil configuration from settings.yaml

func LoadSampleConfig

func LoadSampleConfig() (*AnvilConfig, error)

LoadSampleConfig loads the sample configuration from the assets file

func LoadSampleConfigWithVersion

func LoadSampleConfigWithVersion(version string) (*AnvilConfig, error)

LoadSampleConfigWithVersion loads the sample configuration with a specific version

type AnvilGroups

type AnvilGroups map[string][]string

AnvilGroups represents grouped tool configurations

type AnvilTools

type AnvilTools struct {
	RequiredTools []string `yaml:"required_tools"`
	InstalledApps []string `yaml:"installed_apps"` // Tracks individually installed applications
}

AnvilTools represents tool configurations

type ConfigValidator

type ConfigValidator struct {
	// contains filtered or unexported fields
}

ConfigValidator implements the Validator interface for configuration validation

func (*ConfigValidator) ValidateAppName

func (cv *ConfigValidator) ValidateAppName(appName string) error

ValidateAppName validates an application name

func (*ConfigValidator) ValidateConfig

func (cv *ConfigValidator) ValidateConfig(config interface{}) error

ValidateConfig validates the entire configuration

func (*ConfigValidator) ValidateFont

func (cv *ConfigValidator) ValidateFont(font string) error

ValidateFont validates a font name

func (*ConfigValidator) ValidateGroupName

func (cv *ConfigValidator) ValidateGroupName(groupName string) error

ValidateGroupName validates a group name

type GitConfig

type GitConfig struct {
	Username   string `yaml:"username"`
	Email      string `yaml:"email"`
	SSHKeyPath string `yaml:"ssh_key_path,omitempty"` // Reference to SSH private key
}

GitConfig represents git configuration

type GitHubConfig

type GitHubConfig struct {
	ConfigRepo  string `yaml:"config_repo"`             // GitHub repository URL for configs (e.g., "username/dotfiles")
	Branch      string `yaml:"branch"`                  // Branch to use (default: "main")
	LocalPath   string `yaml:"local_path"`              // Local path where configs are stored/synced
	Token       string `yaml:"token,omitempty"`         // GitHub token (use env var reference)
	TokenEnvVar string `yaml:"token_env_var,omitempty"` // Environment variable name for token
}

GitHubConfig represents GitHub repository configuration for config sync

type LocationSource

type LocationSource int

LocationSource represents where an app config location was found

const (
	LocationConfigs LocationSource = iota // Found in configs section of settings.yaml
	LocationTemp                          // Found in temp directory (pulled but not configured)
)

func ResolveAppLocation

func ResolveAppLocation(appName string) (string, LocationSource, error)

ResolveAppLocation finds the config location for an app following the priority order

func (LocationSource) String

func (ls LocationSource) String() string

String returns a string representation of the location source

type Validator

type Validator interface {
	ValidateGroupName(groupName string) error
	ValidateAppName(appName string) error
	ValidateFont(font string) error
	ValidateConfig(config interface{}) error
}

Validator defines the interface for input validation

func NewConfigValidator

func NewConfigValidator(config *AnvilConfig) Validator

NewConfigValidator creates a new configuration validator

Jump to

Keyboard shortcuts

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