chore: update the version of go-lru we use to the latest available (#1141)

We are now using v2.0.1 in the cve cache logic.
Unfortunately we are also using v0.5.4 indirectly, as it is required for gqlgen, see:
https://github.com/99designs/gqlgen/blob/e6114a2c6af22bcdc92180660a58e6125e7946ad/go.mod#L7

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
Andrei Aaron
2023-01-26 21:14:17 +02:00
committed by GitHub
parent e2c7a3c5ba
commit e04d98272c
2 changed files with 6 additions and 11 deletions
+4 -9
View File
@@ -1,19 +1,19 @@
package trivy
import (
lru "github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru/v2"
cvemodel "zotregistry.io/zot/pkg/extensions/search/cve/model"
"zotregistry.io/zot/pkg/log"
)
type CveCache struct {
cache *lru.Cache
cache *lru.Cache[string, map[string]cvemodel.CVE]
log log.Logger
}
func NewCveCache(size int, log log.Logger) *CveCache {
cache, _ := lru.New(size)
cache, _ := lru.New[string, map[string]cvemodel.CVE](size)
return &CveCache{cache: cache, log: log}
}
@@ -23,12 +23,7 @@ func (cveCache *CveCache) Add(image string, cveMap map[string]cvemodel.CVE) {
}
func (cveCache *CveCache) Get(image string) map[string]cvemodel.CVE {
value, ok := cveCache.cache.Get(image)
if !ok {
return nil
}
cveMap, ok := value.(map[string]cvemodel.CVE)
cveMap, ok := cveCache.cache.Get(image)
if !ok {
return nil
}