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) string
- func GetFromEnvWithSource(key string) (string, string)
- func GitDir(preferRelative bool) []string
- func HasSecurePerms(m fs.FileMode) bool
- func NewBlankRoot() *yaml.Node
- func ParseConfigFile(filename string) ([]byte, *yaml.Node, error)
- func ResolveCustomHeaders(cfg Config, hostname string) (map[string]string, error)
- func SearchConfigFile() (string, error)
- func StubConfig(main, aliases string) func()
- func StubWriteConfig(wc io.Writer, wh io.Writer) func()
- func TrimmedFileContents(filePath string) (string, error)
- func WriteFile(filename string, data []byte, perm os.FileMode) error
- type AliasConfig
- type Config
- type ConfigEntry
- type ConfigMap
- type CustomHeader
- 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 append(GitDir(true), "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 filepath.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 ConfigDir ¶
func ConfigDir() string
ConfigDir returns the config directory for writing configuration. It respects GLAB_CONFIG_DIR as the highest priority override, otherwise uses XDG_CONFIG_HOME (defaulting to ~/.config).
func ConfigFile ¶
func ConfigFile() string
ConfigFile returns the config file path. It respects GLAB_CONFIG_DIR as the highest priority override, otherwise returns the XDG-compliant user config file path. This function only determines the path without creating directories.
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 GitDir ¶ added in v1.59.0
for later use we might prefer relative paths GitDir will find a directory or just return ".git"
func HasSecurePerms ¶ added in v1.44.0
func NewBlankRoot ¶
func NewBlankRoot() *yaml.Node
func ParseConfigFile ¶ added in v1.29.0
func ResolveCustomHeaders ¶ added in v1.73.1
ResolveCustomHeaders is a helper function that works with the Config interface
func SearchConfigFile ¶ added in v1.75.0
SearchConfigFile searches for an existing config file across all XDG config paths. It respects GLAB_CONFIG_DIR as the highest priority override. Search order: 1. $GLAB_CONFIG_DIR/config.yml (if GLAB_CONFIG_DIR is set) 2. $XDG_CONFIG_HOME/glab-cli/config.yml (default: ~/.config/glab-cli/config.yml) 3. $XDG_CONFIG_DIRS/glab-cli/config.yml (default: /etc/xdg/glab-cli/config.yml)
Returns the path to the first config file found, or an error if none exist.
func StubConfig ¶
func StubConfig(main, aliases string) func()
func TrimmedFileContents ¶ added in v1.54.0
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
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) RemoveEntry ¶
func (*ConfigMap) SetStringValue ¶
type CustomHeader ¶ added in v1.73.1
type CustomHeader struct {
Name string `yaml:"name"`
Value string `yaml:"value,omitempty"`
ValueFromEnv string `yaml:"valueFromEnv,omitempty"`
}
CustomHeader represents a single custom HTTP header configuration
func (*CustomHeader) ResolvedValue ¶ added in v1.73.1
func (h *CustomHeader) ResolvedValue() (string, error)
ResolvedValue returns the actual header value, resolving environment variables if needed
type HostConfig ¶
HostConfig represents the configuration for a single host.
func (*HostConfig) GetCustomHeaders ¶ added in v1.73.1
func (hc *HostConfig) GetCustomHeaders() ([]CustomHeader, error)
GetCustomHeaders returns the custom headers for a specific 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.