mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 17:53:21 -04:00 
			
		
		
		
	* Update k8s client-go to v6.0.0 This fix updates k8s client-go to v6.0.0 as CoreDNS is supported in 1.9 and v6.0.0 is the recommended version. There are quite some massive changes that need to be made: 1. k8s.io/client-go/pkg/api/v1 has been changed to k8s.io/api/v1 (repo changed from `client-go` to `api`) 2. kubernetes.Clientset adds one extra layer, so that `kubernetes.Clientset.Services()` and like has been changed to `kubernetes.Clientset.CoreV1().Services()` Also, we have to stick with specific commits of `k8s.io/apimachinery` and the newly introduced `k8s.io/api` because go dep still could not figure out the right version to fetch. Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Update vendor with `dep ensure --update` and `dep prune` Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
		
			
				
	
	
		
			193 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			193 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package federation
 | |
| 
 | |
| import (
 | |
| 	"github.com/coredns/coredns/plugin/kubernetes"
 | |
| 
 | |
| 	api "k8s.io/api/core/v1"
 | |
| 	meta "k8s.io/apimachinery/pkg/apis/meta/v1"
 | |
| )
 | |
| 
 | |
| type APIConnFederationTest struct{}
 | |
| 
 | |
| 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) 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) 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
 | |
| }
 | |
| 
 | |
| func (APIConnFederationTest) ServiceList() []*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
 | |
| }
 | |
| 
 | |
| 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
 | |
| }
 | |
| 
 | |
| func (APIConnFederationTest) EndpointsList() []*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
 | |
| }
 | |
| 
 | |
| func (APIConnFederationTest) GetNodeByName(name string) (*api.Node, error) {
 | |
| 	return &api.Node{
 | |
| 		ObjectMeta: meta.ObjectMeta{
 | |
| 			Name: "test.node.foo.bar",
 | |
| 			Labels: map[string]string{
 | |
| 				kubernetes.LabelRegion: "fd-r",
 | |
| 				kubernetes.LabelZone:   "fd-az",
 | |
| 			},
 | |
| 		},
 | |
| 	}, nil
 | |
| }
 | |
| 
 | |
| func (APIConnFederationTest) GetNamespaceByName(name string) (*api.Namespace, error) {
 | |
| 	return &api.Namespace{
 | |
| 		ObjectMeta: meta.ObjectMeta{
 | |
| 			Name: name,
 | |
| 		},
 | |
| 	}, nil
 | |
| }
 |