Documentation ¶
Overview ¶
Package config defines an interface for configuring a Reflow instance. This interface can be composed in multiple ways, allowing for layered configuration and also for distributions of Reflow to supply custom configuration.
A configuration is a set of keys (corresponding to toplevel keys in a YAML document). A subset of keys, defined by the package's AllKeys, correspond to objects that are configured by the Config interface. These keys may be provisioned by globally registered providers; the keys must be string formatted, and contain the (registered) name of the provider, followed by an optional comma and string argument. For example:
cache: s3,bucket,dynamodb
Configures the cache key (corresponding to Config.Cache) using the s3 provider; the argument "bucket,dynamodb" is used to configure it.
Providers may themselves look up keys to supply further configuration. For example, we may provision the cluster key (corresponding to Config.Cluster) with the ec2cluster provider, which is further configured by the ec2cluster key, for example:
cluster: ec2cluster ec2cluster: zone: us-west-2a ami: ami-12345 disktype: gp2 ...
Configuration providers are registered globally, allowing for different distributions to provide different backends or configuration mechanisms.
Configuration providers may also supply additional keys (i.e., not present in the original concrete input configuration) that can be used to transmit additional configuration information across systems boundaries, for example to pass credentials from the Reflow cluster controller to individual reflowlet instances.
Index ¶
- Constants
- Variables
- func Help() map[string][]Usage
- func Marshal(cfg Config) ([]byte, error)
- func Register(key, kind, arg, usage string, configure func(Config, string) (Config, error))
- func Unmarshal(b []byte, keys Keys) error
- type Base
- func (b Base) AWS() (*session.Session, error)
- func (b Base) AWSCreds() (*credentials.Credentials, error)
- func (b Base) AWSRegion() (string, error)
- func (b Base) AWSTool() (string, error)
- func (b Base) Assoc() (assoc.Assoc, error)
- func (b Base) Cache() (reflow.Cache, error)
- func (b Base) CacheMode() reflow.CacheMode
- func (b Base) Cluster() (runner.Cluster, error)
- func (b Base) HTTPS() (client, server *tls.Config, err error)
- func (b Base) Keys() Keys
- func (b Base) Logger() (*log.Logger, error)
- func (b Base) Marshal(keys Keys) error
- func (b Base) Repository() (reflow.Repository, error)
- func (b Base) User() (string, error)
- func (b Base) Value(key string) interface{}
- type Config
- type Flag
- type KeyConfig
- type Keys
- type OnceConfig
- type Provider
- type Usage
Constants ¶
const ( Logger = "logger" AWS = "aws" AWSTool = "awstool" User = "user" HTTPS = "https" // Cache is maintained as a key for backwards compatibility purposes. Cache = "cache" Cluster = "cluster" Assoc = "assoc" Repository = "repository" )
The following are the set of keys provisioned by Config.
Variables ¶
var AllKeys = []string{ Logger, AWS, AWSTool, User, HTTPS, Cache, Assoc, Repository, Cluster, }
AllKeys defines the order in which configuration keys are provisioned. Thus, providers for keys later in the list may use configuration provided by providers for keys earlier in the list.
Functions ¶
Types ¶
type Base ¶
type Base Keys
Base defines a base configuration with reasonable defaults where they apply.
func (Base) AWSCreds ¶
func (b Base) AWSCreds() (*credentials.Credentials, error)
AWSCreds returns new default AWS credentials.
func (Base) AWSRegion ¶
AWSRegion the region in the key "awsregion", or else the default region us-west-2.
func (Base) Marshal ¶
Marshal populates the provided key dictionary with the keys present in this configuration. It also inlines AWS credentials so that the configuration is sealed.
func (Base) Repository ¶
func (b Base) Repository() (reflow.Repository, error)
Repository returns a nil repository.
type Config ¶
type Config interface { // CacheMode returns the configured cache mode. CacheMode() reflow.CacheMode // Assoc returns this configuration's assoc. Assoc() (assoc.Assoc, error) // Repository returns this configuration's repository. Repository() (reflow.Repository, error) // AWS returns this configuration's AWS session. AWS() (*session.Session, error) // AWSCreds provides AWS credentials directly. This differs from AWS // in that these credentials my be extended to user code, and should // be permanent. AWSCreds() (*credentials.Credentials, error) // AWSRegion returns the region to be used for all AWS operations. AWSRegion() (string, error) // AWSTool is the Docker image to be used for the AWS CLI. AWSTool() (string, error) // HTTPS returns this configuration's client and server configs. HTTPS() (client, server *tls.Config, err error) // User returns the user's id. User() (string, error) // Logger returns the configured logger. Logger() (*log.Logger, error) // Cluster returns the configured cluster. Cluster() (runner.Cluster, error) // Value returns the value of the given key. Value(key string) interface{} // Marshal marshals the current configuration into keys. Marshal(keys Keys) error // Keys returns all the keys as defined by this config. Keys() Keys }
A Config provides a number of methods to mint new objects that are used in Reflow. It is safe to call each method multiple times, but they should not be called concurrently.
func Make ¶
Make evaluates a config's keys: for each key in AllKeys (and in the order defined by AllKeys), Make parses its provider, and provisions the key accordingly. Make returns errors if a provider cannot be found or if the provider fails to configure the given key.
type Flag ¶
type Flag struct { Config // contains filtered or unexported fields }
Flag exposes a FlagSet that overrides a set of config keys.
type KeyConfig ¶
KeyConfig provides default values for keys that do not exist in the underlying configuration.
type OnceConfig ¶
type OnceConfig struct { Config // contains filtered or unexported fields }
OnceConfig memoizes the first call of the following methods to the underlying config: Assoc, Repository, AWS, AWCreds, and HTTPS.
func Once ¶
func Once(cfg Config) *OnceConfig
Once constructs a new OnceConfig using the provided underlying configuration.
func (*OnceConfig) AWS ¶
func (o *OnceConfig) AWS() (*session.Session, error)
AWS returns the result of the first call to the underlying configuration's AWS.
func (*OnceConfig) AWSCreds ¶
func (o *OnceConfig) AWSCreds() (*credentials.Credentials, error)
AWSCreds returns the result of the first call to the underlying configuration's AWSCreds.
func (*OnceConfig) Assoc ¶
func (o *OnceConfig) Assoc() (assoc.Assoc, error)
Assoc returns the result of the first call to the underlying configuration's Assoc.
func (*OnceConfig) HTTPS ¶
func (o *OnceConfig) HTTPS() (client, server *tls.Config, err error)
HTTPS returns the result of the first call to the underlying configuration's HTTPS.
func (*OnceConfig) Repository ¶
func (o *OnceConfig) Repository() (reflow.Repository, error)
Repository returns the result of the first call to the underlying configuration's Repository.
Directories ¶
Path | Synopsis |
---|---|
Package all imports all standard configuration providers in Reflow.
|
Package all imports all standard configuration providers in Reflow. |
Package awsenvconfig configures AWS credentials to be derived from the user's environment.
|
Package awsenvconfig configures AWS credentials to be derived from the user's environment. |
Package ec2config defines and registers configuration providers using Amazon's EC2 metadata service.
|
Package ec2config defines and registers configuration providers using Amazon's EC2 metadata service. |
Package httpscaconfig defines a configuration provider named "httpsca" which can be used to configure HTTPS certificates via an on-disk certificate authority.
|
Package httpscaconfig defines a configuration provider named "httpsca" which can be used to configure HTTPS certificates via an on-disk certificate authority. |
Package httpsconfig defines a configuration provider named "file" which can be used to configure HTTPS certificates.
|
Package httpsconfig defines a configuration provider named "file" which can be used to configure HTTPS certificates. |
Package s3config defines a configuration provider named "s3" which can be used to configure S3-based caches.
|
Package s3config defines a configuration provider named "s3" which can be used to configure S3-based caches. |