| 1 |
/* |
| 2 |
Copyright The Kubernetes Authors. |
| 3 |
|
| 4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
you may not use this file except in compliance with the License. |
| 6 |
You may obtain a copy of the License at |
| 7 |
|
| 8 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| 10 |
Unless required by applicable law or agreed to in writing, software |
| 11 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
See the License for the specific language governing permissions and |
| 14 |
limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
// Code generated by client-gen. DO NOT EDIT. |
| 18 |
|
| 19 |
package fake |
| 20 |
|
| 21 |
import ( |
| 22 |
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 23 |
"k8s.io/apimachinery/pkg/runtime" |
| 24 |
"k8s.io/apimachinery/pkg/watch" |
| 25 |
"k8s.io/client-go/discovery" |
| 26 |
fakediscovery "k8s.io/client-go/discovery/fake" |
| 27 |
"k8s.io/client-go/testing" |
| 28 |
clientset "k8s.io/metrics/pkg/client/clientset/versioned" |
| 29 |
metricsv1alpha1 "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1alpha1" |
| 30 |
fakemetricsv1alpha1 "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1alpha1/fake" |
| 31 |
metricsv1beta1 "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1" |
| 32 |
fakemetricsv1beta1 "k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/fake" |
| 33 |
) |
| 34 |
|
| 35 |
// NewSimpleClientset returns a clientset that will respond with the provided objects. |
| 36 |
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, |
| 37 |
// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement |
| 38 |
// for a real clientset and is mostly useful in simple unit tests. |
| 39 |
// |
| 40 |
// DEPRECATED: NewClientset replaces this with support for field management, which significantly improves |
| 41 |
// server side apply testing. NewClientset is only available when apply configurations are generated (e.g. |
| 42 |
// via --with-applyconfig). |
| 43 |
func NewSimpleClientset(objects ...runtime.Object) *Clientset { |
| 44 |
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) |
| 45 |
for _, obj := range objects { |
| 46 |
if err := o.Add(obj); err != nil { |
| 47 |
panic(err) |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
cs := &Clientset{tracker: o} |
| 52 |
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} |
| 53 |
cs.AddReactor("*", "*", testing.ObjectReaction(o)) |
| 54 |
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { |
| 55 |
var opts metav1.ListOptions |
| 56 |
if watchActcion, ok := action.(testing.WatchActionImpl); ok { |
| 57 |
opts = watchActcion.ListOptions |
| 58 |
} |
| 59 |
gvr := action.GetResource() |
| 60 |
ns := action.GetNamespace() |
| 61 |
watch, err := o.Watch(gvr, ns, opts) |
| 62 |
if err != nil { |
| 63 |
return false, nil, err |
| 64 |
} |
| 65 |
return true, watch, nil |
| 66 |
}) |
| 67 |
|
| 68 |
return cs |
| 69 |
} |
| 70 |
|
| 71 |
// Clientset implements clientset.Interface. Meant to be embedded into a |
| 72 |
// struct to get a default implementation. This makes faking out just the method |
| 73 |
// you want to test easier. |
| 74 |
type Clientset struct { |
| 75 |
testing.Fake |
| 76 |
discovery *fakediscovery.FakeDiscovery |
| 77 |
tracker testing.ObjectTracker |
| 78 |
} |
| 79 |
|
| 80 |
func (c *Clientset) Discovery() discovery.DiscoveryInterface { |
| 81 |
return c.discovery |
| 82 |
} |
| 83 |
|
| 84 |
func (c *Clientset) Tracker() testing.ObjectTracker { |
| 85 |
return c.tracker |
| 86 |
} |
| 87 |
|
| 88 |
var ( |
| 89 |
_ clientset.Interface = &Clientset{} |
| 90 |
_ testing.FakeClient = &Clientset{} |
| 91 |
) |
| 92 |
|
| 93 |
// MetricsV1alpha1 retrieves the MetricsV1alpha1Client |
| 94 |
func (c *Clientset) MetricsV1alpha1() metricsv1alpha1.MetricsV1alpha1Interface { |
| 95 |
return &fakemetricsv1alpha1.FakeMetricsV1alpha1{Fake: &c.Fake} |
| 96 |
} |
| 97 |
|
| 98 |
// MetricsV1beta1 retrieves the MetricsV1beta1Client |
| 99 |
func (c *Clientset) MetricsV1beta1() metricsv1beta1.MetricsV1beta1Interface { |
| 100 |
return &fakemetricsv1beta1.FakeMetricsV1beta1{Fake: &c.Fake} |
| 101 |
} |