config

package
v0.0.0-...-b055b18 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 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(path string) (any, bool)
	GetString(path string) (string, bool)
	GetSection(path string, section any) (bool, error)
	Set(path string, value any) error
	SetSecret(path string, value string) error
	Unset(path string) error
	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