Documentation
¶
Index ¶
- Constants
- func CmlArgumentsProvider() *cmlArgumentsProvider
- func CmlArgumentsSource() *cmlArgumentsSource
- func EnvironmentVariablesProvider() *environmentVariablesProvider
- func EnvironmentVariablesSource() *environmentVariablesSource
- func FailOnMissingVariables(flag bool)
- func Get(name string) interface{}
- func JsonConfigurationProvider() *jsonConfigurationProvider
- func JsonConfigurationProviderWithOptions(options JsonConfigurationProviderOptions) *jsonConfigurationProvider
- func JsonConfigurationSource() *jsonConfigurationSource
- func Load() []error
- func NewJsonConfigurationProviderWithOptions(options JsonConfigurationProviderOptions) *jsonConfigurationProvider
- func NewYamlConfigurationProvider() *yamlConfigurationProvider
- func NewYamlConfigurationProviderWithOptions(options YamlConfigurationProviderOptions) *yamlConfigurationProvider
- func Refresh()
- func SyncedRefresh() error
- func Validate() error
- func Var(name string) *variable
- func YamlConfigurationProvider() *yamlConfigurationProvider
- func YamlConfigurationProviderWithOptions(options YamlConfigurationProviderOptions) *yamlConfigurationProvider
- func YamlConfigurationSource() *yamlConfigurationSource
- type JsonConfigurationProviderOptions
- type Provider
- type Settings
- type Source
- type YamlConfigurationProviderOptions
Constants ¶
const (
ErrVariableAlreadyExists = err.Error("Variable name already exists.")
)
Variables ¶
This section is empty.
Functions ¶
func CmlArgumentsProvider ¶
func CmlArgumentsProvider() *cmlArgumentsProvider
CmlArgumentsProvider Gets the singleton instance for the CML Arguments Provider
func CmlArgumentsSource ¶
func CmlArgumentsSource() *cmlArgumentsSource
func EnvironmentVariablesProvider ¶
func EnvironmentVariablesProvider() *environmentVariablesProvider
EnvironmentVariablesProvider Gets the Environment Variables Provider instance (Singleton)
func EnvironmentVariablesSource ¶
func EnvironmentVariablesSource() *environmentVariablesSource
func FailOnMissingVariables ¶
func FailOnMissingVariables(flag bool)
func Get ¶
func Get(name string) interface{}
Get Gets the value of a variable if it's provided. Returns nil if not.
func JsonConfigurationProvider ¶
func JsonConfigurationProvider() *jsonConfigurationProvider
JsonConfigurationProvider Gets or creates the default JSON configuration Provider instance (Singleton) with default Options
func JsonConfigurationProviderWithOptions ¶
func JsonConfigurationProviderWithOptions(options JsonConfigurationProviderOptions) *jsonConfigurationProvider
JsonConfigurationProviderWithOptions Gets or creates the default JSON Configuration Provider instance (Singleton) with given Options. Options are ignored if there is already a default instance initialized
func JsonConfigurationSource ¶
func JsonConfigurationSource() *jsonConfigurationSource
func NewJsonConfigurationProviderWithOptions ¶
func NewJsonConfigurationProviderWithOptions(options JsonConfigurationProviderOptions) *jsonConfigurationProvider
NewJsonConfigurationProviderWithOptions Creates a new JSON configuration Provider with given options
func NewYamlConfigurationProvider ¶
func NewYamlConfigurationProvider() *yamlConfigurationProvider
NewYamlConfigurationProvider Creates a new JSON configuration Provider
func NewYamlConfigurationProviderWithOptions ¶
func NewYamlConfigurationProviderWithOptions(options YamlConfigurationProviderOptions) *yamlConfigurationProvider
NewYamlConfigurationProviderWithOptions Creates a new Yaml configuration Provider with given options
func SyncedRefresh ¶
func SyncedRefresh() error
SyncedRefresh Refreshes Provider configurations synchronously. A provider does not need to guarantee a refresh, but should have an error-free implementation then.
func Validate ¶
func Validate() error
Validate validates if all non-string properties have been provided by a suitable format
func YamlConfigurationProvider ¶
func YamlConfigurationProvider() *yamlConfigurationProvider
YamlConfigurationProvider Gets or creates the default YAML configuration Provider instance (Singleton) with default Options
func YamlConfigurationProviderWithOptions ¶
func YamlConfigurationProviderWithOptions(options YamlConfigurationProviderOptions) *yamlConfigurationProvider
YamlConfigurationProviderWithOptions Gets or creates the default JSON Configuration Provider instance (Singleton) with given Options. Options are ignored if there is already a default instance initialized
func YamlConfigurationSource ¶
func YamlConfigurationSource() *yamlConfigurationSource
Types ¶
type Provider ¶
type Provider interface { // Get the value for the given property. nil should be returned if no property is found or an error with it exists Get(name string, config interface{}) interface{} // Load Loads the values it should provide Load() error // Refresh the provider sources. Useful for sources which are mutable during a single execution (like file sources) // returns a boolean stating if it has newer values and an error for failures. A provider not able to refresh should // always return false with no errors. Refresh() (bool, error) }
A Provider is a component that is able to extract values from a specific source, when present. They can be registered in the env package as a source of values
type Source ¶
type Source interface { // Provider returns the variable provider Provider() Provider // Config is the provider configuration used to extract the variable from the provider. The returned object should // be defined and processed by the provider Config() interface{} }
Source of a variable identifies the provider where the value will come from and the variable configuration to extract the value from the provider