// selectReferral picks the best referral from a list of candidates.
selectReferral picks the best referral from a list of candidates.
// selectReferral picks the best referral from a list of candidates .
func (f Filter) selectReferral(
	oldName string,
	candidates []*resource.Resource) (*resource.Resource, error) {
	candidates = doSieve(candidates, previousNameMatches(oldName))
	candidates = doSieve(candidates, previousIdSelectedByGvk(&f.ReferralTarget))
	candidates = doSieve(candidates, f.roleRefFilter())
	candidates = doSieve(candidates, f.sameCurrentNamespaceAsReferrer())
	if len(candidates) == 1 {
		return candidates[0], nil
	}
	candidates = doSieve(candidates, prefixSuffixEquals(f.Referrer))
	if len(candidates) == 1 {
		return candidates[0], nil
	}
	if len(candidates) == 0 {
		return nil, nil
	}
	if allNamesAreTheSame(candidates) {
		return candidates[0], nil
	}
	ids := getIds(candidates)
	f.failureDetails(candidates)
	return nil, fmt.Errorf(" found multiple possible referrals: %s", ids)
}
func ( f Filter ) selectReferral ( oldName string , candidates [ ] * resource . Resource ) ( * resource . Resource , error ) { candidates = doSieve ( candidates , previousNameMatches ( oldName ) ) candidates = doSieve ( candidates , previousIdSelectedByGvk ( & f . ReferralTarget ) ) candidates = doSieve ( candidates , f . roleRefFilter ( ) ) candidates = doSieve ( candidates , f . sameCurrentNamespaceAsReferrer ( ) ) if len ( candidates ) == 1 { return candidates [ 0 ] , nil } candidates = doSieve ( candidates , prefixSuffixEquals ( f . Referrer ) ) if len ( candidates ) == 1 { return candidates [ 0 ] , nil } if len ( candidates ) == 0 { return nil , nil } if allNamesAreTheSame ( candidates ) { return candidates [ 0 ] , nil } ids := getIds ( candidates ) f . failureDetails ( candidates ) return nil , fmt . Errorf ( " " , ids ) }
selectReferral picks the best referral from a list of candidates.
selectReferral picks the best referral from a list of candidates .
// The name referral that may need to be updated. // Just take the first one.