Documentation
¶
Overview ¶
Package config is a set of types for interacting with the azdo configuration files. Note: This package is intended for use only in azdo, any other use cases are subject to breakage and non-backwards compatible updates.
Index ¶
- Constants
- Variables
- func DataDir() string
- func DetermineEditor(cfg Config) (string, error)
- func Dir() string
- func HomeDirPath(subdir string) (string, error)
- func ReadFromString(str string) *configData
- func StateDir() string
- func Write(c *configData) error
- type AliasConfig
- type AuthConfig
- type Config
- type InvalidConfigFileError
- type KeyNotFoundError
- type Option
Constants ¶
const ( Aliases = "aliases" Organizations = "organizations" Defaults = "defaults" Pat = "pat" )
Variables ¶
var Read = func() (*configData, error) {
once.Do(func() {
instance, errLoad = load(generalConfigFile(), organizationsConfigFile())
})
return instance, errLoad
}
Read azdo configuration files from the local file system and return a configData.
Functions ¶
func DataDir ¶
func DataDir() string
Data path precedence: XDG_DATA_HOME, LocalAppData (windows only), HOME.
func DetermineEditor ¶
func Dir ¶ added in v0.0.2
func Dir() string
configData path precedence: AZDO_CONFIG_DIR, XDG_CONFIG_HOME, AppData (windows only), HOME.
func HomeDirPath ¶
func ReadFromString ¶
func ReadFromString(str string) *configData
ReadFromString takes a yaml string and returns a configData. Note: This is only used for testing, and should not be relied upon in production.
Types ¶
type AliasConfig ¶
type AuthConfig ¶
type AuthConfig interface { GetURL(organizationName string) (string, error) GetGitProtocol(organizationName string) (string, error) GetDefaultOrganization() (string, error) SetDefaultOrganization(organizationName string) error GetOrganizations() []string GetToken(organizationName string) (string, error) Login(organizationName, organizationURL, token, gitProtocol string, secureStorage bool) error Logout(organizationName string) error }
type Config ¶
type Config interface { Keys([]string) ([]string, error) Get([]string) (string, error) GetOrDefault([]string) (string, error) Set([]string, string) Remove([]string) error Write() error Authentication() AuthConfig Aliases() AliasConfig }
This interface describes interacting with some persistent configuration for azdo.
type InvalidConfigFileError ¶
InvalidConfigFileError represents an error when trying to read a config file.
func (*InvalidConfigFileError) Error ¶
func (e *InvalidConfigFileError) Error() string
Allow InvalidConfigFileError to satisfy error interface.
func (*InvalidConfigFileError) Unwrap ¶
func (e *InvalidConfigFileError) Unwrap() error
Allow InvalidConfigFileError to be unwrapped.
type KeyNotFoundError ¶
type KeyNotFoundError struct {
Key string
}
KeyNotFoundError represents an error when trying to find a config key that does not exist.
func (*KeyNotFoundError) Error ¶
func (e *KeyNotFoundError) Error() string
Allow KeyNotFoundError to satisfy error interface.
func (*KeyNotFoundError) Is ¶ added in v0.0.2
func (e *KeyNotFoundError) Is(err error) bool