Documentation
¶
Overview ¶
Package config provides configuration management functionality for Nix Foundry. It handles loading, saving, and applying configuration settings across different scopes including user, team, and project configurations.
Package config provides configuration management functionality for Nix Foundry. It handles configuration loading, composition, and inheritance.
Package config provides configuration management functionality for Nix Foundry. It handles all aspects of configuration including initialization, saving, applying, and merging of configurations across different scopes (user, team, project).
Index ¶
- type Manager
- func (m *Manager) ComposeConfig() error
- func (m *Manager) ConfigureShell() error
- func (m *Manager) GetActiveConfig() *schema.Config
- func (m *Manager) GetProjectConfig() *schema.Config
- func (m *Manager) GetTeamConfig(name string) *schema.Config
- func (m *Manager) GetUserConfig() *schema.Config
- func (m *Manager) InstallPackage(pkg string) error
- func (m *Manager) LoadProjectConfig() error
- func (m *Manager) LoadTeamConfig(name string) error
- func (m *Manager) LoadUserConfig() error
- type Service
- func (s *Service) ApplyConfig() error
- func (s *Service) GetActiveConfig() (*schema.Config, error)
- func (s *Service) GetConfig(configType schema.ConfigType, name string) (*schema.Config, error)
- func (s *Service) InitConfig() error
- func (s *Service) InitConfigWithType(configType schema.ConfigType, name string) error
- func (s *Service) ListConfigs() ([]*schema.Config, error)
- func (s *Service) SaveConfig(config *schema.Config) error
- func (s *Service) UninstallConfig() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles configuration loading, composition, and inheritance. It manages user, team, and project configurations, handling their relationships and merging them according to inheritance rules.
func NewManager ¶
func NewManager() *Manager
NewManager creates a new configuration manager with initialized maps.
func (*Manager) ComposeConfig ¶
ComposeConfig creates the active configuration by merging configs based on inheritance. It follows the inheritance chain from project to team to user config, with each level overriding settings from the previous level.
func (*Manager) ConfigureShell ¶
ConfigureShell configures the shell based on the active configuration. It sets up the shell environment with Nix-specific configurations and ensures the shell's configuration directory exists.
func (*Manager) GetActiveConfig ¶
GetActiveConfig returns the current active configuration.
func (*Manager) GetProjectConfig ¶
GetProjectConfig returns the current project configuration.
func (*Manager) GetTeamConfig ¶
GetTeamConfig returns a team configuration by name.
func (*Manager) GetUserConfig ¶
GetUserConfig returns the current user configuration.
func (*Manager) InstallPackage ¶
InstallPackage installs a package using the configured package manager. It uses the active configuration to determine which package manager to use and how to install the package.
func (*Manager) LoadProjectConfig ¶
LoadProjectConfig loads a project configuration from the current directory.
func (*Manager) LoadTeamConfig ¶
LoadTeamConfig loads a team configuration by name from disk.
func (*Manager) LoadUserConfig ¶
LoadUserConfig loads the user's configuration from disk. If no configuration exists, it creates a default one.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides configuration management functionality for Nix Foundry. It handles all aspects of configuration including initialization, saving, applying, and merging of configurations across different scopes (user, team, project).
func GetConfigService ¶
func GetConfigService() *Service
GetConfigService creates and returns a new configuration service instance. It initializes the service with a default OS filesystem implementation, enabling configuration operations on the local system.
func NewService ¶
func NewService(fs filesystem.FileSystem) *Service
NewService creates a new configuration service with the provided filesystem implementation. The filesystem abstraction allows for flexible storage backends and easier testing.
func (*Service) ApplyConfig ¶
ApplyConfig applies the active configuration to the system. This includes: 1. Configuring the shell environment if specified in user config 2. Installing all required packages (core and optional) 3. Running any configured scripts
Returns an error if any step of the application process fails.
func (*Service) GetActiveConfig ¶
GetActiveConfig returns the active configuration for the current context. It performs the following steps: 1. Loads the user configuration 2. If the user config extends a team config, merges them 3. If the resulting config extends a project config, merges that as well
The merging follows the override principle where later configs take precedence over earlier ones in the chain.
func (*Service) GetConfig ¶
GetConfig retrieves a specific configuration by type and name. It handles loading of user, team, and project configurations from their respective locations in the filesystem. Returns an error if the configuration cannot be found or cannot be parsed.
func (*Service) InitConfig ¶
InitConfig initializes a new user configuration with default settings. It creates the necessary directory structure and configuration file if they don't exist. Returns an error if the configuration already exists or if there are any filesystem operations failures.
func (*Service) InitConfigWithType ¶
func (s *Service) InitConfigWithType(configType schema.ConfigType, name string) error
InitConfigWithType initializes a new configuration of the specified type (team or project). It creates the necessary directory structure and configuration file with default settings appropriate for the specified type. Returns an error if the configuration already exists or if there are any filesystem operation failures.
func (*Service) ListConfigs ¶
ListConfigs returns a list of all available configurations across all scopes. It searches for and loads: 1. User configuration from ~/.config/nix-foundry/config.yaml 2. Team configurations from ~/.config/nix-foundry/teams/ 3. Project configuration from ./.nix-foundry/config.yaml
Returns the list of found configurations and any error encountered during the search.
func (*Service) SaveConfig ¶
SaveConfig persists a configuration to disk in the appropriate location based on its type. The configuration is saved as YAML and the appropriate directory structure is created if it doesn't exist. The location depends on the configuration type: - UserConfig: ~/.config/nix-foundry/config.yaml - TeamConfig: ~/.config/nix-foundry/teams/<name>.yaml - ProjectConfig: ./.nix-foundry/config.yaml
func (*Service) UninstallConfig ¶
UninstallConfig removes all Nix Foundry configuration files and directories. This includes: 1. User configuration directory (~/.config/nix-foundry) 2. Project configuration directory (./.nix-foundry)
Returns an error if any deletion operation fails.