plugin/k8s_extenral: Supports fallthrough option (#5959)
* Add fallthrough option to k8s_external plugin to allow transitioning control to the next plugin if the domain is not found * Exit on start up if required plugin is not present. Signed-off-by: vanceli <vanceli@tencent.com> --------- Signed-off-by: vanceli <vanceli@tencent.com> Co-authored-by: vanceli <vanceli@tencent.com>
This commit is contained in:
parent
48c40ae1cd
commit
47dceabfc6
4 changed files with 66 additions and 22 deletions
|
@ -4,24 +4,33 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/coredns/caddy"
|
||||
"github.com/coredns/coredns/plugin/pkg/fall"
|
||||
)
|
||||
|
||||
func TestSetup(t *testing.T) {
|
||||
tests := []struct {
|
||||
input string
|
||||
shouldErr bool
|
||||
expectedZone string
|
||||
expectedApex string
|
||||
expectedHeadless bool
|
||||
input string
|
||||
shouldErr bool
|
||||
expectedZone string
|
||||
expectedApex string
|
||||
expectedHeadless bool
|
||||
expectedFallthrough fall.F
|
||||
}{
|
||||
{`k8s_external`, false, "", "dns", false},
|
||||
{`k8s_external example.org`, false, "example.org.", "dns", false},
|
||||
{`k8s_external`, false, "", "dns", false, fall.Zero},
|
||||
{`k8s_external example.org`, false, "example.org.", "dns", false, fall.Zero},
|
||||
{`k8s_external example.org {
|
||||
apex testdns
|
||||
}`, false, "example.org.", "testdns", false},
|
||||
}`, false, "example.org.", "testdns", false, fall.Zero},
|
||||
{`k8s_external example.org {
|
||||
headless
|
||||
}`, false, "example.org.", "dns", true},
|
||||
}`, false, "example.org.", "dns", true, fall.Zero},
|
||||
{`k8s_external example.org {
|
||||
fallthrough
|
||||
}`, false, "example.org.", "dns", false, fall.Root},
|
||||
{`k8s_external example.org {
|
||||
fallthrough ip6.arpa inaddr.arpa foo.com
|
||||
}`, false, "example.org.", "dns", false,
|
||||
fall.F{Zones: []string{"ip6.arpa.", "inaddr.arpa.", "foo.com."}}},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
|
@ -53,5 +62,10 @@ func TestSetup(t *testing.T) {
|
|||
t.Errorf("Test %d, expected headless %q for input %s, got: %v", i, test.expectedApex, test.input, e.headless)
|
||||
}
|
||||
}
|
||||
if !test.shouldErr {
|
||||
if !e.Fall.Equal(test.expectedFallthrough) {
|
||||
t.Errorf("Test %d, expected to be initialized with fallthrough %q for input %s, got: %v", i, test.expectedFallthrough, test.input, e.Fall)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue