aboutsummaryrefslogtreecommitdiff
path: root/plugin/federation/kubernetes_api_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/federation/kubernetes_api_test.go')
-rw-r--r--plugin/federation/kubernetes_api_test.go179
1 files changed, 62 insertions, 117 deletions
diff --git a/plugin/federation/kubernetes_api_test.go b/plugin/federation/kubernetes_api_test.go
index f15b0fa23..4b62605d1 100644
--- a/plugin/federation/kubernetes_api_test.go
+++ b/plugin/federation/kubernetes_api_test.go
@@ -2,6 +2,7 @@ package federation
import (
"github.com/coredns/coredns/plugin/kubernetes"
+ "github.com/coredns/coredns/plugin/kubernetes/object"
"github.com/coredns/coredns/plugin/pkg/watch"
api "k8s.io/api/core/v1"
@@ -12,167 +13,111 @@ type APIConnFederationTest struct {
zone, region string
}
-func (APIConnFederationTest) HasSynced() bool { return true }
-func (APIConnFederationTest) Run() { return }
-func (APIConnFederationTest) Stop() error { return nil }
-func (APIConnFederationTest) SvcIndexReverse(string) []*api.Service { return nil }
-func (APIConnFederationTest) EpIndexReverse(string) []*api.Endpoints { return nil }
-func (APIConnFederationTest) Modified() int64 { return 0 }
-func (APIConnFederationTest) SetWatchChan(watch.Chan) {}
-func (APIConnFederationTest) Watch(string) error { return nil }
-func (APIConnFederationTest) StopWatching(string) {}
+func (APIConnFederationTest) HasSynced() bool { return true }
+func (APIConnFederationTest) Run() { return }
+func (APIConnFederationTest) Stop() error { return nil }
+func (APIConnFederationTest) SvcIndexReverse(string) []*object.Service { return nil }
+func (APIConnFederationTest) EpIndexReverse(string) []*object.Endpoints { return nil }
+func (APIConnFederationTest) Modified() int64 { return 0 }
+func (APIConnFederationTest) SetWatchChan(watch.Chan) {}
+func (APIConnFederationTest) Watch(string) error { return nil }
+func (APIConnFederationTest) StopWatching(string) {}
-func (APIConnFederationTest) PodIndex(string) []*api.Pod {
- a := []*api.Pod{{
- ObjectMeta: meta.ObjectMeta{
- Namespace: "podns",
- },
- Status: api.PodStatus{
- PodIP: "10.240.0.1", // Remote IP set in test.ResponseWriter
- },
- }}
- return a
+func (APIConnFederationTest) PodIndex(string) []*object.Pod {
+ return []*object.Pod{
+ {Namespace: "podns", PodIP: "10.240.0.1"}, // Remote IP set in test.ResponseWriter
+ }
}
-func (APIConnFederationTest) SvcIndex(string) []*api.Service {
- svcs := []*api.Service{
+func (APIConnFederationTest) SvcIndex(string) []*object.Service {
+ svcs := []*object.Service{
{
- ObjectMeta: meta.ObjectMeta{
- Name: "svc1",
- Namespace: "testns",
- },
- Spec: api.ServiceSpec{
- ClusterIP: "10.0.0.1",
- Ports: []api.ServicePort{{
- Name: "http",
- Protocol: "tcp",
- Port: 80,
- }},
+ Name: "svc1",
+ Namespace: "testns",
+ ClusterIP: "10.0.0.1",
+ Ports: []api.ServicePort{
+ {Name: "http", Protocol: "tcp", Port: 80},
},
},
{
- ObjectMeta: meta.ObjectMeta{
- Name: "hdls1",
- Namespace: "testns",
- },
- Spec: api.ServiceSpec{
- ClusterIP: api.ClusterIPNone,
- },
+ Name: "hdls1",
+ Namespace: "testns",
+ ClusterIP: api.ClusterIPNone,
},
{
- ObjectMeta: meta.ObjectMeta{
- Name: "external",
- Namespace: "testns",
- },
- Spec: api.ServiceSpec{
- ExternalName: "ext.interwebs.test",
- Ports: []api.ServicePort{{
- Name: "http",
- Protocol: "tcp",
- Port: 80,
- }},
+ Name: "external",
+ Namespace: "testns",
+ ExternalName: "ext.interwebs.test",
+ Ports: []api.ServicePort{
+ {Name: "http", Protocol: "tcp", Port: 80},
},
},
}
return svcs
}
-func (APIConnFederationTest) ServiceList() []*api.Service {
- svcs := []*api.Service{
+func (APIConnFederationTest) ServiceList() []*object.Service {
+ svcs := []*object.Service{
{
- ObjectMeta: meta.ObjectMeta{
- Name: "svc1",
- Namespace: "testns",
- },
- Spec: api.ServiceSpec{
- ClusterIP: "10.0.0.1",
- Ports: []api.ServicePort{{
- Name: "http",
- Protocol: "tcp",
- Port: 80,
- }},
+ Name: "svc1",
+ Namespace: "testns",
+ ClusterIP: "10.0.0.1",
+ Ports: []api.ServicePort{
+ {Name: "http", Protocol: "tcp", Port: 80},
},
},
{
- ObjectMeta: meta.ObjectMeta{
- Name: "hdls1",
- Namespace: "testns",
- },
- Spec: api.ServiceSpec{
- ClusterIP: api.ClusterIPNone,
- },
+ Name: "hdls1",
+ Namespace: "testns",
+ ClusterIP: api.ClusterIPNone,
},
{
- ObjectMeta: meta.ObjectMeta{
- Name: "external",
- Namespace: "testns",
- },
- Spec: api.ServiceSpec{
- ExternalName: "ext.interwebs.test",
- Ports: []api.ServicePort{{
- Name: "http",
- Protocol: "tcp",
- Port: 80,
- }},
+ Name: "external",
+ Namespace: "testns",
+ ExternalName: "ext.interwebs.test",
+ Ports: []api.ServicePort{
+ {Name: "http", Protocol: "tcp", Port: 80},
},
},
}
return svcs
}
-func (APIConnFederationTest) EpIndex(string) []*api.Endpoints {
- eps := []*api.Endpoints{
+func (APIConnFederationTest) EpIndex(string) []*object.Endpoints {
+ eps := []*object.Endpoints{
{
- Subsets: []api.EndpointSubset{
+ Subsets: []object.EndpointSubset{
{
- Addresses: []api.EndpointAddress{
- {
- IP: "172.0.0.1",
- Hostname: "ep1a",
- },
+ Addresses: []object.EndpointAddress{
+ {IP: "172.0.0.1", Hostname: "ep1a"},
},
- 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
}
-func (APIConnFederationTest) EndpointsList() []*api.Endpoints {
- eps := []*api.Endpoints{
+func (APIConnFederationTest) EndpointsList() []*object.Endpoints {
+ eps := []*object.Endpoints{
{
- Subsets: []api.EndpointSubset{
+ Subsets: []object.EndpointSubset{
{
- Addresses: []api.EndpointAddress{
- {
- IP: "172.0.0.1",
- Hostname: "ep1a",
- },
+ Addresses: []object.EndpointAddress{
+ {IP: "172.0.0.1", Hostname: "ep1a"},
},
- 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