| 
									
										
										
										
											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"
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | )
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type APIConnFederationTest struct{}
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-20 22:53:17 +01:00
										 |  |  | func (APIConnFederationTest) HasSynced() bool                        { return true }
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | 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 }
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | func (APIConnFederationTest) PodIndex(string) []*api.Pod {
 | 
					
						
							|  |  |  | 	a := []*api.Pod{{
 | 
					
						
							|  |  |  | 		ObjectMeta: meta.ObjectMeta{
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 			Namespace: "podns",
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 		Status: api.PodStatus{
 | 
					
						
							|  |  |  | 			PodIP: "10.240.0.1", // Remote IP set in test.ResponseWriter
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 	}}
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 	return a
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | func (APIConnFederationTest) SvcIndex(string) []*api.Service {
 | 
					
						
							|  |  |  | 	svcs := []*api.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,
 | 
					
						
							|  |  |  | 				}},
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 		{
 | 
					
						
							|  |  |  | 			ObjectMeta: meta.ObjectMeta{
 | 
					
						
							|  |  |  | 				Name:      "hdls1",
 | 
					
						
							|  |  |  | 				Namespace: "testns",
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 			Spec: api.ServiceSpec{
 | 
					
						
							|  |  |  | 				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,
 | 
					
						
							|  |  |  | 				}},
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | 	return svcs
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | func (APIConnFederationTest) ServiceList() []*api.Service {
 | 
					
						
							|  |  |  | 	svcs := []*api.Service{
 | 
					
						
							|  |  |  | 		{
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 			ObjectMeta: meta.ObjectMeta{
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 				Name:      "svc1",
 | 
					
						
							|  |  |  | 				Namespace: "testns",
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 			Spec: api.ServiceSpec{
 | 
					
						
							|  |  |  | 				ClusterIP: "10.0.0.1",
 | 
					
						
							|  |  |  | 				Ports: []api.ServicePort{{
 | 
					
						
							|  |  |  | 					Name:     "http",
 | 
					
						
							|  |  |  | 					Protocol: "tcp",
 | 
					
						
							|  |  |  | 					Port:     80,
 | 
					
						
							|  |  |  | 				}},
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 		{
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 			ObjectMeta: meta.ObjectMeta{
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 				Name:      "hdls1",
 | 
					
						
							|  |  |  | 				Namespace: "testns",
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 			Spec: api.ServiceSpec{
 | 
					
						
							|  |  |  | 				ClusterIP: api.ClusterIPNone,
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 		{
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 			ObjectMeta: meta.ObjectMeta{
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 				Name:      "external",
 | 
					
						
							|  |  |  | 				Namespace: "testns",
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 			Spec: api.ServiceSpec{
 | 
					
						
							|  |  |  | 				ExternalName: "ext.interwebs.test",
 | 
					
						
							|  |  |  | 				Ports: []api.ServicePort{{
 | 
					
						
							|  |  |  | 					Name:     "http",
 | 
					
						
							|  |  |  | 					Protocol: "tcp",
 | 
					
						
							|  |  |  | 					Port:     80,
 | 
					
						
							|  |  |  | 				}},
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | 	return svcs
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:30:54 -04:00
										 |  |  | func (APIConnFederationTest) EpIndex(string) []*api.Endpoints {
 | 
					
						
							|  |  |  | 	eps := []*api.Endpoints{
 | 
					
						
							|  |  |  | 		{
 | 
					
						
							|  |  |  | 			Subsets: []api.EndpointSubset{
 | 
					
						
							|  |  |  | 				{
 | 
					
						
							|  |  |  | 					Addresses: []api.EndpointAddress{
 | 
					
						
							|  |  |  | 						{
 | 
					
						
							|  |  |  | 							IP:       "172.0.0.1",
 | 
					
						
							|  |  |  | 							Hostname: "ep1a",
 | 
					
						
							|  |  |  | 						},
 | 
					
						
							|  |  |  | 					},
 | 
					
						
							|  |  |  | 					Ports: []api.EndpointPort{
 | 
					
						
							|  |  |  | 						{
 | 
					
						
							|  |  |  | 							Port:     80,
 | 
					
						
							|  |  |  | 							Protocol: "tcp",
 | 
					
						
							|  |  |  | 							Name:     "http",
 | 
					
						
							|  |  |  | 						},
 | 
					
						
							|  |  |  | 					},
 | 
					
						
							|  |  |  | 				},
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 			ObjectMeta: meta.ObjectMeta{
 | 
					
						
							|  |  |  | 				Name:      "svc1",
 | 
					
						
							|  |  |  | 				Namespace: "testns",
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | 	return eps
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | func (APIConnFederationTest) EndpointsList() []*api.Endpoints {
 | 
					
						
							|  |  |  | 	eps := []*api.Endpoints{
 | 
					
						
							|  |  |  | 		{
 | 
					
						
							|  |  |  | 			Subsets: []api.EndpointSubset{
 | 
					
						
							|  |  |  | 				{
 | 
					
						
							|  |  |  | 					Addresses: []api.EndpointAddress{
 | 
					
						
							|  |  |  | 						{
 | 
					
						
							|  |  |  | 							IP:       "172.0.0.1",
 | 
					
						
							|  |  |  | 							Hostname: "ep1a",
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 						},
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 					},
 | 
					
						
							|  |  |  | 					Ports: []api.EndpointPort{
 | 
					
						
							|  |  |  | 						{
 | 
					
						
							|  |  |  | 							Port:     80,
 | 
					
						
							|  |  |  | 							Protocol: "tcp",
 | 
					
						
							|  |  |  | 							Name:     "http",
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 						},
 | 
					
						
							|  |  |  | 					},
 | 
					
						
							|  |  |  | 				},
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 			},
 | 
					
						
							|  |  |  | 			ObjectMeta: meta.ObjectMeta{
 | 
					
						
							|  |  |  | 				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
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | func (APIConnFederationTest) GetNodeByName(name string) (*api.Node, error) {
 | 
					
						
							|  |  |  | 	return &api.Node{
 | 
					
						
							|  |  |  | 		ObjectMeta: meta.ObjectMeta{
 | 
					
						
							| 
									
										
										
										
											2017-08-18 14:45:20 +01:00
										 |  |  | 			Name: "test.node.foo.bar",
 | 
					
						
							|  |  |  | 			Labels: map[string]string{
 | 
					
						
							|  |  |  | 				kubernetes.LabelRegion: "fd-r",
 | 
					
						
							|  |  |  | 				kubernetes.LabelZone:   "fd-az",
 | 
					
						
							|  |  |  | 			},
 | 
					
						
							|  |  |  | 		},
 | 
					
						
							|  |  |  | 	}, 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
 | 
					
						
							|  |  |  | }
 |