Documentation
¶
Index ¶
- func ParseEnv(log logr.Logger, prefix string, config interface{}, p EnvParser) error
- func ParseFile(log logr.Logger, name string, config interface{}, o []FileParser) (err error)
- func ParseFileFromInterfaces(log logr.Logger, name string, config interface{}, generic []interface{}) (err error)
- func ParseFlags(log logr.Logger, config interface{}, p FlagParser) error
- type EnvParser
- type FileParser
- type FlagParser
- type Option
- type Parser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseFile ¶
func ParseFile(log logr.Logger, name string, config interface{}, o []FileParser) (err error)
ParseFile parses a file, trying all interface implementations passed in
func ParseFileFromInterfaces ¶
func ParseFileFromInterfaces(log logr.Logger, name string, config interface{}, generic []interface{}) (err error)
ParseFileFromInterfaces pass through to ParseFile function
func ParseFlags ¶
func ParseFlags(log logr.Logger, config interface{}, p FlagParser) error
ParseFlags cli flags
Types ¶
type EnvParser ¶
type EnvParser interface { // Parse environment variables and update the config // interface with the values Parse(log logr.Logger, prefix string, config interface{}) error }
EnvParser interface for environment variables
type FileParser ¶
type FileParser interface { // Parse config file and update the config // interface with the values Parse(log logr.Logger, name string, config interface{}) error }
FileParser interface for configuration files
type FlagParser ¶
type FlagParser interface { // Parse environment variables and update the config // interface with the values Parse(log logr.Logger, config interface{}) error }
FlagParser interface for environment variables
type Option ¶
type Option func(*Parser)
Option for config
func WithEnvInterface ¶
WithEnvInterface sets the env parser to use
func WithFileInterface ¶
WithFileInterface sets the file parser to use
func WithFlagInterface ¶
func WithFlagInterface(fi FlagParser) Option
WithFlagInterface sets the flag parser to use
func WithPrefix ¶
WithPrefix sets the prefix for env vars PREFIX_
type Parser ¶
type Parser struct { Logger logr.Logger Prefix string File string Usage func() FlagInterface FlagParser EnvInterface EnvParser FileInterface *registrar.Registry }
Parser struct
func (*Parser) Parse ¶
Parse a config file, env vars and cli flags (override is in that order).
The fields of the confStruct passed in must be exported (uppercase).
CLI flags by default split camelCase field names with dashes. e.x. `KeyOne` would be a cli flag of `-key-one`. To modify this, add a struct tag. KeyOne string `flag:"keyone"` will give you a cli flag of `-keyone`.