diff --git a/CHANGELOG.md b/CHANGELOG.md index c713dde..8c05b24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## UNRELEASED * 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) diff --git a/README.md b/README.md index c8b82a9..9643a87 100644 --- a/README.md +++ b/README.md @@ -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. +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 docker run -d -p 8000:8000 -v /local/config.yml:/opt/config.yml:ro quiq/registry-ui diff --git a/main.go b/main.go index d9739c5..bb892d0 100644 --- a/main.go +++ b/main.go @@ -51,6 +51,8 @@ func main() { if err != nil { panic(fmt.Errorf("fatal error reading config file: %w", err)) } + viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) + viper.AutomaticEnv() // Init registry API client. a.client = registry.NewClient()