Documentation ¶
Overview ¶
Package config contains a handful of useful functions to load to configuration structs from JSON files, JSON blobs in Consul k/v or environment variables.
The subpackages contain structs meant for managing common configuration options and credentials. There are currently configs for:
* Go Kit Metrics * MySQL * MongoDB * Oracle * PostgreSQL * AWS (S3, DynamoDB, ElastiCache) * GCP * Gorilla's `securecookie`
The package also has a generic `Config` type in the `config/combined` package that contains all of the above types. It's meant to be a 'catch all' convenience struct that many applications should be able to use.
Index ¶
Constants ¶
const DefaultConfigLocation = "/opt/nyt/etc/conf.json"
DefaultConfigLocation is the default filepath for JSON config files.
Variables ¶
var EnvAppName = ""
EnvAppName is used as a prefix for environment variable names when using the LoadXFromEnv funcs. It defaults to empty.
Functions ¶
func LoadEnvConfig ¶
func LoadEnvConfig(c interface{})
LoadEnvConfig will use envconfig to load the given config struct from the environment.
func LoadJSONFile ¶
func LoadJSONFile(fileName string, cfg interface{})
LoadJSONFile is a helper function to read a config file into whatever config struct you need. For example, your custom config could be composed of one or more of the given Config, AWS, MySQL, Oracle or MongoDB structs.
func LoadJSONFromConsulKV ¶
func LoadJSONFromConsulKV(configKeyParameter string, cfg interface{}) interface{}
LoadJSONFromConsulKV is a helper function to read a JSON string found in a path defined by configKey inside Consul's Key Value storage then unmarshalled into a config struct, like LoadJSONFile does. It assumes that the Consul agent is running with the default setup, where the HTTP API is found via 127.0.0.1:8500.
func SetFlagOverrides ¶
SetFlagOverrides will add and check a `log` and `config` CLI flag to the current process, call flag.Parse() and will overwrite the passed in string pointer if the flag exists.
func SetLogOverride ¶
func SetLogOverride(log *string)
SetLogOverride will check `*LogCLI` for any values and override the given string pointer if LogCLI is set. If LogCLI is set to "dev", the given log var will be set to "".
Types ¶
This section is empty.