storage

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigNotFound = errors.New("config did not exist")

ErrConfigNotFound is returned if there is no Config in a ConfigStore.

View Source
var ErrMissingToken = errors.New("could not find token")
View Source
var ErrTokenNotFound = errors.New("token does not exist")

ErrTokenNotFound is returned if there is no Token in a ConfigStore.

Functions

func PutToken added in v0.1.0

func PutToken(t Token, ss SecretStore) error

func RemoveToken added in v0.1.0

func RemoveToken(name string, ss SecretStore) error

func SetCurrentToken

func SetCurrentToken(name string, cs ConfigStore, ss SecretStore) error

SetCurrentToken is a convenient way to set the CurrentToken field in a the current config.

Types

type Config

type Config struct {
	Version      string
	CurrentToken string
}

Config represents the contents of a zed configuration file.

type ConfigStore

type ConfigStore interface {
	Get() (Config, error)
	Put(Config) error
}

ConfigStore is anything that can persistently store a Config.

type JSONConfigStore added in v0.1.0

type JSONConfigStore struct {
	ConfigPath string
}

JSONConfigStore implements a ConfigStore that stores its Config in a JSON file at the provided ConfigPath.

func (JSONConfigStore) Get added in v0.1.0

func (s JSONConfigStore) Get() (Config, error)

Get parses a Config from the filesystem.

func (JSONConfigStore) Put added in v0.1.0

func (s JSONConfigStore) Put(cfg Config) error

Put overwrites a Config on the filesystem.

type KeychainSecretStore added in v0.1.0

type KeychainSecretStore struct {
	ConfigPath string
	// contains filtered or unexported fields
}

func (*KeychainSecretStore) Get added in v0.1.0

func (k *KeychainSecretStore) Get() (Secrets, error)

func (*KeychainSecretStore) Put added in v0.1.0

func (k *KeychainSecretStore) Put(s Secrets) error

type SecretStore added in v0.1.0

type SecretStore interface {
	Get() (Secrets, error)
	Put(s Secrets) error
}

type Secrets added in v0.1.0

type Secrets struct {
	Tokens []Token
}

type Token

type Token struct {
	Name       string
	Endpoint   string
	APIToken   string
	Insecure   *bool
	NoVerifyCA *bool
	CACert     []byte
}

func CurrentToken

func CurrentToken(cs ConfigStore, ss SecretStore) (Token, error)

CurrentToken is convenient way to obtain the CurrentToken field from the current Config.

func DefaultToken

func DefaultToken(overrideEndpoint, overrideAPIToken string, cs ConfigStore, ss SecretStore) (Token, error)

DefaultToken creates a Token from input, filling any missing values in with the current context's defaults.

func GetToken added in v0.1.0

func GetToken(name string, ss SecretStore) (Token, error)

func (Token) Certificate added in v0.8.0

func (t Token) Certificate() (cert []byte, ok bool)

func (Token) HasNoVerifyCA added in v0.11.0

func (t Token) HasNoVerifyCA() bool

func (Token) IsInsecure added in v0.4.3

func (t Token) IsInsecure() bool

func (Token) Redacted added in v0.4.3

func (t Token) Redacted() string

func (Token) SplitAPIToken added in v0.3.1

func (t Token) SplitAPIToken() (prefix, secret string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL