func()

in azkustodata/trusted_endpoints/trusted_endpoints.go [214:241]


func (trusted *TrustedEndpoints) validateHostnameIsTrusted(host string, loginEndpoint string) error {
	// The loopback is unconditionally allowed (since we trust ourselves)
	if isLocalAddress(host) {
		return nil
	}

	// Either check the override matcher OR the matcher:
	override := trusted.overrideMatcher
	if override != nil && override(host) {
		return nil
	} else {
		matcher, ok := trusted.matchers[strings.ToLower(loginEndpoint)]
		if ok && (*matcher).isMatch(host) {
			return nil
		}
	}

	matcher := trusted.additionalMatcher
	if matcher != nil && matcher.isMatch(host) {
		return nil
	}

	return errors.ES(
		errors.OpUnknown,
		errors.KClientArgs,
		fmt.Sprintf("Can't communicate with '%s' as this hostname is currently not trusted; please see https://aka.ms/kustotrustedendpoints.", host),
	).SetNoRetry()
}