mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
34 lines
952 B
Go
34 lines
952 B
Go
|
//go:build scrub
|
||
|
// +build scrub
|
||
|
|
||
|
package extensions
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"zotregistry.io/zot/pkg/api/config"
|
||
|
"zotregistry.io/zot/pkg/extensions/scrub"
|
||
|
"zotregistry.io/zot/pkg/log"
|
||
|
"zotregistry.io/zot/pkg/storage"
|
||
|
)
|
||
|
|
||
|
// EnableScrubExtension enables scrub extension.
|
||
|
func EnableScrubExtension(config *config.Config, log log.Logger, run bool, imgStore storage.ImageStore, repo string) {
|
||
|
if !run {
|
||
|
if config.Extensions.Scrub != nil &&
|
||
|
config.Extensions.Scrub.Interval != 0 {
|
||
|
minScrubInterval, _ := time.ParseDuration("2h")
|
||
|
|
||
|
if config.Extensions.Scrub.Interval < minScrubInterval {
|
||
|
config.Extensions.Scrub.Interval = minScrubInterval
|
||
|
|
||
|
log.Warn().Msg("Scrub interval set to too-short interval < 2h, changing scrub duration to 2 hours and continuing.") //nolint:lll // gofumpt conflicts with lll
|
||
|
}
|
||
|
} else {
|
||
|
log.Info().Msg("Scrub config not provided, skipping scrub")
|
||
|
}
|
||
|
} else {
|
||
|
scrub.RunScrubRepo(imgStore, repo, log)
|
||
|
}
|
||
|
}
|