config

package
v6.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAddressEncodingName = stores.Base64EncodingName
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 NoopSymmetricProvider

func NoopSymmetricProvider(_ string) ([]byte, error)

NoopSymmetricProvider returns an empty provider

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
	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, 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 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
	// Chunk size for data upload / download
	ChunkSize int
	// 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 DefaultCloud

func DefaultCloud(cloud string) *Storage

func DefaultFileSystemConfig

func DefaultFileSystemConfig() *Storage

func DefaultIPFSConfig

func DefaultIPFSConfig() *Storage

func DefaultMemory

func DefaultMemory() *Storage

func GetDefaultStorage

func GetDefaultStorage(c string) (*Storage, error)

func NewCloud

func NewCloud(encoding, cloud, bucket, prefix, region string) (*Storage, error)

func NewFileSystemConfig

func NewFileSystemConfig(addressEncoding, rootDirectory string) *Storage

func NewIPFSConfig

func NewIPFSConfig(addressEncoding, host string) *Storage

func NewMemory

func NewMemory(addressEncoding 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) ([]byte, error)

func NewSymmetricProvider

func NewSymmetricProvider(conf *Secrets) SymmetricProvider

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
	Passphrase string
}

Jump to

Keyboard shortcuts

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