func GetRegistries(ctx *types.SystemContext) ([]Registry, error) {
	configPath := getConfigPath(ctx)

	configMutex.Lock()
	defer configMutex.Unlock()
	// if the config has already been loaded, return the cached registries
	if registries, inCache := configCache[configPath]; inCache {
		return registries, nil
	}

	// load the config
	config, err := loadRegistryConf(configPath)
	if err != nil {
		// Return an empty []Registry if we use the default config,
		// which implies that the config path of the SystemContext
		// isn't set.  Note: if ctx.SystemRegistriesConfPath points to
		// the default config, we will still return an error.
		if os.IsNotExist(err) && (ctx == nil || ctx.SystemRegistriesConfPath == "") {
			return []Registry{}, nil
		}
		return nil, err
	}

	registries := config.Registries

	// backwards compatibility for v1 configs
	v1Registries, err := getV1Registries(config)
	if err != nil {
		return nil, err
	}
	if len(v1Registries) > 0 {
		if len(registries) > 0 {
			return nil, &InvalidRegistries{s: "mixing sysregistry v1/v2 is not supported"}
		}
		registries = v1Registries
	}

	registries, err = postProcessRegistries(registries)
	if err != nil {
		return nil, err
	}

	// populate the cache
	configCache[configPath] = registries

	return registries, err
}
func GetRegistries(ctx *types.SystemContext) ([]Registry, error) {
	configPath := getConfigPath(ctx)

	configMutex.Lock()
	defer configMutex.Unlock()
	
	if registries, inCache := configCache[configPath]; inCache {
		return registries, nil
	}

	
	config, err := loadRegistryConf(configPath)
	if err != nil {
		
		
		
		
		if os.IsNotExist(err) && (ctx == nil || ctx.SystemRegistriesConfPath == "") {
			return []Registry{}, nil
		}
		return nil, err
	}

	registries := config.Registries

	
	v1Registries, err := getV1Registries(config)
	if err != nil {
		return nil, err
	}
	if len(v1Registries) > 0 {
		if len(registries) > 0 {
			return nil, &InvalidRegistries{s: "mixing sysregistry v1/v2 is not supported"}
		}
		registries = v1Registries
	}

	registries, err = postProcessRegistries(registries)
	if err != nil {
		return nil, err
	}

	
	configCache[configPath] = registries

	return registries, err
}
func GetRegistries ( ctx * types . SystemContext ) ( [ ] Registry , error ) { configPath := getConfigPath ( ctx ) configMutex . Lock ( ) defer configMutex . Unlock ( ) // if the config has already been loaded, return the cached registries if registries , inCache := configCache [ configPath ] ; inCache { return registries , nil } // load the config config , err := loadRegistryConf ( configPath ) if err != nil { // Return an empty []Registry if we use the default config, // which implies that the config path of the SystemContext // isn't set.  Note: if ctx.SystemRegistriesConfPath points to // the default config, we will still return an error. if os . IsNotExist ( err ) && ( ctx == nil || ctx . SystemRegistriesConfPath == " " ) { return [ ] Registry { } , nil } return nil , err } registries := config . Registries // backwards compatibility for v1 configs v1Registries , err := getV1Registries ( config ) if err != nil { return nil , err } if len ( v1Registries ) > 0 { if len ( registries ) > 0 { return nil , & InvalidRegistries { s : " " } } registries = v1Registries } registries , err = postProcessRegistries ( registries ) if err != nil { return nil , err } // populate the cache configCache [ configPath ] = registries return registries , err }
// GetRegistries loads and returns the registries specified in the config.
// Note the parsed content of registry config files is cached.  For reloading,
// use `InvalidateCache` and re-call `GetRegistries`.
GetRegistries loads and returns the registries specified in the config . Note the parsed content of registry config files is cached . For reloading use InvalidateCache and re - call GetRegistries .