Documentation ¶
Index ¶
Constants ¶
const EnvClusterIdentifier = "SPOTINST_CLUSTER_IDENTIFIER"
EnvClusterIdentifier specifies the name of the environment variable points to cluster identifier.
Variables ¶
var ErrNoValidProvidersFoundInChain = errors.New("config: no valid " +
"configuration providers in chain")
ErrNoValidProvidersFoundInChain Is returned when there are no valid configuration providers in the ChainProvider.
Functions ¶
This section is empty.
Types ¶
type ChainProvider ¶
type ChainProvider struct {
Providers []Provider
}
ChainProvider will search for a provider which returns configuration and cache that provider until Retrieve is called again.
The ChainProvider provides a way of chaining multiple providers together which will pick the first available using priority order of the Providers in the list.
If none of the Providers retrieve valid configuration, Retrieve() will return the error ErrNoValidProvidersFoundInChain.
If a Provider is found which returns valid configuration, ChainProvider will cache that Provider for all calls until Retrieve is called again.
func (*ChainProvider) Retrieve ¶
func (x *ChainProvider) Retrieve(ctx context.Context) (*Value, error)
Retrieve retrieves and returns the configuration, or error in case of failure.
func (*ChainProvider) String ¶
func (x *ChainProvider) String() string
String returns the string representation of the Chain provider.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config provides synchronous safe retrieval of configuration.
Config is safe to use across multiple goroutines and will manage the synchronous state so the Providers do not need to implement their own synchronization.
The first Config.Get() will always call Provider.Retrieve() to get the first instance of the configuration. All calls to Get() after that will return the cached configuration.
func NewChainProvider ¶
NewChainProvider returns a new Config object wrapping a chain of providers.
func NewConfigMapProvider ¶
NewConfigMapProvider returns a new Config object wrapping the ConfigMap provider.
func NewDefaultProvider ¶
func NewDefaultProvider() *Config
NewDefaultProvider returns a new Config object wrapping the Default provider.
func NewEnvProvider ¶
func NewEnvProvider() *Config
NewEnvProvider returns a new Config object wrapping the Env provider.
type ConfigMapProvider ¶
ConfigMapProvider retrieves configuration from a ConfigMap.
func (*ConfigMapProvider) Retrieve ¶
func (x *ConfigMapProvider) Retrieve(ctx context.Context) (*Value, error)
Retrieve retrieves and returns the configuration, or error in case of failure.
func (*ConfigMapProvider) String ¶
func (x *ConfigMapProvider) String() string
String returns the string representation of the ConfigMap provider.
type DefaultProvider ¶
type DefaultProvider struct{}
DefaultProvider returns the default configuration.
func (*DefaultProvider) Retrieve ¶
func (x *DefaultProvider) Retrieve(context.Context) (*Value, error)
Retrieve retrieves and returns the configuration, or error in case of failure.
func (*DefaultProvider) String ¶
func (x *DefaultProvider) String() string
String returns the string representation of the Default provider.
type EnvProvider ¶
type EnvProvider struct{}
EnvProvider retrieves configuration from the environment variables of the process.
func (*EnvProvider) Retrieve ¶
func (x *EnvProvider) Retrieve(ctx context.Context) (*Value, error)
Retrieve retrieves and returns the configuration, or error in case of failure.
func (*EnvProvider) String ¶
func (x *EnvProvider) String() string
String returns the string representation of the Env provider.
type Provider ¶
type Provider interface { fmt.Stringer // Retrieve retrieves and returns the configuration, or error in case of failure. Retrieve(ctx context.Context) (*Value, error) }
Provider defines the interface for any component which will provide configuration. The Provider should not need to implement its own mutexes, because that will be managed by Config.
type Value ¶
type Value struct {
ClusterIdentifier string `json:"clusterIdentifier,omitempty" yaml:"clusterIdentifier,omitempty"`
}
Value represents the operator configuration.
func (*Value) IsComplete ¶
IsComplete if all fields of a Value are set.