Documentation ¶
Index ¶
- Variables
- func DefaultUnmarshal(dst Cloneable, args []string, fs *flag.FlagSet) error
- func DynamicUnmarshal(dst DynamicCloneable, args []string, fs *flag.FlagSet) error
- func GetTestMode() bool
- func SetTestMode(isTestMode bool)
- func Unmarshal(dst Cloneable, sources ...Source) error
- type Cloneable
- type DynamicCloneable
- type Source
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotPointer = errors.New("dst is not a pointer")
)
Functions ¶
func DefaultUnmarshal ¶
DefaultUnmarshal is a higher level wrapper for Unmarshal that automatically parses flags and a .yaml file
func DynamicUnmarshal ¶
func DynamicUnmarshal(dst DynamicCloneable, args []string, fs *flag.FlagSet) error
DynamicUnmarshal handles populating a config based on the following precedence: 1. Defaults provided by the `RegisterFlags` interface 2. Sections populated by dynamic logic. Configs passed to this function must implement ApplyDynamicConfig() 3. Any config options specified directly in the config file 4. Any config options specified on the command line.
func GetTestMode ¶ added in v0.6.0
func GetTestMode() bool
GetTestMode is used to get the testMode flag when running tests.
func SetTestMode ¶ added in v0.6.0
func SetTestMode(isTestMode bool)
SetTestMode is used to set the testMode flag. We don't want to exit the process when running tests.
Types ¶
type Cloneable ¶
type Cloneable interface {
Clone() flagext.Registerer
}
Cloneable is a config which can be cloned into a flagext.Registerer Contract: the cloned value must not mutate the original.
type DynamicCloneable ¶
DynamicCloneable must be implemented by config structs that can be dynamically unmarshalled
type Source ¶
Source is a generic configuration source. This function may do whatever is required to obtain the configuration. It is passed a pointer to the destination, which will be something compatible to `json.Unmarshal`. The obtained configuration may be written to this object, it may also contain data from previous sources.
func Flags ¶
Flags parses the flag from the command line, setting only user-supplied values on the flagext.Registerer passed to Defaults()
func YAML ¶
YAML returns a Source that opens the supplied `.yaml` file and loads it. When expandEnvVars is true, variables in the supplied '.yaml\ file are expanded using https://pkg.go.dev/github.com/drone/envsubst?tab=overview