mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	use v1.ResourcePods instead of hard coding 'pods'
Signed-off-by: sakeven <jc5930@sina.cn>
This commit is contained in:
		@@ -624,7 +624,7 @@ func (l assignedPodNamespaceLister) Get(name string) (*v1.Pod, error) {
 | 
				
			|||||||
	if len(pod.Spec.NodeName) > 0 {
 | 
						if len(pod.Spec.NodeName) > 0 {
 | 
				
			||||||
		return pod, nil
 | 
							return pod, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil, errors.NewNotFound(schema.GroupResource{Resource: "pods"}, name)
 | 
						return nil, errors.NewNotFound(schema.GroupResource{Resource: string(v1.ResourcePods)}, name)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type podInformer struct {
 | 
					type podInformer struct {
 | 
				
			||||||
@@ -642,7 +642,7 @@ func (i *podInformer) Lister() corelisters.PodLister {
 | 
				
			|||||||
// NewPodInformer creates a shared index informer that returns only non-terminal pods.
 | 
					// NewPodInformer creates a shared index informer that returns only non-terminal pods.
 | 
				
			||||||
func NewPodInformer(client clientset.Interface, resyncPeriod time.Duration) coreinformers.PodInformer {
 | 
					func NewPodInformer(client clientset.Interface, resyncPeriod time.Duration) coreinformers.PodInformer {
 | 
				
			||||||
	selector := fields.ParseSelectorOrDie("status.phase!=" + string(v1.PodSucceeded) + ",status.phase!=" + string(v1.PodFailed))
 | 
						selector := fields.ParseSelectorOrDie("status.phase!=" + string(v1.PodSucceeded) + ",status.phase!=" + string(v1.PodFailed))
 | 
				
			||||||
	lw := cache.NewListWatchFromClient(client.Core().RESTClient(), "pods", metav1.NamespaceAll, selector)
 | 
						lw := cache.NewListWatchFromClient(client.Core().RESTClient(), string(v1.ResourcePods), metav1.NamespaceAll, selector)
 | 
				
			||||||
	return &podInformer{
 | 
						return &podInformer{
 | 
				
			||||||
		informer: cache.NewSharedIndexInformer(lw, &v1.Pod{}, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}),
 | 
							informer: cache.NewSharedIndexInformer(lw, &v1.Pod{}, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -249,7 +249,7 @@ func TestDefaultErrorFunc(t *testing.T) {
 | 
				
			|||||||
	mux := http.NewServeMux()
 | 
						mux := http.NewServeMux()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// FakeHandler musn't be sent requests other than the one you want to test.
 | 
						// FakeHandler musn't be sent requests other than the one you want to test.
 | 
				
			||||||
	mux.Handle(util.Test.ResourcePath("pods", "bar", "foo"), &handler)
 | 
						mux.Handle(util.Test.ResourcePath(string(v1.ResourcePods), "bar", "foo"), &handler)
 | 
				
			||||||
	server := httptest.NewServer(mux)
 | 
						server := httptest.NewServer(mux)
 | 
				
			||||||
	defer server.Close()
 | 
						defer server.Close()
 | 
				
			||||||
	client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &api.Registry.GroupOrDie(v1.GroupName).GroupVersion}})
 | 
						client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &api.Registry.GroupOrDie(v1.GroupName).GroupVersion}})
 | 
				
			||||||
@@ -281,7 +281,7 @@ func TestDefaultErrorFunc(t *testing.T) {
 | 
				
			|||||||
		if !exists {
 | 
							if !exists {
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		handler.ValidateRequest(t, util.Test.ResourcePath("pods", "bar", "foo"), "GET", nil)
 | 
							handler.ValidateRequest(t, util.Test.ResourcePath(string(v1.ResourcePods), "bar", "foo"), "GET", nil)
 | 
				
			||||||
		if e, a := testPod, got; !reflect.DeepEqual(e, a) {
 | 
							if e, a := testPod, got; !reflect.DeepEqual(e, a) {
 | 
				
			||||||
			t.Errorf("Expected %v, got %v", e, a)
 | 
								t.Errorf("Expected %v, got %v", e, a)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -345,7 +345,7 @@ func TestBind(t *testing.T) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		expectedBody := runtime.EncodeOrDie(util.Test.Codec(), item.binding)
 | 
							expectedBody := runtime.EncodeOrDie(util.Test.Codec(), item.binding)
 | 
				
			||||||
		handler.ValidateRequest(t,
 | 
							handler.ValidateRequest(t,
 | 
				
			||||||
			util.Test.SubResourcePath("pods", metav1.NamespaceDefault, "foo", "binding"),
 | 
								util.Test.SubResourcePath(string(v1.ResourcePods), metav1.NamespaceDefault, "foo", "binding"),
 | 
				
			||||||
			"POST", &expectedBody)
 | 
								"POST", &expectedBody)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,7 +55,7 @@ func (fc fakePodConditionUpdater) Update(pod *v1.Pod, podCondition *v1.PodCondit
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func podWithID(id, desiredHost string) *v1.Pod {
 | 
					func podWithID(id, desiredHost string) *v1.Pod {
 | 
				
			||||||
	return &v1.Pod{
 | 
						return &v1.Pod{
 | 
				
			||||||
		ObjectMeta: metav1.ObjectMeta{Name: id, SelfLink: util.Test.SelfLink("pods", id)},
 | 
							ObjectMeta: metav1.ObjectMeta{Name: id, SelfLink: util.Test.SelfLink(string(v1.ResourcePods), id)},
 | 
				
			||||||
		Spec: v1.PodSpec{
 | 
							Spec: v1.PodSpec{
 | 
				
			||||||
			NodeName: desiredHost,
 | 
								NodeName: desiredHost,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -65,7 +65,7 @@ func podWithID(id, desiredHost string) *v1.Pod {
 | 
				
			|||||||
func deletingPod(id string) *v1.Pod {
 | 
					func deletingPod(id string) *v1.Pod {
 | 
				
			||||||
	deletionTimestamp := metav1.Now()
 | 
						deletionTimestamp := metav1.Now()
 | 
				
			||||||
	return &v1.Pod{
 | 
						return &v1.Pod{
 | 
				
			||||||
		ObjectMeta: metav1.ObjectMeta{Name: id, SelfLink: util.Test.SelfLink("pods", id), DeletionTimestamp: &deletionTimestamp},
 | 
							ObjectMeta: metav1.ObjectMeta{Name: id, SelfLink: util.Test.SelfLink(string(v1.ResourcePods), id), DeletionTimestamp: &deletionTimestamp},
 | 
				
			||||||
		Spec: v1.PodSpec{
 | 
							Spec: v1.PodSpec{
 | 
				
			||||||
			NodeName: "",
 | 
								NodeName: "",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user