config

package
v0.14.4-dev Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const SymmetricCrypterKeyBytes = 32

SymmetricCrypterKeyBytes is the required key size in bytes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crypter

type Crypter interface {
	Encrypter
	Decrypter
}

Crypter can both encrypt and decrypt values.

func NewPanicCrypter

func NewPanicCrypter() Crypter

NewPanicCrypter returns a new config crypter that will panic if used.

func NewSymmetricCrypter

func NewSymmetricCrypter(key []byte) Crypter

NewSymmetricCrypter creates a crypter that encrypts and decrypts values using AES-256-GCM. The nonce is stored with the value itself as a pair of base64 values separated by a colon and a version tag `v1` is prepended.

func NewSymmetricCrypterFromPassphrase

func NewSymmetricCrypterFromPassphrase(phrase string, salt []byte) Crypter

NewSymmetricCrypterFromPassphrase uses a passphrase and salt to generate a key, and then returns a crypter using it.

type Decrypter

type Decrypter interface {
	DecryptValue(ciphertext string) (string, error)
}

Decrypter decrypts encrypted ciphertext to its plaintext representation.

var NopDecrypter Decrypter = nopDecrypter{}

func NewBlindingDecrypter

func NewBlindingDecrypter() Decrypter

NewBlindingDecrypter returns a Decrypter that instead of decrypting data, just returns "[secret]", it can be used when you want to display configuration information to a user but don't want to prompt for a password so secrets will not be decrypted.

type Encrypter

type Encrypter interface {
	EncryptValue(plaintext string) (string, error)
}

Encrypter encrypts plaintext into its encrypted ciphertext.

type Key

type Key struct {
	// contains filtered or unexported fields
}

func MustMakeKey

func MustMakeKey(namespace string, name string) Key

MustMakeKey constructs a config.Key for a given namespace and name. The namespace may not contain a `:`

func ParseKey

func ParseKey(s string) (Key, error)

func (Key) MarshalJSON

func (k Key) MarshalJSON() ([]byte, error)

func (Key) MarshalYAML

func (k Key) MarshalYAML() (interface{}, error)

func (Key) Name

func (k Key) Name() string

func (Key) Namespace

func (k Key) Namespace() string

func (Key) String

func (k Key) String() string

func (*Key) UnmarshalJSON

func (k *Key) UnmarshalJSON(b []byte) error

func (*Key) UnmarshalYAML

func (k *Key) UnmarshalYAML(unmarshal func(interface{}) error) error

type KeyArray

type KeyArray []Key

func (KeyArray) Len

func (k KeyArray) Len() int

func (KeyArray) Less

func (k KeyArray) Less(i int, j int) bool

func (KeyArray) Swap

func (k KeyArray) Swap(i int, j int)

type Map

type Map map[Key]Value

Map is a bag of config stored in the settings file.

func (Map) Decrypt

func (m Map) Decrypt(decrypter Decrypter) (map[Key]string, error)

Decrypt returns the configuration as a map from module member to decrypted value.

func (Map) HasSecureValue

func (m Map) HasSecureValue() bool

HasSecureValue returns true if the config map contains a secure (encrypted) value.

func (Map) MarshalJSON

func (m Map) MarshalJSON() ([]byte, error)

func (Map) MarshalYAML

func (m Map) MarshalYAML() (interface{}, error)

func (*Map) UnmarshalJSON

func (m *Map) UnmarshalJSON(b []byte) error

func (*Map) UnmarshalYAML

func (m *Map) UnmarshalYAML(unmarshal func(interface{}) error) error

type Value

type Value struct {
	// contains filtered or unexported fields
}

Value is a single config value.

func NewSecureValue

func NewSecureValue(v string) Value

func NewValue

func NewValue(v string) Value

func (Value) MarshalJSON

func (c Value) MarshalJSON() ([]byte, error)

func (Value) MarshalYAML

func (c Value) MarshalYAML() (interface{}, error)

func (Value) Secure

func (c Value) Secure() bool

func (*Value) UnmarshalJSON

func (c *Value) UnmarshalJSON(b []byte) error

func (*Value) UnmarshalYAML

func (c *Value) UnmarshalYAML(unmarshal func(interface{}) error) error

func (Value) Value

func (c Value) Value(decrypter Decrypter) (string, error)

Value fetches the value of this configuration entry, using decrypter to decrypt if necessary. If the value is a secret and decrypter is nil, or if decryption fails for any reason, a non-nil error is returned.

Jump to

Keyboard shortcuts

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