config

package
v7.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAddressEncodingName = stores.Base64EncodingName
View Source
const DefaultChunkSize = 1 << 16 // 64 Kb
View Source
const DefaultHoardConfigFileName = "hoard.conf"
View Source
const DefaultJSONConfigEnvironmentVariable = "HOARD_JSON_CONFIG"
View Source
const DefaultListenAddress = "tcp://:53431"
View Source
const STDINFileIdentifier = "-"

Variables

View Source
var NoopSecretManager = SecretsManager{
	Provider: NoopSymmetricProvider,
	OpenPGP:  nil,
}

NoopSecretManager is an empty secret manager

Functions

func Cascade

func Cascade(logWriter io.Writer, shortCircuit bool, sources ...Provider) *configSource

func Default

func Default() *configSource

func Environment

func Environment(key string) *configSource

Source from a single environment variable with config embedded in JSON

func File

func File(configFile string) *configSource

Source from file

func Logger

func Logger(loggingConfig *Logging, writer io.Writer) (log.Logger, error)

func NewTerminalLogger

func NewTerminalLogger(loggingType LoggingType, writer io.Writer) (log.Logger, error)

func OutputLoggerMaker

func OutputLoggerMaker(loggingType LoggingType) (func(writer io.Writer) log.Logger, error)

func XDGBaseDir

func XDGBaseDir() *configSource

Try to find config by using XDG base dir spec

Types

type Cloud

type Cloud struct {
	Bucket string
	Prefix string
	Region string
}

type FileSystemConfig

type FileSystemConfig struct {
	RootDirectory string
}

type HoardConfig

type HoardConfig struct {
	ListenAddress string
	// Chunk size for data upload / download
	ChunkSize int
	Storage   *Storage
	Logging   *Logging
	Secrets   *Secrets
}

func HoardConfigFromJSONString

func HoardConfigFromJSONString(jsonString string) (*HoardConfig, error)

func HoardConfigFromTOMLString

func HoardConfigFromTOMLString(tomlString string) (*HoardConfig, error)

func HoardConfigFromYAMLString

func HoardConfigFromYAMLString(yamlString string) (*HoardConfig, error)

func NewHoardConfig

func NewHoardConfig(listenAddress string, chunkSize int, storageConfig *Storage, loggingConfig *Logging) *HoardConfig

func (*HoardConfig) JSONString

func (hoardConfig *HoardConfig) JSONString() string

func (*HoardConfig) TOMLString

func (hoardConfig *HoardConfig) TOMLString() string

func (*HoardConfig) YAMLString

func (hoardConfig *HoardConfig) YAMLString() string

type IPFSConfig

type IPFSConfig struct {
	RemoteAPI string
}

type Logging

type Logging struct {
	LoggingType LoggingType
	Channels    []structure.Channel
}

Logging describes the channels to listen on, messages not on these channels will be filtered and leaving empty disables logging

func NewLogging

func NewLogging(loggingType LoggingType,
	channels ...structure.Channel) *Logging

type LoggingType

type LoggingType string
const (
	Logfmt LoggingType = "logfmt"
	Json   LoggingType = "json"
)

type OpenPGPSecret

type OpenPGPSecret struct {
	// A private (though not secret) identifier that points to a PGP keyring that this instance of hoard
	// will use to provide PGP grants
	PrivateID string
	File      string
	Data      []byte
}

func NewOpenPGPSecret

func NewOpenPGPSecret(conf *Secrets) *OpenPGPSecret

OpenPGPFromConfig reads a given PGP keyring

type Provider

type Provider interface {
	// Description of where this provider sources its config from
	From() string
	// Get the config possibly overriding values passed in from baseConfig
	Get(baseConfig *HoardConfig) (*HoardConfig, error)
	// Return a copy of the provider that does nothing if skip is true
	SetSkip(skip bool) Provider
	// Whether to skip this provider
	Skip() bool
}

type SecretKey added in v7.2.0

type SecretKey []byte

SecretKey allows us to encode yaml and toml as base64

func (SecretKey) MarshalText added in v7.2.0

func (sec SecretKey) MarshalText() ([]byte, error)

MarshalText should fulfil most serialization interfaces to ensure that the secret key in the config is always base64 encoded

type Secrets

type Secrets struct {
	Symmetric []*SymmetricSecret
	OpenPGP   *OpenPGPSecret
}

Secrets lists the configured secrets, Symmetric secrets are those local to the running daemon and OpenPGP identifies an entity in the given keyring

type SecretsManager

type SecretsManager struct {
	Provider SymmetricProvider
	OpenPGP  *OpenPGPSecret
}

type Storage

type Storage struct {
	// Acts a string enum
	StorageType StorageType
	// Address encoding name
	AddressEncoding string
	// Embedding a pointer to each type of config struct allows us to access the
	// relevant one, while at the same time those that are left as nil will be
	// omitted from being serialised.
	*FileSystemConfig
	*Cloud
	*IPFSConfig
}

Storage identifies the configured back-end

func ConfigFromString

func ConfigFromString(tomlString string) (*Storage, error)

func GetDefaultStorage

func GetDefaultStorage(storageType StorageType) (*Storage, error)

func NewDefaultCloud

func NewDefaultCloud(cloud StorageType) *Storage

func NewDefaultFileSystemConfig

func NewDefaultFileSystemConfig() *Storage

func NewDefaultIPFSConfig

func NewDefaultIPFSConfig() *Storage

func NewDefaultMemory

func NewDefaultMemory() *Storage

func NewDefaultStorage

func NewDefaultStorage() *Storage

func NewFileSystemConfig

func NewFileSystemConfig(addressEncoding, rootDirectory string) *Storage

func NewIPFSConfig

func NewIPFSConfig(addressEncoding, host string) *Storage

func NewStorage

func NewStorage(storageType StorageType, addressEncoding string) *Storage

func (*Storage) TOMLString

func (storageConfig *Storage) TOMLString() string

type StorageType

type StorageType string
const (
	Unspecified StorageType = ""
	Memory      StorageType = "memory"
	Filesystem  StorageType = "filesystem"
	AWS         StorageType = "aws"
	Azure       StorageType = "azure"
	GCP         StorageType = "gcp"
	IPFS        StorageType = "ipfs"
)

func GetStorageTypes

func GetStorageTypes() []StorageType

type SymmetricProvider

type SymmetricProvider func(secretID string) (SymmetricSecret, error)

func NewSymmetricProvider

func NewSymmetricProvider(conf *Secrets, fromEnv bool) (SymmetricProvider, error)

ProviderFromConfig creates a secret reader from a set of symmetric secrets

type SymmetricSecret

type SymmetricSecret struct {
	// An identifier for this secret that will be stored in the clear with the grant
	PublicID string
	// We expect this to be base64 encoded
	SecretKey SecretKey
	// Needed for backwards compatability
	Passphrase string
}

func NoopSymmetricProvider

func NoopSymmetricProvider(_ string) (SymmetricSecret, error)

NoopSymmetricProvider returns an empty provider

func (*SymmetricSecret) UnmarshalTOML added in v7.2.0

func (sec *SymmetricSecret) UnmarshalTOML(in interface{}) error

func (*SymmetricSecret) UnmarshalYAML added in v7.2.0

func (sec *SymmetricSecret) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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