config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 8 Imported by: 0

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

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

func (m *Manager) ComposeConfig() error

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

func (m *Manager) ConfigureShell() error

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

func (m *Manager) GetActiveConfig() *schema.Config

GetActiveConfig returns the current active configuration.

func (*Manager) GetProjectConfig

func (m *Manager) GetProjectConfig() *schema.Config

GetProjectConfig returns the current project configuration.

func (*Manager) GetTeamConfig

func (m *Manager) GetTeamConfig(name string) *schema.Config

GetTeamConfig returns a team configuration by name.

func (*Manager) GetUserConfig

func (m *Manager) GetUserConfig() *schema.Config

GetUserConfig returns the current user configuration.

func (*Manager) InstallPackage

func (m *Manager) InstallPackage(pkg string) error

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

func (m *Manager) LoadProjectConfig() error

LoadProjectConfig loads a project configuration from the current directory.

func (*Manager) LoadTeamConfig

func (m *Manager) LoadTeamConfig(name string) error

LoadTeamConfig loads a team configuration by name from disk.

func (*Manager) LoadUserConfig

func (m *Manager) LoadUserConfig() error

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

func (s *Service) ApplyConfig() error

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

func (s *Service) GetActiveConfig() (*schema.Config, error)

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

func (s *Service) GetConfig(configType schema.ConfigType, name string) (*schema.Config, error)

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

func (s *Service) InitConfig() error

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

func (s *Service) ListConfigs() ([]*schema.Config, error)

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

func (s *Service) SaveConfig(config *schema.Config) error

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

func (s *Service) UninstallConfig() error

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.

Jump to

Keyboard shortcuts

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