pkg/sysregistriesv2/system_registries_v2.go
func (e *Endpoint) RewriteReference(ref reference.Named, prefix string) (reference.Named, error) {
	if ref == nil {
		return nil, fmt.Errorf("provided reference is nil")
	}
	if prefix == "" {
		return ref, nil
	}
	refString := ref.String()
	if refMatchesPrefix(refString, prefix) {
		newNamedRef := strings.Replace(refString, prefix, e.Location, 1)
		newParsedRef, err := reference.ParseNamed(newNamedRef)
		if newParsedRef != nil {
			logrus.Debugf("reference rewritten from '%v' to '%v'", refString, newParsedRef.String())
		}
		if err != nil {
			return nil, errors.Wrapf(err, "error rewriting reference")
		}
		return newParsedRef, nil
	}

	return nil, fmt.Errorf("invalid prefix '%v' for reference '%v'", prefix, refString)
}
func (e *Endpoint) RewriteReference(ref reference.Named, prefix string) (reference.Named, error) {
	if ref == nil {
		return nil, fmt.Errorf("provided reference is nil")
	}
	if prefix == "" {
		return ref, nil
	}
	refString := ref.String()
	if refMatchesPrefix(refString, prefix) {
		newNamedRef := strings.Replace(refString, prefix, e.Location, 1)
		newParsedRef, err := reference.ParseNamed(newNamedRef)
		if newParsedRef != nil {
			logrus.Debugf("reference rewritten from '%v' to '%v'", refString, newParsedRef.String())
		}
		if err != nil {
			return nil, errors.Wrapf(err, "error rewriting reference")
		}
		return newParsedRef, nil
	}

	return nil, fmt.Errorf("invalid prefix '%v' for reference '%v'", prefix, refString)
}
func ( e * Endpoint ) RewriteReference ( ref reference . Named , prefix string ) ( reference . Named , error ) { if ref == nil { return nil , fmt . Errorf ( " " ) } if prefix == " " { return ref , nil } refString := ref . String ( ) if refMatchesPrefix ( refString , prefix ) { newNamedRef := strings . Replace ( refString , prefix , e . Location , 1 ) newParsedRef , err := reference . ParseNamed ( newNamedRef ) if newParsedRef != nil { logrus . Debugf ( " " , refString , newParsedRef . String ( ) ) } if err != nil { return nil , errors . Wrapf ( err , " " ) } return newParsedRef , nil } return nil , fmt . Errorf ( " " , prefix , refString ) }
// RewriteReference will substitute the provided reference `prefix` to the
// endpoints `location` from the `ref` and creates a new named reference from it.
// The function errors if the newly created reference is not parsable.
RewriteReference will substitute the provided reference prefix to the endpoints location from the ref and creates a new named reference from it . The function errors if the newly created reference is not parsable .