3 Commits

Author SHA1 Message Date
Roman Vynar
bbefd03dbd Release 0.10.2 2024-05-31 18:35:42 +03:00
Roman Vynar
f7e40bece8 Allow to override any config option via environment variables using SECTION_KEY_NAME syntax 2024-05-21 17:01:44 +03:00
Roman Vynar
b49076db7c Fix repo tag count when a repo name is a prefix for another repo name(s) 2024-05-06 16:47:37 +03:00
7 changed files with 17 additions and 6 deletions

View File

@@ -1,5 +1,11 @@
## Changelog ## Changelog
## 0.10.2 (2024-05-31)
* 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)
* Rename cmd flag `-purge-from-repos` to `-purge-include-repos` to purge tags only for the specified repositories. * Rename cmd flag `-purge-from-repos` to `-purge-include-repos` to purge tags only for the specified repositories.

View File

@@ -1,4 +1,4 @@
FROM golang:1.22.2-alpine3.19 as builder FROM golang:1.22.3-alpine3.19 as builder
RUN apk update && \ RUN apk update && \
apk add ca-certificates git bash gcc musl-dev apk add ca-certificates git bash gcc musl-dev

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()

View File

@@ -272,8 +272,8 @@ func (c *Client) GetImageCreated(imageRef string) time.Time {
return cfg.Created.Time return cfg.Created.Time
} }
// TagCounts return map with tag counts according to the provided list of repos/sub-repos etc. // SubRepoTagCounts return map with tag counts according to the provided list of repos/sub-repos etc.
func (c *Client) TagCounts(repoPath string, repos []string) map[string]int { func (c *Client) SubRepoTagCounts(repoPath string, repos []string) map[string]int {
counts := map[string]int{} counts := map[string]int{}
for _, r := range repos { for _, r := range repos {
subRepo := r subRepo := r
@@ -281,7 +281,7 @@ func (c *Client) TagCounts(repoPath string, repos []string) map[string]int {
subRepo = repoPath + "/" + r subRepo = repoPath + "/" + r
} }
for k, v := range c.tagCounts { for k, v := range c.tagCounts {
if strings.HasPrefix(k, subRepo) { if k == subRepo || strings.HasPrefix(k, subRepo+"/") {
counts[subRepo] = counts[subRepo] + v counts[subRepo] = counts[subRepo] + v
} }
} }

View File

@@ -1,3 +1,3 @@
package main package main
const version = "0.10.1" const version = "0.10.2"

2
web.go
View File

@@ -76,7 +76,7 @@ func (a *apiClient) viewCatalog(c echo.Context) error {
} }
data.Set("repos", repos) data.Set("repos", repos)
data.Set("isCatalogReady", a.client.IsCatalogReady()) data.Set("isCatalogReady", a.client.IsCatalogReady())
data.Set("tagCounts", a.client.TagCounts(repoPath, repos)) data.Set("tagCounts", a.client.SubRepoTagCounts(repoPath, repos))
data.Set("tags", tags) data.Set("tags", tags)
if repoPath != "" && (len(repos) > 0 || len(tags) > 0) { if repoPath != "" && (len(repos) > 0 || len(tags) > 0) {
// Do not show events in the root of catalog. // Do not show events in the root of catalog.