Documentation ¶
Index ¶
- Variables
- func CheckFileExists(filename string) bool
- func CheckPathExists(path string) bool
- func ConfigDir() string
- func ConfigFile() string
- func ConfigKeyEquivalence(key string) string
- func EnvKeyEquivalence(key string) []string
- func GetFromEnv(key string) (value string)
- func GetFromEnvWithSource(key string) (value, source string)
- func NewBlankRoot() *yaml.Node
- func ParseConfigFile(filename string) ([]byte, *yaml.Node, error)
- func StubConfig(main, aliases string) func()
- func StubWriteConfig(wc io.Writer, wh io.Writer) func()
- func WriteFile(filename string, data []byte, perm os.FileMode) error
- type AliasConfig
- type Config
- type ConfigEntry
- type ConfigMap
- type HostConfig
- type LocalConfig
- type NotFoundError
Constants ¶
This section is empty.
Variables ¶
var BackupConfigFile = func(filename string) error { return os.Rename(filename, filename+".bak") }
BackupConfigFile creates a backup of the provided config file
var LocalConfigDir = func() []string { return []string{".git", "glab-cli"} }
LocalConfigDir returns the local config path in map which must be joined for complete path
var LocalConfigFile = func() string { configFile := append(LocalConfigDir(), "config.yml") return path.Join(configFile...) }
LocalConfigFile returns the config file name with full path
Functions ¶
func CheckFileExists ¶
CheckFileExists : checks if a file exists and is not a directory.
func CheckPathExists ¶
CheckPathExists checks if a folder exists and is a directory
func ConfigKeyEquivalence ¶
ConfigKeyEquivalence returns the equivalent key that's actually used in the config file
func EnvKeyEquivalence ¶
EnvKeyEquivalence returns the equivalent key that's used for environment variables
func GetFromEnv ¶
GetFromEnv is just a wrapper for os.GetEnv but checks for matching names used in previous glab versions and retrieves the value of the environment if any of the matching names have been set. It returns the value, which will be empty if the variable is not present.
func GetFromEnvWithSource ¶
GetFromEnvWithSource works like GetFromEnv but also returns the name of the environment variable that was set as the source.
func NewBlankRoot ¶
func NewBlankRoot() *yaml.Node
func ParseConfigFile ¶ added in v1.29.0
func StubConfig ¶
func StubConfig(main, aliases string) func()
Types ¶
type AliasConfig ¶
func (*AliasConfig) All ¶
func (a *AliasConfig) All() map[string]string
func (*AliasConfig) Delete ¶
func (a *AliasConfig) Delete(alias string) error
func (*AliasConfig) Set ¶
func (a *AliasConfig) Set(alias, expansion string) error
func (*AliasConfig) Write ¶
func (a *AliasConfig) Write() error
type Config ¶
type Config interface { Get(string, string) (string, error) GetWithSource(string, string, bool) (string, string, error) Set(string, string, string) error UnsetHost(string) Hosts() ([]string, error) Aliases() (*AliasConfig, error) Local() (*LocalConfig, error) // Write writes to the config.yml file Write() error // WriteAll saves all the available configuration file types WriteAll() error }
A Config reads and writes persistent configuration for glab.
func NewBlankConfig ¶
func NewBlankConfig() Config
NewBlankConfig initializes a config file pre-populated with comments and default values
func NewFromString ¶
NewFromString initializes a Config from a yaml string
func ParseConfig ¶
func ParseDefaultConfig ¶
type ConfigEntry ¶
type ConfigEntry struct { KeyNode *yaml.Node ValueNode *yaml.Node Index int }
type ConfigMap ¶
type ConfigMap struct {
Root *yaml.Node
}
ConfigMap type implements a low-level get/set config that is backed by an in-memory tree of YAML nodes. It allows us to interact with a YAML-based config programmatically, preserving any comments that were present when the YAML was parsed.
func (*ConfigMap) FindEntry ¶
func (cm *ConfigMap) FindEntry(key string) (ce *ConfigEntry, err error)
func (*ConfigMap) RemoveEntry ¶
func (*ConfigMap) SetStringValue ¶
type HostConfig ¶
HostConfig represents the configuration for a single host.
type LocalConfig ¶
func (*LocalConfig) All ¶
func (a *LocalConfig) All() map[string]string
func (*LocalConfig) Delete ¶
func (a *LocalConfig) Delete(key string) error
func (*LocalConfig) Set ¶
func (a *LocalConfig) Set(key, value string) error
func (*LocalConfig) Write ¶
func (a *LocalConfig) Write() error
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError is returned when a config entry is not found.