Documentation
¶
Overview ¶
Package config provides functionality related to storing application-wide configuration data.
Configuration data stored should not be specific to a given repository/project.
Index ¶
Constants ¶
const EnvOnlyPrefix = "(env) "
EnvOnlyPrefix is the prefix used to mark environment-only configuration options
Variables ¶
This section is empty.
Functions ¶
func GetUserConfigDir ¶
GetUserConfigDir returns the config directory for storing user wide configuration data.
The config directory is guaranteed to exist, otherwise an error is returned.
func GetUserConfigFilePath ¶
Gets the local file system path to the Azd configuration file
Types ¶
type Config ¶
type Config interface {
Raw() map[string]any
// similar to Raw() but it will resolve any vault references
ResolvedRaw() map[string]any
// Get retrieves the value stored at the specified path
Get(path string) (any, bool)
// GetString retrieves the value stored at the specified path as a string
GetString(path string) (string, bool)
// GetSection retrieves the value stored at the specified path and unmarshals it into the provided section
GetSection(path string, section any) (bool, error)
// GetMap retrieves the map stored at the specified path
GetMap(path string) (map[string]any, bool)
// GetSlice retrieves the slice stored at the specified path
GetSlice(path string) ([]any, bool)
// Set stores the value at the specified path
Set(path string, value any) error
// SetSecret stores the secrets at the specified path within a local user vault
SetSecret(path string, value string) error
// Unset removes the value stored at the specified path
Unset(path string) error
// IsEmpty returns a value indicating whether the configuration is empty
IsEmpty() bool
}
Azd configuration for the current user Configuration data is stored in user's home directory @ ~/.azd/config.json
func NewConfig ¶
NewConfig creates a configuration object, populated with an initial set of keys and values. If [data] is nil or an empty map, and empty configuration object is returned, but NewEmptyConfig might better express your intention.
func NewEmptyConfig ¶
func NewEmptyConfig() Config
NewEmptyConfig creates a empty configuration object.
type ConfigOption ¶
type ConfigOption struct {
Key string `yaml:"key"`
Description string `yaml:"description"`
Type string `yaml:"type"`
AllowedValues []string `yaml:"allowedValues,omitempty"`
Example string `yaml:"example,omitempty"`
EnvVar string `yaml:"envVar,omitempty"`
}
ConfigOption defines a configuration setting that can be set in azd config
func GetAllConfigOptions ¶
func GetAllConfigOptions() []ConfigOption
GetAllConfigOptions returns all available configuration options
type FileConfigManager ¶
type FileConfigManager interface {
// Saves the azd configuration to the specified file path
// Path is automatically created if it does not exist
Save(config Config, filePath string) error
// Loads azd configuration from the specified file path
Load(filePath string) (Config, error)
}
FileConfigManager provides the ability to load, parse and save azd configuration files
func NewFileConfigManager ¶
func NewFileConfigManager(configManager Manager) FileConfigManager
NewFileConfigManager creates a new FileConfigManager instance
type Manager ¶
type UserConfigManager ¶
func NewUserConfigManager ¶
func NewUserConfigManager(configManager FileConfigManager) UserConfigManager