config

package
v0.0.0-...-6cd82ae Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 13 Imported by: 0

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

This section is empty.

Variables

This section is empty.

Functions

func GetUserConfigDir

func GetUserConfigDir() (string, error)

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

func GetUserConfigFilePath() (string, error)

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

func NewConfig(data map[string]any) Config

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.

func Parse

func Parse(configJson []byte) (Config, error)

Parses azd configuration JSON and returns a Config instance

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 Manager interface {
	Save(config Config, writer io.Writer) error
	Load(io.Reader) (Config, error)
}

func NewManager

func NewManager() Manager

Creates a new Configuration Manager

type UserConfigManager

type UserConfigManager interface {
	Save(Config) error
	Load() (Config, error)
}

func NewUserConfigManager

func NewUserConfigManager(configManager FileConfigManager) UserConfigManager

Jump to

Keyboard shortcuts

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