Allow to override any config option via environment variables using SECTION_KEY_NAME syntax

This commit is contained in:
Roman Vynar 2024-05-21 17:01:44 +03:00
parent b49076db7c
commit f7e40bece8
3 changed files with 7 additions and 0 deletions

View File

@ -3,6 +3,8 @@
## UNRELEASED ## UNRELEASED
* Fix repo tag count when a repo name is a prefix for another repo name(s) * Fix repo tag count when a repo name is a prefix for another repo name(s)
* Allow to override any config option via environment variables using SECTION_KEY_NAME syntax, e.g.
LISTEN_ADDR, PERFORMANCE_TAGS_COUNT_REFRESH_INTERVAL, REGISTRY_HOSTNAME etc.
## 0.10.1 (2024-04-19) ## 0.10.1 (2024-04-19)

View File

@ -27,6 +27,9 @@ Docker images [quiq/registry-ui](https://hub.docker.com/r/quiq/registry-ui/tags/
The configuration is stored in `config.yml` and the options are self-descriptive. The configuration is stored in `config.yml` and the options are self-descriptive.
You can override any config option via environment variables using SECTION_KEY_NAME syntax,
e.g. `LISTEN_ADDR`, `PERFORMANCE_TAGS_COUNT_REFRESH_INTERVAL`, `REGISTRY_HOSTNAME` etc.
### Run UI ### Run UI
docker run -d -p 8000:8000 -v /local/config.yml:/opt/config.yml:ro quiq/registry-ui docker run -d -p 8000:8000 -v /local/config.yml:/opt/config.yml:ro quiq/registry-ui

View File

@ -51,6 +51,8 @@ func main() {
if err != nil { if err != nil {
panic(fmt.Errorf("fatal error reading config file: %w", err)) panic(fmt.Errorf("fatal error reading config file: %w", err))
} }
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()
// Init registry API client. // Init registry API client.
a.client = registry.NewClient() a.client = registry.NewClient()