storage

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 11 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 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.

func TokenExists added in v0.21.4

func TokenExists(name string, ss SecretStore) (bool, error)

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
	Exists() (bool, 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) Exists added in v0.21.4

func (s JSONConfigStore) Exists() (bool, error)

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 Token, err error)

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

func GetTokenIfExists added in v0.21.4

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

Returns an empty token if no token exists.

func TokenWithOverride added in v0.21.2

func TokenWithOverride(overrideToken Token, referenceToken Token) (Token, error)

TokenWithOverride returns a Token that retrieves its values from the reference Token, and has its values overridden any of the non-empty/non-nil values of the overrideToken.

func (Token) AnyValue added in v0.21.2

func (t Token) AnyValue() bool

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