| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package fake |
| 18 |
|
| 19 |
import ( |
| 20 |
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 |
"k8s.io/apimachinery/pkg/labels" |
| 22 |
"k8s.io/apimachinery/pkg/runtime/schema" |
| 23 |
"k8s.io/client-go/testing" |
| 24 |
"k8s.io/metrics/pkg/apis/external_metrics/v1beta1" |
| 25 |
eclient "k8s.io/metrics/pkg/client/external_metrics" |
| 26 |
) |
| 27 |
|
| 28 |
type FakeExternalMetricsClient struct { |
| 29 |
testing.Fake |
| 30 |
} |
| 31 |
|
| 32 |
func (c *FakeExternalMetricsClient) NamespacedMetrics(namespace string) eclient.MetricsInterface { |
| 33 |
return &fakeNamespacedMetrics{ |
| 34 |
Fake: c, |
| 35 |
ns: namespace, |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
type fakeNamespacedMetrics struct { |
| 40 |
Fake *FakeExternalMetricsClient |
| 41 |
ns string |
| 42 |
} |
| 43 |
|
| 44 |
func (m *fakeNamespacedMetrics) List(metricName string, metricSelector labels.Selector) (*v1beta1.ExternalMetricValueList, error) { |
| 45 |
resource := schema.GroupResource{ |
| 46 |
Group: v1beta1.SchemeGroupVersion.Group, |
| 47 |
Resource: metricName, |
| 48 |
} |
| 49 |
kind := schema.GroupKind{ |
| 50 |
Group: v1beta1.SchemeGroupVersion.Group, |
| 51 |
Kind: "ExternalMetricValue", |
| 52 |
} |
| 53 |
action := testing.NewListAction(resource.WithVersion(""), kind.WithVersion(""), m.ns, metav1.ListOptions{LabelSelector: metricSelector.String()}) |
| 54 |
obj, err := m.Fake. |
| 55 |
Invokes(action, &v1beta1.ExternalMetricValueList{}) |
| 56 |
|
| 57 |
if obj == nil { |
| 58 |
return nil, err |
| 59 |
} |
| 60 |
|
| 61 |
return obj.(*v1beta1.ExternalMetricValueList), err |
| 62 |
} |