aboutsummaryrefslogtreecommitdiff
path: root/plugin/k8s_external/setup_test.go
diff options
context:
space:
mode:
authorGravatar Vancl <liyannois@gmail.com> 2023-03-24 20:52:44 +0800
committerGravatar GitHub <noreply@github.com> 2023-03-24 08:52:44 -0400
commit47dceabfc6465ba6c5d41472d6602d4ad5c9fb1b (patch)
treefd93da074caa38ae954a8d8bacd241aefc401124 /plugin/k8s_external/setup_test.go
parent48c40ae1cd4e0c0a2b6aaf0141c7111822ac7cd3 (diff)
downloadcoredns-47dceabfc6465ba6c5d41472d6602d4ad5c9fb1b.tar.gz
coredns-47dceabfc6465ba6c5d41472d6602d4ad5c9fb1b.tar.zst
coredns-47dceabfc6465ba6c5d41472d6602d4ad5c9fb1b.zip
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>
Diffstat (limited to 'plugin/k8s_external/setup_test.go')
-rw-r--r--plugin/k8s_external/setup_test.go32
1 files changed, 23 insertions, 9 deletions
diff --git a/plugin/k8s_external/setup_test.go b/plugin/k8s_external/setup_test.go
index 351b35a4f..8814554ef 100644
--- a/plugin/k8s_external/setup_test.go
+++ b/plugin/k8s_external/setup_test.go
@@ -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)
+ }
+ }
}
}