plugin/k8s_external: Resolve headless services (#5505)

*add option for resolving headless Services without external IPs in k8s_external

Signed-off-by: Tomas Kohout <tomas.kohout1995@gmail.com>
This commit is contained in:
TomasKohout
2022-08-30 20:59:27 +02:00
committed by GitHub
parent b218b56063
commit 6782b7fb42
15 changed files with 491 additions and 81 deletions

View File

@@ -8,16 +8,20 @@ import (
func TestSetup(t *testing.T) {
tests := []struct {
input string
shouldErr bool
expectedZone string
expectedApex string
input string
shouldErr bool
expectedZone string
expectedApex string
expectedHeadless bool
}{
{`k8s_external`, false, "", "dns"},
{`k8s_external example.org`, false, "example.org.", "dns"},
{`k8s_external`, false, "", "dns", false},
{`k8s_external example.org`, false, "example.org.", "dns", false},
{`k8s_external example.org {
apex testdns
}`, false, "example.org.", "testdns"},
}`, false, "example.org.", "testdns", false},
{`k8s_external example.org {
headless
}`, false, "example.org.", "dns", true},
}
for i, test := range tests {
@@ -44,5 +48,10 @@ func TestSetup(t *testing.T) {
t.Errorf("Test %d, expected apex %q for input %s, got: %q", i, test.expectedApex, test.input, e.apex)
}
}
if !test.shouldErr {
if test.expectedHeadless != e.headless {
t.Errorf("Test %d, expected headless %q for input %s, got: %v", i, test.expectedApex, test.input, e.headless)
}
}
}
}