config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 14 Imported by: 0

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

View Source
const (
	Aliases       = "aliases"
	Organizations = "organizations"
	Defaults      = "defaults"
	Pat           = "pat"
)

Variables

View Source
var (
	ErrURLNotFoundForOrganization = errors.New("failed to get URL for organization")
	ErrOrganizationNotFound       = errors.New("organization not found")
	ErrDefaultOrganizationNotSet  = errors.New("no default organization defined")
)

Functions

func DataDir

func DataDir() string

Data path precedence: XDG_DATA_HOME, LocalAppData (windows only), HOME.

func DetermineEditor

func DetermineEditor(cfg Config) (string, error)

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 HomeDirPath(subdir string) (string, error)

func Read

func Read() (*yamlmap.Map, error)

Read azdo configuration files from the local file system and return a configData.

func ReadFromString

func ReadFromString(str string) (*yamlmap.Map, error)

ReadFromString takes a yaml string and returns a configData. Note: This is only used for testing, and should not be relied upon in production.

func StateDir

func StateDir() string

State path precedence: XDG_STATE_HOME, LocalAppData (windows only), HOME.

func Write

func Write(c *configData) error

Write azdo configuration files to the local file system. It will only write azdo configuration files that have been modified since last being read.

Types

type AliasConfig

type AliasConfig interface {
	Get(string) (string, error)
	Add(string, string) error
	Delete(string) error
	All() map[string]string
}

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.

func NewConfig

func NewConfig() (Config, error)

func NewConfigWithReader added in v0.5.0

func NewConfigWithReader(rd ConfigReader) (Config, error)

type ConfigReader added in v0.5.0

type ConfigReader interface {
	Read() (*yamlmap.Map, error)
}

func NewStringConfigReader added in v0.5.0

func NewStringConfigReader(str string) (ConfigReader, error)

type InvalidConfigFileError

type InvalidConfigFileError struct {
	Path string
	Err  error
}

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.

type Option added in v0.0.2

type Option struct {
	Key           string
	Description   string
	DefaultValue  string
	AllowedValues []string
}

func Options added in v0.0.2

func Options() []Option

Jump to

Keyboard shortcuts

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