1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-25 08:19:40 +02:00

chore(code): clean up the code EE-5719 (#9183)

This commit is contained in:
andres-portainer 2023-07-10 23:26:54 -03:00 committed by GitHub
parent 979af5301e
commit 64b227b2e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 93 additions and 87 deletions

View file

@ -4,22 +4,19 @@ import (
"strings"
"time"
"github.com/patrickmn/go-cache"
"github.com/pkg/errors"
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/dataservices"
"github.com/portainer/portainer/api/internal/registryutils"
"github.com/patrickmn/go-cache"
"github.com/pkg/errors"
)
var (
_registriesCache = cache.New(5*time.Minute, 5*time.Minute)
)
var registriesCache = cache.New(5*time.Minute, 5*time.Minute)
type (
RegistryClient struct {
dataStore dataservices.DataStore
}
)
type RegistryClient struct {
dataStore dataservices.DataStore
}
func NewRegistryClient(dataStore dataservices.DataStore) *RegistryClient {
return &RegistryClient{dataStore: dataStore}
@ -130,12 +127,14 @@ func findBestMatchRegistry(repository string, registries []portainer.Registry) (
if match == nil {
return nil, errors.New("no registries matched")
}
_registriesCache.Set(repository, match, 0)
registriesCache.Set(repository, match, 0)
return match, nil
}
func cachedRegistry(cacheKey string) (*portainer.Registry, error) {
r, ok := _registriesCache.Get(cacheKey)
r, ok := registriesCache.Get(cacheKey)
if ok {
registry, ok := r.(portainer.Registry)
if ok {