func postProcessRegistries(regs []Registry) ([]Registry, error) {
	var registries []Registry
	regMap := make(map[string][]Registry)

	for _, reg := range regs {
		var err error

		// make sure Location and Prefix are valid
		reg.Location, err = parseLocation(reg.Location)
		if err != nil {
			return nil, err
		}

		if reg.Prefix == "" {
			reg.Prefix = reg.Location
		} else {
			reg.Prefix, err = parseLocation(reg.Prefix)
			if err != nil {
				return nil, err
			}
		}

		// make sure mirrors are valid
		for _, mir := range reg.Mirrors {
			mir.Location, err = parseLocation(mir.Location)
			if err != nil {
				return nil, err
			}
		}
		registries = append(registries, reg)
		regMap[reg.Location] = append(regMap[reg.Location], reg)
	}

	// Given a registry can be mentioned multiple times (e.g., to have
	// multiple prefixes backed by different mirrors), we need to make sure
	// there are no conflicts among them.
	//
	// Note: we need to iterate over the registries array to ensure a
	// deterministic behavior which is not guaranteed by maps.
	for _, reg := range registries {
		others, _ := regMap[reg.Location]
		for _, other := range others {
			if reg.Insecure != other.Insecure {
				msg := fmt.Sprintf("registry '%s' is defined multiple times with conflicting 'insecure' setting", reg.Location)

				return nil, &InvalidRegistries{s: msg}
			}
			if reg.Blocked != other.Blocked {
				msg := fmt.Sprintf("registry '%s' is defined multiple times with conflicting 'blocked' setting", reg.Location)
				return nil, &InvalidRegistries{s: msg}
			}
		}
	}

	return registries, nil
}
func postProcessRegistries(regs []Registry) ([]Registry, error) {
	var registries []Registry
	regMap := make(map[string][]Registry)

	for _, reg := range regs {
		var err error

		
		reg.Location, err = parseLocation(reg.Location)
		if err != nil {
			return nil, err
		}

		if reg.Prefix == "" {
			reg.Prefix = reg.Location
		} else {
			reg.Prefix, err = parseLocation(reg.Prefix)
			if err != nil {
				return nil, err
			}
		}

		
		for _, mir := range reg.Mirrors {
			mir.Location, err = parseLocation(mir.Location)
			if err != nil {
				return nil, err
			}
		}
		registries = append(registries, reg)
		regMap[reg.Location] = append(regMap[reg.Location], reg)
	}

	
	
	
	
	
	
	for _, reg := range registries {
		others, _ := regMap[reg.Location]
		for _, other := range others {
			if reg.Insecure != other.Insecure {
				msg := fmt.Sprintf("registry '%s' is defined multiple times with conflicting 'insecure' setting", reg.Location)

				return nil, &InvalidRegistries{s: msg}
			}
			if reg.Blocked != other.Blocked {
				msg := fmt.Sprintf("registry '%s' is defined multiple times with conflicting 'blocked' setting", reg.Location)
				return nil, &InvalidRegistries{s: msg}
			}
		}
	}

	return registries, nil
}
func postProcessRegistries ( regs [ ] Registry ) ( [ ] Registry , error ) { var registries [ ] Registry regMap := make ( map [ string ] [ ] Registry ) for _ , reg := range regs { var err error // make sure Location and Prefix are valid reg . Location , err = parseLocation ( reg . Location ) if err != nil { return nil , err } if reg . Prefix == " " { reg . Prefix = reg . Location } else { reg . Prefix , err = parseLocation ( reg . Prefix ) if err != nil { return nil , err } } // make sure mirrors are valid for _ , mir := range reg . Mirrors { mir . Location , err = parseLocation ( mir . Location ) if err != nil { return nil , err } } registries = append ( registries , reg ) regMap [ reg . Location ] = append ( regMap [ reg . Location ] , reg ) } // Given a registry can be mentioned multiple times (e.g., to have // multiple prefixes backed by different mirrors), we need to make sure // there are no conflicts among them. // // Note: we need to iterate over the registries array to ensure a // deterministic behavior which is not guaranteed by maps. for _ , reg := range registries { others , _ := regMap [ reg . Location ] for _ , other := range others { if reg . Insecure != other . Insecure { msg := fmt . Sprintf ( " " , reg . Location ) return nil , & InvalidRegistries { s : msg } } if reg . Blocked != other . Blocked { msg := fmt . Sprintf ( " " , reg . Location ) return nil , & InvalidRegistries { s : msg } } } } return registries , nil }
// postProcessRegistries checks the consistency of all registries (e.g., set
// the Prefix to Location if not set) and applies conflict checks.  It returns an
// array of cleaned registries and error in case of conflicts.
postProcessRegistries checks the consistency of all registries ( e . g . set the Prefix to Location if not set ) and applies conflict checks . It returns an array of cleaned registries and error in case of conflicts .