| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | package federation
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import (
 | 
					
						
							| 
									
										
										
										
											2017-09-14 09:36:06 +01:00
										 |  |  | 	"github.com/coredns/coredns/plugin/kubernetes"
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 	"github.com/coredns/coredns/plugin/kubernetes/object"
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-03 19:11:28 +08:00
										 |  |  | 	api "k8s.io/api/core/v1"
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 	meta "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | )
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 02:07:24 -04:00
										 |  |  | type APIConnFederationTest struct {
 | 
					
						
							|  |  |  | 	zone, region string
 | 
					
						
							|  |  |  | }
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | func (APIConnFederationTest) HasSynced() bool                           { return true }
 | 
					
						
							|  |  |  | func (APIConnFederationTest) Run()                                      { return }
 | 
					
						
							|  |  |  | func (APIConnFederationTest) Stop() error                               { return nil }
 | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | func (APIConnFederationTest) SvcIndexReverse(string) []*object.Service  { return nil }
 | 
					
						
							|  |  |  | func (APIConnFederationTest) EpIndexReverse(string) []*object.Endpoints { return nil }
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | func (APIConnFederationTest) Modified() int64                           { return 0 }
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | func (APIConnFederationTest) PodIndex(string) []*object.Pod {
 | 
					
						
							|  |  |  | 	return []*object.Pod{
 | 
					
						
							|  |  |  | 		{Namespace: "podns", PodIP: "10.240.0.1"}, // Remote IP set in test.ResponseWriter
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | func (APIConnFederationTest) SvcIndex(string) []*object.Service {
 | 
					
						
							|  |  |  | 	svcs := []*object.Service{
 | 
					
						
							|  |  |  | 		{
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 			Name:      "svc1",
 | 
					
						
							|  |  |  | 			Namespace: "testns",
 | 
					
						
							|  |  |  | 			ClusterIP: "10.0.0.1",
 | 
					
						
							|  |  |  | 			Ports: []api.ServicePort{
 | 
					
						
							|  |  |  | 				{Name: "http", Protocol: "tcp", Port: 80},
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | 		{
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 			Name:      "hdls1",
 | 
					
						
							|  |  |  | 			Namespace: "testns",
 | 
					
						
							|  |  |  | 			ClusterIP: api.ClusterIPNone,
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | 		},
 | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | 		{
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 			Name:         "external",
 | 
					
						
							|  |  |  | 			Namespace:    "testns",
 | 
					
						
							|  |  |  | 			ExternalName: "ext.interwebs.test",
 | 
					
						
							|  |  |  | 			Ports: []api.ServicePort{
 | 
					
						
							|  |  |  | 				{Name: "http", Protocol: "tcp", Port: 80},
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | 	return svcs
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | func (APIConnFederationTest) ServiceList() []*object.Service {
 | 
					
						
							|  |  |  | 	svcs := []*object.Service{
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 		{
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 			Name:      "svc1",
 | 
					
						
							|  |  |  | 			Namespace: "testns",
 | 
					
						
							|  |  |  | 			ClusterIP: "10.0.0.1",
 | 
					
						
							|  |  |  | 			Ports: []api.ServicePort{
 | 
					
						
							|  |  |  | 				{Name: "http", Protocol: "tcp", Port: 80},
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 		{
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 			Name:      "hdls1",
 | 
					
						
							|  |  |  | 			Namespace: "testns",
 | 
					
						
							|  |  |  | 			ClusterIP: api.ClusterIPNone,
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 		},
 | 
					
						
							|  |  |  | 		{
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 			Name:         "external",
 | 
					
						
							|  |  |  | 			Namespace:    "testns",
 | 
					
						
							|  |  |  | 			ExternalName: "ext.interwebs.test",
 | 
					
						
							|  |  |  | 			Ports: []api.ServicePort{
 | 
					
						
							|  |  |  | 				{Name: "http", Protocol: "tcp", Port: 80},
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | 	return svcs
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | func (APIConnFederationTest) EpIndex(string) []*object.Endpoints {
 | 
					
						
							|  |  |  | 	eps := []*object.Endpoints{
 | 
					
						
							|  |  |  | 		{
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 			Subsets: []object.EndpointSubset{
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | 				{
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 					Addresses: []object.EndpointAddress{
 | 
					
						
							|  |  |  | 						{IP: "172.0.0.1", Hostname: "ep1a"},
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | 					},
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 					Ports: []object.EndpointPort{
 | 
					
						
							|  |  |  | 						{Port: 80, Protocol: "tcp", Name: "http"},
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | 					},
 | 
					
						
							|  |  |  | 				},
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 			Name:      "svc1",
 | 
					
						
							|  |  |  | 			Namespace: "testns",
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | 		},
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | 	return eps
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | func (APIConnFederationTest) EndpointsList() []*object.Endpoints {
 | 
					
						
							|  |  |  | 	eps := []*object.Endpoints{
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 		{
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 			Subsets: []object.EndpointSubset{
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 				{
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 					Addresses: []object.EndpointAddress{
 | 
					
						
							|  |  |  | 						{IP: "172.0.0.1", Hostname: "ep1a"},
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 					},
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 					Ports: []object.EndpointPort{
 | 
					
						
							|  |  |  | 						{Port: 80, Protocol: "tcp", Name: "http"},
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 					},
 | 
					
						
							|  |  |  | 				},
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 			},
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 			Name:      "svc1",
 | 
					
						
							|  |  |  | 			Namespace: "testns",
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 		},
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 	return eps
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 02:07:24 -04:00
										 |  |  | func (a APIConnFederationTest) GetNodeByName(name string) (*api.Node, error) {
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 	return &api.Node{
 | 
					
						
							|  |  |  | 		ObjectMeta: meta.ObjectMeta{
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 			Name: "test.node.foo.bar",
 | 
					
						
							|  |  |  | 			Labels: map[string]string{
 | 
					
						
							| 
									
										
										
										
											2018-09-12 02:07:24 -04:00
										 |  |  | 				kubernetes.LabelRegion: a.region,
 | 
					
						
							|  |  |  | 				kubernetes.LabelZone:   a.zone,
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 	}, nil
 | 
					
						
							|  |  |  | }
 | 
					
						
							| 
									
										
										
										
											2017-11-13 16:15:10 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | func (APIConnFederationTest) GetNamespaceByName(name string) (*api.Namespace, error) {
 | 
					
						
							|  |  |  | 	return &api.Namespace{
 | 
					
						
							|  |  |  | 		ObjectMeta: meta.ObjectMeta{
 | 
					
						
							|  |  |  | 			Name: name,
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 	}, nil
 | 
					
						
							|  |  |  | }
 |