middleware/kubernetes: cleanup (#818)

Drop the interfaceAddr interfaces and just use a function. Cleanup
all fallout from that. Remove the use of global variables and cleanup
the tests a bit.
This commit is contained in:
Miek Gieben 2017-08-03 23:14:11 -07:00 committed by GitHub
parent 8ad8c75ab4
commit 2c0fc3182c
8 changed files with 25 additions and 53 deletions

View file

@ -96,19 +96,13 @@ func (APIConnTest) EndpointsList() api.EndpointsList {
func (APIConnTest) GetNodeByName(name string) (api.Node, error) { return api.Node{}, nil }
type interfaceAddrsTest struct{}
func (i interfaceAddrsTest) interfaceAddrs() ([]net.Addr, error) {
_, ipnet, _ := net.ParseCIDR("172.0.40.10/32")
return []net.Addr{ipnet}, nil
}
func TestDoCoreDNSRecord(t *testing.T) {
corednsRecord = dns.A{}
k := Kubernetes{Zones: []string{"inter.webs.test"}}
k.interfaceAddrs = &interfaceAddrsTest{}
k.interfaceAddrsFunc = func() net.IP { return net.ParseIP("172.0.40.10") }
k.APIConn = &APIConnTest{}
cdr := k.coreDNSRecord()