/
podlist.go
65 lines (52 loc) · 2.25 KB
/
podlist.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
Copyright 2021 The Custom Pod Autoscaler Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fake
import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
corelisters "k8s.io/client-go/listers/core/v1"
)
// PodReadyCounter (fake) provides a way to insert functionality into a PodReadyCounter
type PodReadyCounter struct {
GetReadyPodsCountReactor func(namespace string, selector labels.Selector) (int64, error)
}
// GetReadyPodsCount calls the fake PodReadyCounter function
func (f *PodReadyCounter) GetReadyPodsCount(namespace string, selector labels.Selector) (int64, error) {
return f.GetReadyPodsCountReactor(namespace, selector)
}
// PodLister (fake) provides a way to insert functionality into a PodLister
type PodLister struct {
ListReactor func(selector labels.Selector) (ret []*corev1.Pod, err error)
PodsReactor func(namespace string) corelisters.PodNamespaceLister
}
// List calls the fake PodLister function
func (f *PodLister) List(selector labels.Selector) (ret []*corev1.Pod, err error) {
return f.ListReactor(selector)
}
// Pods calls the fake PodLister function
func (f *PodLister) Pods(namespace string) corelisters.PodNamespaceLister {
return f.PodsReactor(namespace)
}
// PodNamespaceLister (fake) provides a way to insert functionality into a PodNamespaceLister
type PodNamespaceLister struct {
ListReactor func(selector labels.Selector) (ret []*corev1.Pod, err error)
GetReactor func(name string) (*corev1.Pod, error)
}
// List calls the fake PodNamespaceLister function
func (f *PodNamespaceLister) List(selector labels.Selector) (ret []*corev1.Pod, err error) {
return f.ListReactor(selector)
}
// Get calls the fake PodNamespaceLister function
func (f *PodNamespaceLister) Get(name string) (*corev1.Pod, error) {
return f.GetReactor(name)
}