func (rs *Registries) Add(r *Registry) {
	AllRegistries.Lock()
	AllRegistries.Registries[r.Name] = r
	AllRegistries.Unlock()
	logrus.Infof("Added new registry: %s", r.Name)
}
Add adds a created registry to the map of AllRegistries using the corresponding locks
package manager
import (
	"net/url"
	"path"
	"path/filepath"
	"runtime"
	"sync"
	"time"
	"github.com/sirupsen/logrus"
	"github.com/spf13/viper"
)
var AllRegistries Registries
var avoidUpdateOnRegistries = make(map[string]struct{})
func init() {
	AllRegistries.Registries = map[string]*Registry{}
	go func() {
		for {
			avoidUpdateOnRegistries = make(map[string]struct{})
			registriesToUpdate := make(map[string]*Registry)
			AllRegistries.Lock()
			for registryName, registry := range AllRegistries.Registries {
				if time.Now().UTC().Sub(registry.LastRefresh) >= registry.TTL {
					registriesToUpdate[registryName] = registry
				}
			}
			AllRegistries.Unlock()
			for registryName, registry := range registriesToUpdate {
				updatedRegistry := registry.Update()
				registriesToUpdate[registryName] = &updatedRegistry
			}
			AllRegistries.Lock()
			for registryName, updatedRegistry := range registriesToUpdate {
				if _, registryExists := AllRegistries.Registries[registryName]; !registryExists {
					continue
				}
				if _, registryWasEdited := avoidUpdateOnRegistries[registryName]; registryWasEdited {
					continue
				}
				AllRegistries.Registries[registryName] = updatedRegistry
			}
			AllRegistries.Unlock()
			time.Sleep(1 * time.Second)
		}
	}()
}
type Registries struct {
	Registries map[string]*Registry
	*viper.Viper
	sync.RWMutex
}