Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultConfigStore is the ConfigStore that should be used unless otherwise // specified. DefaultConfigStore = HomeJSONConfigStore{} // ErrConfigNotFound is returned if there is no Config in a ConfigStore. ErrConfigNotFound = errors.New("config did not exist") )
var ( // DefaultTokenStore is the TokenStore that should be used unless otherwise // specified. DefaultTokenStore = KeychainTokenStore{} // ErrTokenNotFound is returned if there is no Config in a ConfigStore. ErrTokenNotFound = errors.New("token does not exist") // ErrMultipleTokens is returned if there are multiple tokens with the same // name. ErrMultipleTokens = errors.New("multiple tokens with the same name") )
Functions ¶
func SetCurrentToken ¶
func SetCurrentToken(name string, cs ConfigStore, ts TokenStore) error
SetCurrentToken is a convenient way to set the CurrentToken field in a the current config.
Types ¶
type ConfigStore ¶
ConfigStore is anything that can persistently store a Config.
type HomeJSONConfigStore ¶
type HomeJSONConfigStore struct{}
HomeJSONConfigStore implements a ConfigStore that stores its Config in the file "${XDG_CONFIG_HOME:-$HOME/.zed}/config.json".
func (HomeJSONConfigStore) Get ¶
func (s HomeJSONConfigStore) Get() (Config, error)
Get parses a Config from the filesystem.
func (HomeJSONConfigStore) Put ¶
func (s HomeJSONConfigStore) Put(cfg Config) error
Put overwrites a Config on the filesystem.
type KeychainTokenStore ¶
type KeychainTokenStore struct{}
KeychainTokenStore implements TokenStore by using the OS keychain service, falling back to an encrypted JWT on disk if the OS has no keychain.
func (KeychainTokenStore) Delete ¶
func (ks KeychainTokenStore) Delete(system string) error
Delete removes a Token from the keychain.
func (KeychainTokenStore) Get ¶
func (ks KeychainTokenStore) Get(system string) (Token, error)
Get fetches a Token from the keychain.
func (KeychainTokenStore) List ¶
func (ks KeychainTokenStore) List(revealTokens bool) ([]Token, error)
List returns all of the tokens in the keychain.
If revealTokens is true, the Token.Secrets field will contain the secret.
func (KeychainTokenStore) Put ¶
func (ks KeychainTokenStore) Put(system, endpoint, secret string) error
Put overwrites a Token in the keychain.
type Token ¶
Token represents an API Token and all of its metadata.
func CurrentToken ¶
func CurrentToken(cs ConfigStore, ts TokenStore) (Token, error)
CurrentToken is convenient way to obtain the CurrentToken field from the current Config.
func DefaultToken ¶
DefaultToken creates a Token from input, filling any missing values in with the current context's defaults.