mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 09:36:58 +02:00
fix: zonefinder used a quoted version of %s, but we should use %q instead
change: test message to fit %q Signed-off-by: Sandor Szuecs <sandor.szuecs@zalando.de>
This commit is contained in:
parent
2d898cd88d
commit
fd5e11764b
@ -43,19 +43,19 @@ func (z ZoneIDName) Add(zoneID, zoneName string) {
|
|||||||
// ensures compatibility with such use cases.
|
// ensures compatibility with such use cases.
|
||||||
func (z ZoneIDName) FindZone(hostname string) (suitableZoneID, suitableZoneName string) {
|
func (z ZoneIDName) FindZone(hostname string) (suitableZoneID, suitableZoneName string) {
|
||||||
var name string
|
var name string
|
||||||
domain_labels := strings.Split(hostname, ".")
|
domainLabels := strings.Split(hostname, ".")
|
||||||
for i, label := range domain_labels {
|
for i, label := range domainLabels {
|
||||||
if strings.Contains(label, "_") {
|
if strings.Contains(label, "_") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
convertedLabel, err := idna.Lookup.ToUnicode(label)
|
convertedLabel, err := idna.Lookup.ToUnicode(label)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("Failed to convert label '%s' of hostname '%s' to its Unicode form: %v", label, hostname, err)
|
log.Warnf("Failed to convert label %q of hostname %q to its Unicode form: %v", label, hostname, err)
|
||||||
convertedLabel = label
|
convertedLabel = label
|
||||||
}
|
}
|
||||||
domain_labels[i] = convertedLabel
|
domainLabels[i] = convertedLabel
|
||||||
}
|
}
|
||||||
name = strings.Join(domain_labels, ".")
|
name = strings.Join(domainLabels, ".")
|
||||||
|
|
||||||
for zoneID, zoneName := range z {
|
for zoneID, zoneName := range z {
|
||||||
if name == zoneName || strings.HasSuffix(name, "."+zoneName) {
|
if name == zoneName || strings.HasSuffix(name, "."+zoneName) {
|
||||||
|
@ -80,5 +80,5 @@ func TestZoneIDName(t *testing.T) {
|
|||||||
hook := testutils.LogsUnderTestWithLogLevel(log.WarnLevel, t)
|
hook := testutils.LogsUnderTestWithLogLevel(log.WarnLevel, t)
|
||||||
_, _ = z.FindZone("???")
|
_, _ = z.FindZone("???")
|
||||||
|
|
||||||
testutils.TestHelperLogContains("Failed to convert label '???' of hostname '???' to its Unicode form: idna: disallowed rune U+003F", hook, t)
|
testutils.TestHelperLogContains("Failed to convert label \"???\" of hostname \"???\" to its Unicode form: idna: disallowed rune U+003F", hook, t)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user