Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config interface {
// DisableEnvVarSubstitution is the same as the global flag,
// DisableEnvVarSubstitution.
DisableEnvVarSubstitution(disable bool)
// Parent gets the configuration's parent (if set).
Parent() Config
// FlagSets gets the config's flag sets.
FlagSets() map[string]*pflag.FlagSet
// Scope returns a scoped view of the configuration. The specified scope
// string will be used to prefix all property retrievals via the Get
// and Set functions. Please note that the other functions will still
// operate as they would for the non-scoped configuration instance. This
// includes the AllSettings and AllKeys functions as well; they are *not*
// scoped.
Scope(scope interface{}) Config
// GetScope returns the config's current scope (if any).
GetScope() string
// GetString returns the value associated with the key as a string
GetString(k interface{}) string
// GetBool returns the value associated with the key as a bool
GetBool(k interface{}) bool
// GetStringSlice returns the value associated with the key as a string
// slice.
GetStringSlice(k interface{}) []string
// GetInt returns the value associated with the key as an int
GetInt(k interface{}) int
// Get returns the value associated with the key
Get(k interface{}) interface{}
// Set sets an override value
Set(k interface{}, v interface{})
// IsSet returns a flag indicating whether or not a key is set.
IsSet(k interface{}) bool
// Copy creates a copy of this Config instance
Copy() (Config, error)
// ToJSON exports this Config instance to a JSON string
ToJSON() (string, error)
// ToJSONCompact exports this Config instance to a compact JSON string
ToJSONCompact() (string, error)
// MarshalJSON implements the encoding/json.Marshaller interface. It allows
// this type to provide its own marshalling routine.
MarshalJSON() ([]byte, error)
// ReadConfig reads a configuration stream into the current config instance
ReadConfig(in io.Reader) error
// ReadConfigFile reads a configuration files into the current config
// instance
ReadConfigFile(filePath string) error
// EnvVars returns an array of the initialized configuration keys as
// key=value strings where the key is configuration key's environment
// variable key and the value is the current value for that key.
EnvVars() []string
// AllKeys gets a list of all the keys present in this configuration.
AllKeys() []string
// AllSettings gets a map of this configuration's settings.
AllSettings() map[string]interface{}
}
Config is the interface that enables retrieving configuration information. The variations of the Get function, the Set, IsSet, and Scope functions all take an interface{} as their first parameter. However, the param must be either a string or a fmt.Stringer, otherwise the function will panic.
type ConfigKeyTypes ¶
type ConfigKeyTypes int
ConfigKeyTypes is a type of configuration key.
const ( // String is a key with a string value String ConfigKeyTypes = iota // 0 // Int is a key with an integer value Int // 1 // Bool is a key with a boolean value Bool // 2 // SecureString is a key with a string value that is not included when the // configuration is marshaled to JSON. SecureString // 3 )
type ConfigRegistration ¶
type ConfigRegistration interface {
// Name returns the name of the config registration.
Name() string
// YAML returns the registration's default yaml configuration.
YAML() string
// SetYAML sets the registration's default yaml configuration.
SetYAML(y string)
// Key adds a key to the registration.
//
// The first vararg argument is the yaml name of the key, using a '.' as
// the nested separator. If the second two arguments are omitted they will
// be generated from the first argument. The second argument is the explicit
// name of the flag bound to this key. The third argument is the explicit
// name of the environment variable bound to thie key.
Key(
keyType ConfigKeyTypes,
short string,
defVal interface{},
description string,
keys ...interface{})
// Keys returns a channel on which a listener can receive the config
// registration's keys.
Keys() <-chan ConfigRegistrationKey
}
ConfigRegistration is an interface that describes a configuration registration object.
type ConfigRegistrationKey ¶
type ConfigRegistrationKey interface {
KeyType() ConfigKeyTypes
DefaultValue() interface{}
Short() string
Description() string
KeyName() string
FlagName() string
EnvVarName() string
}
ConfigRegistrationKey is an interfact that describes a cofniguration registration key object.
Click to show internal directories.
Click to hide internal directories.