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:
parent
979af5301e
commit
64b227b2e1
24 changed files with 93 additions and 87 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue