aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/reverse_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/kubernetes/reverse_test.go')
-rw-r--r--plugin/kubernetes/reverse_test.go107
1 files changed, 37 insertions, 70 deletions
diff --git a/plugin/kubernetes/reverse_test.go b/plugin/kubernetes/reverse_test.go
index 681172021..a706b7585 100644
--- a/plugin/kubernetes/reverse_test.go
+++ b/plugin/kubernetes/reverse_test.go
@@ -4,6 +4,7 @@ import (
"context"
"testing"
+ "github.com/coredns/coredns/plugin/kubernetes/object"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/pkg/watch"
"github.com/coredns/coredns/plugin/test"
@@ -15,66 +16,50 @@ import (
type APIConnReverseTest struct{}
-func (APIConnReverseTest) HasSynced() bool { return true }
-func (APIConnReverseTest) Run() { return }
-func (APIConnReverseTest) Stop() error { return nil }
-func (APIConnReverseTest) PodIndex(string) []*api.Pod { return nil }
-func (APIConnReverseTest) EpIndex(string) []*api.Endpoints { return nil }
-func (APIConnReverseTest) EndpointsList() []*api.Endpoints { return nil }
-func (APIConnReverseTest) ServiceList() []*api.Service { return nil }
-func (APIConnReverseTest) Modified() int64 { return 0 }
-func (APIConnReverseTest) SetWatchChan(watch.Chan) {}
-func (APIConnReverseTest) Watch(string) error { return nil }
-func (APIConnReverseTest) StopWatching(string) {}
-
-func (APIConnReverseTest) SvcIndex(svc string) []*api.Service {
+func (APIConnReverseTest) HasSynced() bool { return true }
+func (APIConnReverseTest) Run() { return }
+func (APIConnReverseTest) Stop() error { return nil }
+func (APIConnReverseTest) PodIndex(string) []*object.Pod { return nil }
+func (APIConnReverseTest) EpIndex(string) []*object.Endpoints { return nil }
+func (APIConnReverseTest) EndpointsList() []*object.Endpoints { return nil }
+func (APIConnReverseTest) ServiceList() []*object.Service { return nil }
+func (APIConnReverseTest) Modified() int64 { return 0 }
+func (APIConnReverseTest) SetWatchChan(watch.Chan) {}
+func (APIConnReverseTest) Watch(string) error { return nil }
+func (APIConnReverseTest) StopWatching(string) {}
+
+func (APIConnReverseTest) SvcIndex(svc string) []*object.Service {
if svc != "svc1.testns" {
return nil
}
- svcs := []*api.Service{
+ svcs := []*object.Service{
{
- ObjectMeta: meta.ObjectMeta{
- Name: "svc1",
- Namespace: "testns",
- },
- Spec: api.ServiceSpec{
- ClusterIP: "192.168.1.100",
- Ports: []api.ServicePort{{
- Name: "http",
- Protocol: "tcp",
- Port: 80,
- }},
- },
+ Name: "svc1",
+ Namespace: "testns",
+ ClusterIP: "192.168.1.100",
+ Ports: []api.ServicePort{{Name: "http", Protocol: "tcp", Port: 80}},
},
}
return svcs
}
-func (APIConnReverseTest) SvcIndexReverse(ip string) []*api.Service {
+func (APIConnReverseTest) SvcIndexReverse(ip string) []*object.Service {
if ip != "192.168.1.100" {
return nil
}
- svcs := []*api.Service{
+ svcs := []*object.Service{
{
- ObjectMeta: meta.ObjectMeta{
- Name: "svc1",
- Namespace: "testns",
- },
- Spec: api.ServiceSpec{
- ClusterIP: "192.168.1.100",
- Ports: []api.ServicePort{{
- Name: "http",
- Protocol: "tcp",
- Port: 80,
- }},
- },
+ Name: "svc1",
+ Namespace: "testns",
+ ClusterIP: "192.168.1.100",
+ Ports: []api.ServicePort{{Name: "http", Protocol: "tcp", Port: 80}},
},
}
return svcs
}
-func (APIConnReverseTest) EpIndexReverse(ip string) []*api.Endpoints {
+func (APIConnReverseTest) EpIndexReverse(ip string) []*object.Endpoints {
switch ip {
case "10.0.0.100":
case "1234:abcd::1":
@@ -83,41 +68,23 @@ func (APIConnReverseTest) EpIndexReverse(ip string) []*api.Endpoints {
default:
return nil
}
- eps := []*api.Endpoints{
+ eps := []*object.Endpoints{
{
- Subsets: []api.EndpointSubset{
+ Subsets: []object.EndpointSubset{
{
- Addresses: []api.EndpointAddress{
- {
- IP: "10.0.0.100",
- Hostname: "ep1a",
- },
- {
- IP: "1234:abcd::1",
- Hostname: "ep1b",
- },
- {
- IP: "fd00:77:30::a",
- Hostname: "ip6svc1ex",
- },
- {
- IP: "fd00:77:30::2:9ba6",
- Hostname: "ip6svc1in",
- },
+ Addresses: []object.EndpointAddress{
+ {IP: "10.0.0.100", Hostname: "ep1a"},
+ {IP: "1234:abcd::1", Hostname: "ep1b"},
+ {IP: "fd00:77:30::a", Hostname: "ip6svc1ex"},
+ {IP: "fd00:77:30::2:9ba6", Hostname: "ip6svc1in"},
},
- Ports: []api.EndpointPort{
- {
- Port: 80,
- Protocol: "tcp",
- Name: "http",
- },
+ Ports: []object.EndpointPort{
+ {Port: 80, Protocol: "tcp", Name: "http"},
},
},
},
- ObjectMeta: meta.ObjectMeta{
- Name: "svc1",
- Namespace: "testns",
- },
+ Name: "svc1",
+ Namespace: "testns",
},
}
return eps