Documentation ¶
Index ¶
- Constants
- Variables
- func IsValidKey(raw_key string) error
- type Config
- func New(ctx context.Context) (*Config, error)
- func NewLoadedConfig(ctx context.Context, envPrefixList []string, fileList []string) (*Config, error)
- func WithInitialValues(ctx context.Context, initialValues map[string]interface{}) (*Config, error)
- func WithInitialValuesAndOptions(ctx context.Context, initialValues map[string]interface{}, options *Config) (*Config, error)
- func (c *Config) Compare(ctx context.Context, cmp *Config, valueCompare bool) error
- func (c *Config) CompareMap(ctx context.Context, cmpMap map[string]string, valueCompare bool) error
- func (c *Config) Copy(ctx context.Context) (*Config, error)
- func (c *Config) DumpToFile(ctx context.Context, format string, outFile string) error
- func (c *Config) GetConfig(ctx context.Context, key string) (*Config, error)
- func (c *Config) Load(ctx context.Context, envPrefixList []string, fileList []string) error
- func (c *Config) Merge(ctx context.Context, merger ConfigStore, overwrite bool) error
- func (c *Config) MergeIn(ctx context.Context, baseKey string, value ConfigStore, force bool) error
- func (c *Config) Sprint() string
- type ConfigLoader
- type ConfigStore
- type ConfigStoreImpl
- func (c *ConfigStoreImpl) Get(ctx context.Context, key string) (string, error)
- func (c *ConfigStoreImpl) GetAll(ctx context.Context, key string) map[string]string
- func (c *ConfigStoreImpl) Has(ctx context.Context, key string) bool
- func (c *ConfigStoreImpl) HasAllKeys(ctx context.Context, cmp []string) error
- func (c *ConfigStoreImpl) Keys(ctx context.Context) []string
- func (c *ConfigStoreImpl) Set(ctx context.Context, key string, value string, force bool) error
- type ConfigStoreNew
- type ErrCopyConfigReason
- type ErrDumpToFile
- type ErrFieldNotBool
- type ErrFieldNotConfig
- type ErrFieldNotDuration
- type ErrFieldNotFloat
- type ErrFieldNotInt
- type ErrFieldNotString
- type ErrKeyAmbiguous
- type ErrKeyInStore
- type ErrKeyNotFound
- type ErrKeyValueInvalid
- type ErrMergeConfigReason
- type ErrParsingEnvVar
- type ErrValueMismatch
- type ErrValueNotFound
- type KeyCharInvalid
- type Loader
Constants ¶
View Source
const ( CONFIG_TREE_SEPARATOR = "/" KEY_ALLOWED_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-" )
View Source
const ( ENV_SPLIT_CHAR = "_" ENTRY_SPLIT = "=" )
Variables ¶
View Source
var ( ErrDumpFailed = errors.New("dump failed") ErrMergeFailed = errors.New("merge failed") ErrConfigKey = errors.New("config key error") ErrTypeMismatch = errors.New("type mismatch") ErrCopyConfig = errors.New("copy config error") ErrNoConfigSource = errors.New("no config source provided") ErrLoadingConfig = errors.New("loading config failed") ErrValueInvalid = errors.New("value invalid") )
Functions ¶
func IsValidKey ¶ added in v0.1.6
Types ¶
type Config ¶
type Config struct { ConfigStore // contains filtered or unexported fields }
func NewLoadedConfig ¶ added in v0.1.6
func WithInitialValues ¶ added in v0.1.6
func WithInitialValuesAndOptions ¶ added in v0.1.6
func (*Config) Compare ¶
check if base config has all keys defined in cmp if firstError is true, return first error encountered
func (*Config) CompareMap ¶ added in v0.1.6
check if base config has all keys defined in cmp if firstError is true, return first error encountered
func (*Config) DumpToFile ¶
type ConfigLoader ¶ added in v0.1.4
type ConfigLoader struct{}
func (*ConfigLoader) LoadEnv ¶ added in v0.1.4
func (cl *ConfigLoader) LoadEnv(ctx context.Context, store ConfigStore, prefixList []string) error
func (*ConfigLoader) LoadFile ¶ added in v0.1.4
func (cl *ConfigLoader) LoadFile(ctx context.Context, store ConfigStore, filePaths []string) error
type ConfigStore ¶
type ConfigStore interface { Get(ctx context.Context, key string) (string, error) GetAll(ctx context.Context, key string) map[string]string Set(ctx context.Context, key string, value string, force bool) error Has(ctx context.Context, key string) bool // HasAllKeys(cmp map[string]interface{}) error Keys(ctx context.Context) []string }
func NewConfigStore ¶ added in v0.1.6
func NewConfigStore(ctx context.Context) (ConfigStore, error)
type ConfigStoreImpl ¶ added in v0.1.6
type ConfigStoreImpl struct {
// contains filtered or unexported fields
}
type ConfigStoreImpl map[string]interface{}
func (*ConfigStoreImpl) GetAll ¶ added in v0.1.6
GetAll returns all values that match the given key. If the key is not found, nil is returned. // If the key is found, but no values match, an empty map is returned. If the key is found, and values match, a map of values is returned, index by the key suffix (the part of the key after the last CONFIG_TREE_SEPARATOR) Single values are therefore indexed by an empty string.
func (*ConfigStoreImpl) Has ¶ added in v0.1.6
func (c *ConfigStoreImpl) Has(ctx context.Context, key string) bool
func (*ConfigStoreImpl) HasAllKeys ¶ added in v0.1.6
func (c *ConfigStoreImpl) HasAllKeys(ctx context.Context, cmp []string) error
type ConfigStoreNew ¶ added in v0.1.6
type ConfigStoreNew func(context.Context) (ConfigStore, error)
var DefaultConfigStore ConfigStoreNew = NewConfigStore
type ErrCopyConfigReason ¶ added in v0.1.6
type ErrCopyConfigReason struct {
// contains filtered or unexported fields
}
func (ErrCopyConfigReason) Error ¶ added in v0.1.6
func (e ErrCopyConfigReason) Error() string
func (ErrCopyConfigReason) Unwrap ¶ added in v0.1.6
func (e ErrCopyConfigReason) Unwrap() error
type ErrDumpToFile ¶
type ErrDumpToFile struct {
// contains filtered or unexported fields
}
func (*ErrDumpToFile) Error ¶
func (c *ErrDumpToFile) Error() string
func (*ErrDumpToFile) Unwrap ¶
func (c *ErrDumpToFile) Unwrap() error
type ErrFieldNotBool ¶
type ErrFieldNotBool struct {
// contains filtered or unexported fields
}
func (*ErrFieldNotBool) Error ¶
func (f *ErrFieldNotBool) Error() string
func (*ErrFieldNotBool) Unwrap ¶
func (f *ErrFieldNotBool) Unwrap() error
type ErrFieldNotConfig ¶
type ErrFieldNotConfig struct {
// contains filtered or unexported fields
}
func (*ErrFieldNotConfig) Error ¶
func (f *ErrFieldNotConfig) Error() string
func (*ErrFieldNotConfig) Unwrap ¶
func (f *ErrFieldNotConfig) Unwrap() error
type ErrFieldNotDuration ¶
type ErrFieldNotDuration struct {
// contains filtered or unexported fields
}
func (*ErrFieldNotDuration) Error ¶
func (f *ErrFieldNotDuration) Error() string
func (*ErrFieldNotDuration) Unwrap ¶
func (f *ErrFieldNotDuration) Unwrap() error
type ErrFieldNotFloat ¶
type ErrFieldNotFloat struct {
// contains filtered or unexported fields
}
func (*ErrFieldNotFloat) Error ¶
func (f *ErrFieldNotFloat) Error() string
func (*ErrFieldNotFloat) Unwrap ¶
func (f *ErrFieldNotFloat) Unwrap() error
type ErrFieldNotInt ¶
type ErrFieldNotInt struct {
// contains filtered or unexported fields
}
func (*ErrFieldNotInt) Error ¶
func (f *ErrFieldNotInt) Error() string
func (*ErrFieldNotInt) Unwrap ¶
func (f *ErrFieldNotInt) Unwrap() error
type ErrFieldNotString ¶
type ErrFieldNotString struct {
// contains filtered or unexported fields
}
func (*ErrFieldNotString) Error ¶
func (f *ErrFieldNotString) Error() string
func (*ErrFieldNotString) Unwrap ¶
func (f *ErrFieldNotString) Unwrap() error
type ErrKeyAmbiguous ¶ added in v0.1.6
type ErrKeyAmbiguous struct {
// contains filtered or unexported fields
}
func (*ErrKeyAmbiguous) Error ¶ added in v0.1.6
func (e *ErrKeyAmbiguous) Error() string
func (*ErrKeyAmbiguous) Unwrap ¶ added in v0.1.6
func (e *ErrKeyAmbiguous) Unwrap() error
type ErrKeyInStore ¶
type ErrKeyInStore struct {
// contains filtered or unexported fields
}
func (*ErrKeyInStore) Error ¶
func (k *ErrKeyInStore) Error() string
func (*ErrKeyInStore) Unwrap ¶ added in v0.1.6
func (k *ErrKeyInStore) Unwrap() error
type ErrKeyNotFound ¶
type ErrKeyNotFound struct {
// contains filtered or unexported fields
}
func (*ErrKeyNotFound) Error ¶
func (k *ErrKeyNotFound) Error() string
func (*ErrKeyNotFound) Unwrap ¶
func (k *ErrKeyNotFound) Unwrap() error
type ErrKeyValueInvalid ¶ added in v0.1.6
type ErrKeyValueInvalid struct {
// contains filtered or unexported fields
}
func (*ErrKeyValueInvalid) Error ¶ added in v0.1.6
func (v *ErrKeyValueInvalid) Error() string
func (*ErrKeyValueInvalid) Unwrap ¶ added in v0.1.6
func (v *ErrKeyValueInvalid) Unwrap() error
func (*ErrKeyValueInvalid) Wrap ¶ added in v0.1.6
func (v *ErrKeyValueInvalid) Wrap(err error)
type ErrMergeConfigReason ¶ added in v0.1.6
type ErrMergeConfigReason struct {
// contains filtered or unexported fields
}
func (ErrMergeConfigReason) Error ¶ added in v0.1.6
func (e ErrMergeConfigReason) Error() string
func (ErrMergeConfigReason) Unwrap ¶ added in v0.1.6
func (e ErrMergeConfigReason) Unwrap() error
type ErrParsingEnvVar ¶ added in v0.1.6
type ErrParsingEnvVar struct {
// contains filtered or unexported fields
}
func (*ErrParsingEnvVar) Error ¶ added in v0.1.6
func (e *ErrParsingEnvVar) Error() string
func (*ErrParsingEnvVar) Unwrap ¶ added in v0.1.6
func (e *ErrParsingEnvVar) Unwrap() error
type ErrValueMismatch ¶
type ErrValueMismatch struct {
// contains filtered or unexported fields
}
func (*ErrValueMismatch) Error ¶
func (v *ErrValueMismatch) Error() string
func (*ErrValueMismatch) Unwrap ¶
func (v *ErrValueMismatch) Unwrap() error
type ErrValueNotFound ¶
type ErrValueNotFound struct {
// contains filtered or unexported fields
}
func (*ErrValueNotFound) Error ¶
func (v *ErrValueNotFound) Error() string
func (*ErrValueNotFound) Unwrap ¶
func (v *ErrValueNotFound) Unwrap() error
type KeyCharInvalid ¶
type KeyCharInvalid struct {
// contains filtered or unexported fields
}
func (*KeyCharInvalid) Error ¶
func (k *KeyCharInvalid) Error() string
func (*KeyCharInvalid) Unwrap ¶
func (k *KeyCharInvalid) Unwrap() error
Click to show internal directories.
Click to hide internal directories.