Merge pull request #8339 from owncloud/add-env-in-yaml

feat: use env variable in yaml config files
This commit is contained in:
Michael Barz
2024-02-10 11:08:39 +01:00
committed by GitHub
2 changed files with 16 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
Enhancement: Use environment variables in yaml config files
We added the ability to use environment variables in yaml config files. This allows to use environment variables in the config files of the ocis services which will be replaced by the actual value of the environment variable at runtime.
Example:
```
web:
http:
addr: ${SOME_HTTP_ADDR}
```
This makes it possible to use the same config file for different environments without the need to change the config file itself. This is especially useful when using docker-compose to run the ocis services. It is a common pattern to create an .env file which contains the environment variables for the docker-compose file. Now you can use the same .env file to configure the ocis services.
https://github.com/owncloud/ocis/pull/8339

View File

@@ -20,6 +20,7 @@ var (
func BindSourcesToStructs(service string, dst interface{}) (*gofig.Config, error) {
cnf := gofig.NewWithOptions(service)
cnf.WithOptions(func(options *gofig.Options) {
options.ParseEnv = true
options.DecoderConfig.TagName = decoderConfigTagName
})
cnf.AddDriver(gooyaml.Driver)