mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	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:
		| @@ -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) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user