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 MigrateOldConfig() error
- func NewBlankRoot() *yaml.Node
- func OldLocalConfigFile() string
- func Prompt(question, defaultVal string) (envVal string, err 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
var ReadConfigFile = func(filename string) ([]byte, error) { data, err := ioutil.ReadFile(filename) if err != nil { return nil, pathError(err) } return data, nil }
var WriteConfigFile = func(filename string, data []byte) error { err := os.MkdirAll(path.Dir(filename), 0o750) if err != nil { return pathError(err) } _, err = ioutil.ReadFile(filename) if err != nil && !os.IsNotExist(err) { return err } err = WriteFile(filename, data, 0o600) return err }
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 has been set. It returns the value, which will be empty if the variable is not present.
func GetFromEnvWithSource ¶
func MigrateOldConfig ¶
func MigrateOldConfig() error
MigrateOldConfig migrates the old aliases and configuration
func NewBlankRoot ¶
func NewBlankRoot() *yaml.Node
func OldLocalConfigFile ¶
func OldLocalConfigFile() string
OldLocalConfigFile returns the path to the old local config path.
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 }
This interface describes interacting with some 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 ¶
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
}