-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
The configuration in the framework is managed using environment variables. Whenever you run the docker-compose files, .env
file is expected to be present in the docker
folder wherein all the configuration variables are automatically picked up & added to the environment. Each config variable is then read in the config
package using https://github.com/spf13/viper.
config
package holds the entire configuration of the service. For each type of configuration, there is a separate file in the config package, for ex: api.go
, postgres.go
, objectstorage.go
etc. Feel free to add new variables in the same files or new files to the codebase as you contribute.
Each config file like api.go
, postgres.go
etc has the following sections
This is the struct for the config type which holds the config variables as the member variables
This method reads all the variables from the environment & loads them onto the member variables of the struct
The config.go
file in the config
package is the file that ties all the config together.
This is the main struct for the config which takes all the config type variables as the member variables
This method calls the load method of all the config structs into the singleton configuration
variable. This method is automatically called as the first line in main.go
Each configuration variable (no matter which type) has an accessor method in the config.go
file. Whenever you want to access a config variable anywhere, you should be using these accessor methods to get the config value.