mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #48333 from sakeven/master
Automatic merge from submit-queue (batch tested with PRs 48333, 48806, 49046) use v1.ResourcePods instead of hard coding "pods" Signed-off-by: sakeven <jc5930@sina.cn> **What this PR does / why we need it**: use v1.ResourcePods instead of hard coding 'pods' **Special notes for your reviewer**: **Release note**: ``` NONE ```
This commit is contained in:
commit
686e93bbf1
@ -624,7 +624,7 @@ func (l assignedPodNamespaceLister) Get(name string) (*v1.Pod, error) {
|
||||
if len(pod.Spec.NodeName) > 0 {
|
||||
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 {
|
||||
@ -642,7 +642,7 @@ func (i *podInformer) Lister() corelisters.PodLister {
|
||||
// NewPodInformer creates a shared index informer that returns only non-terminal pods.
|
||||
func NewPodInformer(client clientset.Interface, resyncPeriod time.Duration) coreinformers.PodInformer {
|
||||
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{
|
||||
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()
|
||||
|
||||
// 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)
|
||||
defer server.Close()
|
||||
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 {
|
||||
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) {
|
||||
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)
|
||||
handler.ValidateRequest(t,
|
||||
util.Test.SubResourcePath("pods", metav1.NamespaceDefault, "foo", "binding"),
|
||||
util.Test.SubResourcePath(string(v1.ResourcePods), metav1.NamespaceDefault, "foo", "binding"),
|
||||
"POST", &expectedBody)
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ func (fc fakePodConditionUpdater) Update(pod *v1.Pod, podCondition *v1.PodCondit
|
||||
|
||||
func podWithID(id, desiredHost string) *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{
|
||||
NodeName: desiredHost,
|
||||
},
|
||||
@ -65,7 +65,7 @@ func podWithID(id, desiredHost string) *v1.Pod {
|
||||
func deletingPod(id string) *v1.Pod {
|
||||
deletionTimestamp := metav1.Now()
|
||||
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{
|
||||
NodeName: "",
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user