Documentation
¶
Index ¶
- Constants
- Variables
- func AuthTokenFromEnv(hostname string) (string, string)
- func AuthTokenProvidedFromEnv() bool
- func ClusterDir() string
- func ClusterFile() string
- func DataDir() string
- func HomeDirPath(subdir string) (string, error)
- func HostsClusterFile() string
- func IsEnterpriseEnv(src string) bool
- func IsHostEnv(src string) bool
- func NewBlankRoot() *yaml.Node
- func StateDir() string
- func StubBackupCluster() func()
- func StubWriteCluster(wc io.Writer, wh io.Writer) func()
- func ValidateKey(key string) error
- func ValidateValue(key, value string) error
- type Cluster
- type ClusterEntry
- type ClusterMap
- type ClusterOption
- type ClusterStub
- func (c ClusterStub) CheckWriteable(host, key string) error
- func (c ClusterStub) DefaultHost() (string, error)
- func (c ClusterStub) DefaultHostWithSource() (string, string, error)
- func (c ClusterStub) Get(host, key string) (string, error)
- func (c ClusterStub) GetWithSource(host, key string) (string, string, error)
- func (c ClusterStub) Hosts() ([]string, error)
- func (c ClusterStub) Set(host, key, value string) error
- func (c ClusterStub) UnsetHost(hostname string)
- func (c ClusterStub) Write() error
- type HostCluster
- type InvalidValueError
- type NotFoundError
- type ReadOnlyEnvError
Constants ¶
View Source
const ( CONFIG_DIR = "CONFIG_DIR" XDG_CONFIG_HOME = "XDG_CONFIG_HOME" XDG_STATE_HOME = "XDG_STATE_HOME" XDG_DATA_HOME = "XDG_DATA_HOME" APP_DATA = "AppData" // (windows only) LOCAL_APP_DATA = "LocalAppData" // (windows only) )
View Source
const ( SM_GH_HOST = "SM_GH_HOST" SM_GH_TOKEN = "SM_GH_TOKEN" SM_GITHUB_TOKEN = "SM_GITHUB_TOKEN" SM_GH_ENTERPRISE_TOKEN = "SM_GH_ENTERPRISE_TOKEN" SM_GITHUB_ENTERPRISE_TOKEN = "SM_GITHUB_ENTERPRISE_TOKEN" )
Variables ¶
View Source
var BackupClusterFile = func(filename string) error { return os.Rename(filename, filename+".bak") }
View Source
var ReadClusterFile = func(filename string) ([]byte, error) { f, err := os.Open(filename) if err != nil { return nil, pathError(err) } defer f.Close() data, err := ioutil.ReadAll(f) if err != nil { return nil, err } return data, nil }
View Source
var WriteClusterFile = 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 ClusterDir ¶
func ClusterDir() string
Cluster path precedence 1. CONFIG_DIR 2. XDG_CONFIG_HOME 3. AppData (windows only) 4. HOME
func ClusterFile ¶
func ClusterFile() string
func DataDir ¶
func DataDir() string
Data path precedence 1. XDG_DATA_HOME 2. LocalAppData (windows only) 3. HOME
func HomeDirPath ¶
func HostsClusterFile ¶
func HostsClusterFile() string
func IsEnterpriseEnv ¶
func NewBlankRoot ¶
func StateDir ¶
func StateDir() string
State path precedence 1. XDG_CONFIG_HOME 2. LocalAppData (windows only) 3. HOME
func StubBackupCluster ¶
func StubBackupCluster() func()
func ValidateKey ¶
func ValidateValue ¶
Types ¶
type Cluster ¶
type Cluster 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) CheckWriteable(string, string) error Write() error }
func InheritEnv ¶
func NewBlankCluster ¶
func NewBlankCluster() Cluster
NewBlankCluster initializes a cluster file pre-populated with comments and default values
func NewCluster ¶
func NewFromString ¶
NewFromString initializes a Cluster from a yaml string
func ParseDefaultCluster ¶
type ClusterEntry ¶
type ClusterEntry struct { KeyNode *yaml.Node ValueNode *yaml.Node Index int }
type ClusterMap ¶
type ClusterMap struct {
Root *yaml.Node
}
func (*ClusterMap) Empty ¶
func (cm *ClusterMap) Empty() bool
func (*ClusterMap) FindEntry ¶
func (cm *ClusterMap) FindEntry(key string) (ce *ClusterEntry, err error)
func (*ClusterMap) GetStringValue ¶
func (cm *ClusterMap) GetStringValue(key string) (string, error)
func (*ClusterMap) RemoveEntry ¶
func (cm *ClusterMap) RemoveEntry(key string)
func (*ClusterMap) SetStringValue ¶
func (cm *ClusterMap) SetStringValue(key, value string) error
type ClusterOption ¶
type ClusterOption struct { Key string Description string DefaultValue string AllowedValues []string }
func ClusterOptions ¶
func ClusterOptions() []ClusterOption
type ClusterStub ¶
func (ClusterStub) CheckWriteable ¶
func (c ClusterStub) CheckWriteable(host, key string) error
func (ClusterStub) DefaultHost ¶
func (c ClusterStub) DefaultHost() (string, error)
func (ClusterStub) DefaultHostWithSource ¶
func (c ClusterStub) DefaultHostWithSource() (string, string, error)
func (ClusterStub) GetWithSource ¶
func (c ClusterStub) GetWithSource(host, key string) (string, string, error)
func (ClusterStub) Hosts ¶
func (c ClusterStub) Hosts() ([]string, error)
func (ClusterStub) Set ¶
func (c ClusterStub) Set(host, key, value string) error
func (ClusterStub) UnsetHost ¶
func (c ClusterStub) UnsetHost(hostname string)
func (ClusterStub) Write ¶
func (c ClusterStub) Write() error
type HostCluster ¶
type HostCluster struct { ClusterMap Host string }
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.