mirror of
https://github.com/Quiq/docker-registry-ui.git
synced 2025-07-17 07:41:18 +00:00
Don't match regexp if empty
This commit is contained in:
parent
f769e3e5f9
commit
a939599a1c
@ -86,9 +86,13 @@ func PurgeOldTags(client *Client, purgeDryRun bool, purgeTagsKeepDays, purgeTags
|
|||||||
|
|
||||||
// Filter out tags by retention days and regexp
|
// Filter out tags by retention days and regexp
|
||||||
for _, tag := range repos[repo] {
|
for _, tag := range repos[repo] {
|
||||||
regexpMatch, _ := regexp.MatchString(purgeTagsKeepRegexp, tag.name)
|
regexpKeep := false
|
||||||
|
if purgeTagsKeepRegexp != "" {
|
||||||
|
regexpMatch, _ := regexp.MatchString(purgeTagsKeepRegexp, tag.name)
|
||||||
|
regexpKeep = regexpMatch
|
||||||
|
}
|
||||||
delta := int(now.Sub(tag.created).Hours() / 24)
|
delta := int(now.Sub(tag.created).Hours() / 24)
|
||||||
if !regexpMatch && delta > purgeTagsKeepDays {
|
if !regexpKeep && delta > purgeTagsKeepDays {
|
||||||
purgeTags[repo] = append(purgeTags[repo], tag.name)
|
purgeTags[repo] = append(purgeTags[repo], tag.name)
|
||||||
} else {
|
} else {
|
||||||
keepTags[repo] = append(keepTags[repo], tag.name)
|
keepTags[repo] = append(keepTags[repo], tag.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user