api/docs/content/doc/development/config.md
Dominik Pschenitschni aaa0593289 feat(docs): various improvements
- removing spaces at end of line
- fixing spelling and grammar mistakes
- making sure 'Vikunja' is spelled the same way everywhere
- prefer using editors word wrap instead of hardcoding word wrap in markdown (reason: different word wrap per editor & end of line space)
- add newline add end where missing
- remove double colon at end of headlines
- remove unnecessary indention
- make sure code blocks and headlines etc always have an empty line around
2023-04-11 16:42:59 +00:00

1.4 KiB

date title draft type menu
2019-02-12:00:00+02:00 Configuration Options false doc
sidebar
parent
development

Configuration options

All configuration variables are declared in the config package. It uses viper under the hood to handle setting defaults and parsing config files. Viper handles parsing all different configuration sources.

Adding new config options

To make handling configuration parameters a bit easier, we introduced a Key string type in the config package which you can call directly to get a config value.

To add a new config option, you should add a new key const to pkg/config/config.go and possibly a default value. Default values should always enable the feature to work or turn it off completely if it always needs additional configuration.

Make sure to also add the new config option to the default config file (config.yml.sample at the root of the repository) with an explanatory comment to make sure it is well documented. Then run mage generate-docs to generate the configuration docs from the sample file.

Getting Configuration Values

To retrieve a configured value call the key with a getter for the type you need. For example:

{{< highlight golang >}} if config.CacheEnabled.GetBool() { // Do something with enabled caches } {{< /highlight >}}

Take a look at the methods declared on the type to see what's available.