Documentation ¶
Index ¶
- Variables
- func ConfigDir() string
- func DataDir() string
- func HomeDirPath(subdir string) (string, error)
- func NewBlankConfig() *ghmock.ConfigMock
- func NewConfig() (gh.Config, error)
- func NewFromString(cfgStr string) *ghmock.ConfigMock
- func NewIsolatedTestConfig(t *testing.T) (*cfg, func(io.Writer, io.Writer))
- func StateDir() string
- func StubWriteConfig(t *testing.T) func(io.Writer, io.Writer)
- type AliasConfig
- type AuthConfig
- func (c *AuthConfig) ActiveToken(hostname string) (string, string)
- func (c *AuthConfig) ActiveUser(hostname string) (string, error)
- func (c *AuthConfig) DefaultHost() (string, string)
- func (c *AuthConfig) HasEnvToken() bool
- func (c *AuthConfig) Hosts() []string
- func (c *AuthConfig) Login(hostname, username, token, gitProtocol string, secureStorage bool) (bool, error)
- func (c *AuthConfig) Logout(hostname, username string) error
- func (c *AuthConfig) SetActiveToken(token, source string)
- func (c *AuthConfig) SetDefaultHost(host, source string)
- func (c *AuthConfig) SetHosts(hosts []string)
- func (c *AuthConfig) SwitchUser(hostname, user string) error
- func (c *AuthConfig) TokenForUser(hostname, user string) (string, string, error)
- func (c *AuthConfig) TokenFromKeyring(hostname string) (string, error)
- func (c *AuthConfig) TokenFromKeyringForUser(hostname, username string) (string, error)
- func (c *AuthConfig) UsersForHost(hostname string) []string
- type ConfigOption
Constants ¶
This section is empty.
Variables ¶
var Options = []ConfigOption{ { Key: gitProtocolKey, Description: "the protocol to use for git clone and push operations", DefaultValue: "https", AllowedValues: []string{"https", "ssh"}, CurrentValue: func(c gh.Config, hostname string) string { return c.GitProtocol(hostname).Value }, }, { Key: editorKey, Description: "the text editor program to use for authoring text", DefaultValue: "", CurrentValue: func(c gh.Config, hostname string) string { return c.Editor(hostname).Value }, }, { Key: promptKey, Description: "toggle interactive prompting in the terminal", DefaultValue: "enabled", AllowedValues: []string{"enabled", "disabled"}, CurrentValue: func(c gh.Config, hostname string) string { return c.Prompt(hostname).Value }, }, { Key: pagerKey, Description: "the terminal pager program to send standard output to", DefaultValue: "", CurrentValue: func(c gh.Config, hostname string) string { return c.Pager(hostname).Value }, }, { Key: httpUnixSocketKey, Description: "the path to a Unix socket through which to make an HTTP connection", DefaultValue: "", CurrentValue: func(c gh.Config, hostname string) string { return c.HTTPUnixSocket(hostname).Value }, }, { Key: browserKey, Description: "the web browser to use for opening URLs", DefaultValue: "", CurrentValue: func(c gh.Config, hostname string) string { return c.Browser(hostname).Value }, }, }
Functions ¶
func HomeDirPath ¶
func NewBlankConfig ¶
func NewBlankConfig() *ghmock.ConfigMock
func NewFromString ¶
func NewFromString(cfgStr string) *ghmock.ConfigMock
func NewIsolatedTestConfig ¶ added in v2.40.0
NewIsolatedTestConfig sets up a Mock keyring, creates a blank config overwrites the ghConfig.Read function that returns a singleton config in the real implementation, sets the GH_CONFIG_DIR env var so that any call to Write goes to a different location on disk, and then returns the blank config and a function that reads any data written to disk.
func StubWriteConfig ¶
StubWriteConfig stubs out the filesystem where config file are written. It then returns a function that will read in the config files into io.Writers. It automatically cleans up environment variables and written files.
Types ¶
type AliasConfig ¶
type AliasConfig struct {
// contains filtered or unexported fields
}
func (*AliasConfig) Add ¶
func (a *AliasConfig) Add(alias, expansion string)
func (*AliasConfig) All ¶
func (a *AliasConfig) All() map[string]string
func (*AliasConfig) Delete ¶
func (a *AliasConfig) Delete(alias string) error
type AuthConfig ¶ added in v2.24.0
type AuthConfig struct {
// contains filtered or unexported fields
}
AuthConfig is used for interacting with some persistent configuration for gh, with knowledge on how to access encrypted storage when neccesarry. Behavior is scoped to authentication specific tasks.
func (*AuthConfig) ActiveToken ¶ added in v2.40.0
func (c *AuthConfig) ActiveToken(hostname string) (string, string)
ActiveToken will retrieve the active auth token for the given hostname, searching environment variables, plain text config, and lastly encrypted storage.
func (*AuthConfig) ActiveUser ¶ added in v2.40.0
func (c *AuthConfig) ActiveUser(hostname string) (string, error)
ActiveUser will retrieve the username for the active user at the given hostname. This will not be accurate if the oauth token is set from an environment variable.
func (*AuthConfig) DefaultHost ¶ added in v2.24.0
func (c *AuthConfig) DefaultHost() (string, string)
func (*AuthConfig) HasEnvToken ¶ added in v2.25.0
func (c *AuthConfig) HasEnvToken() bool
HasEnvToken returns true when a token has been specified in an environment variable, else returns false.
func (*AuthConfig) Hosts ¶ added in v2.24.0
func (c *AuthConfig) Hosts() []string
func (*AuthConfig) Login ¶ added in v2.24.0
func (c *AuthConfig) Login(hostname, username, token, gitProtocol string, secureStorage bool) (bool, error)
Login will set user, git protocol, and auth token for the given hostname. If the encrypt option is specified it will first try to store the auth token in encrypted storage and will fall back to the plain text config file.
func (*AuthConfig) Logout ¶ added in v2.24.0
func (c *AuthConfig) Logout(hostname, username string) error
Logout will remove user, git protocol, and auth token for the given hostname. It will remove the auth token from the encrypted storage if it exists there.
func (*AuthConfig) SetActiveToken ¶ added in v2.40.0
func (c *AuthConfig) SetActiveToken(token, source string)
SetActiveToken will override any token resolution and return the given token and source for all calls to ActiveToken. Use for testing purposes only.
func (*AuthConfig) SetDefaultHost ¶ added in v2.24.0
func (c *AuthConfig) SetDefaultHost(host, source string)
SetDefaultHost will override any host resolution and return the given host and source for all calls to DefaultHost. Use for testing purposes only.
func (*AuthConfig) SetHosts ¶ added in v2.24.0
func (c *AuthConfig) SetHosts(hosts []string)
SetHosts will override any hosts resolution and return the given hosts for all calls to Hosts. Use for testing purposes only.
func (*AuthConfig) SwitchUser ¶ added in v2.40.0
func (c *AuthConfig) SwitchUser(hostname, user string) error
func (*AuthConfig) TokenForUser ¶ added in v2.40.0
func (c *AuthConfig) TokenForUser(hostname, user string) (string, string, error)
func (*AuthConfig) TokenFromKeyring ¶ added in v2.24.0
func (c *AuthConfig) TokenFromKeyring(hostname string) (string, error)
TokenFromKeyring will retrieve the auth token for the given hostname, only searching in encrypted storage.
func (*AuthConfig) TokenFromKeyringForUser ¶ added in v2.40.0
func (c *AuthConfig) TokenFromKeyringForUser(hostname, username string) (string, error)
TokenFromKeyringForUser will retrieve the auth token for the given hostname and username, only searching in encrypted storage.
An empty username will return an error because the potential to return the currently active token under surprising cases is just too high to risk compared to the utility of having the function being smart.
func (*AuthConfig) UsersForHost ¶ added in v2.40.0
func (c *AuthConfig) UsersForHost(hostname string) []string