Documentation ¶
Index ¶
- Constants
- Variables
- func AuthTokenFromEnv(hostname string) (string, string)
- func AuthTokenProvidedFromEnv() bool
- func ConfigDir() string
- func ConfigFile() string
- func HomeDirPath(subdir string) (string, error)
- func HostsConfigFile() string
- func NewBlankRoot() *yaml.Node
- func ValidateKey(key string) error
- func ValidateValue(key, value string) error
- type AliasConfig
- type Config
- type ConfigEntry
- type ConfigMap
- type ConfigOption
- type HostConfig
- type InvalidValueError
- type NotFoundError
- type ReadOnlyEnvError
Constants ¶
View Source
const ( GH_HOST = "GH_HOST" GH_TOKEN = "GH_TOKEN" GITHUB_TOKEN = "GITHUB_TOKEN" GH_ENTERPRISE_TOKEN = "GH_ENTERPRISE_TOKEN" GITHUB_ENTERPRISE_TOKEN = "GITHUB_ENTERPRISE_TOKEN" )
View Source
const (
GH_CONFIG_DIR = "GH_CONFIG_DIR"
)
Variables ¶
View Source
var BackupConfigFile = func(filename string) error { return os.Rename(filename, filename+".bak") }
View Source
var ReadConfigFile = func(filename string) ([]byte, error) { f, err := os.Open(filename) if err != nil { return nil, pathError(err) } defer f.Close() data, err := io.ReadAll(f) if err != nil { return nil, err } return data, nil }
View Source
var WriteConfigFile = func(filename string, data []byte) error { err := os.MkdirAll(filepath.Dir(filename), 0771) if err != nil { return pathError(err) } cfgFile, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } defer cfgFile.Close() _, err = cfgFile.Write(data) return err }
Functions ¶
func AuthTokenFromEnv ¶
func AuthTokenProvidedFromEnv ¶
func AuthTokenProvidedFromEnv() bool
func ConfigFile ¶
func ConfigFile() string
func HomeDirPath ¶
func HostsConfigFile ¶
func HostsConfigFile() string
func NewBlankRoot ¶
func NewBlankRoot() *yaml.Node
func ValidateKey ¶
func ValidateValue ¶
Types ¶
type AliasConfig ¶
func (*AliasConfig) Add ¶
func (a *AliasConfig) Add(alias, expansion string) error
func (*AliasConfig) All ¶
func (a *AliasConfig) All() map[string]string
func (*AliasConfig) Delete ¶
func (a *AliasConfig) Delete(alias string) error
type Config ¶
type Config interface { Get(string, string) (string, error) GetWithSource(string, string) (string, string, error) Set(string, string, string) error UnsetHost(string) Hosts() ([]string, error) DefaultHost() (string, error) DefaultHostWithSource() (string, string, error) Aliases() (*AliasConfig, error) CheckWriteable(string, string) error Write() error }
Config This interface describes interacting with some persistent configuration for gh.
func InheritEnv ¶
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 ParseDefaultConfig ¶
type ConfigEntry ¶
type ConfigEntry struct { KeyNode *yaml.Node ValueNode *yaml.Node Index int }
type ConfigMap ¶
type ConfigMap struct {
Root *yaml.Node
}
ConfigMap This 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 ConfigOption ¶
type ConfigOption struct { Key string Description string DefaultValue string AllowedValues []string }
func ConfigOptions ¶
func ConfigOptions() []ConfigOption
type HostConfig ¶
type InvalidValueError ¶
type InvalidValueError struct {
ValidValues []string
}
func (InvalidValueError) Error ¶
func (e InvalidValueError) Error() string
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
type ReadOnlyEnvError ¶
type ReadOnlyEnvError struct {
Variable string
}
func (*ReadOnlyEnvError) Error ¶
func (e *ReadOnlyEnvError) Error() string
Click to show internal directories.
Click to hide internal directories.