github.com/mirantis/virtlet@v1.5.2-0.20191204181327-1659b8a48e9b/pkg/client/clientset/versioned/fake/clientset_generated.go (about) 1 /* 2 Copyright 2019 Mirantis 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 clientset "github.com/Mirantis/virtlet/pkg/client/clientset/versioned" 23 virtletv1 "github.com/Mirantis/virtlet/pkg/client/clientset/versioned/typed/virtlet.k8s/v1" 24 fakevirtletv1 "github.com/Mirantis/virtlet/pkg/client/clientset/versioned/typed/virtlet.k8s/v1/fake" 25 "k8s.io/apimachinery/pkg/runtime" 26 "k8s.io/apimachinery/pkg/watch" 27 "k8s.io/client-go/discovery" 28 fakediscovery "k8s.io/client-go/discovery/fake" 29 "k8s.io/client-go/testing" 30 ) 31 32 // NewSimpleClientset returns a clientset that will respond with the provided objects. 33 // It's backed by a very simple object tracker that processes creates, updates and deletions as-is, 34 // without applying any validations and/or defaults. It shouldn't be considered a replacement 35 // for a real clientset and is mostly useful in simple unit tests. 36 func NewSimpleClientset(objects ...runtime.Object) *Clientset { 37 o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) 38 for _, obj := range objects { 39 if err := o.Add(obj); err != nil { 40 panic(err) 41 } 42 } 43 44 fakePtr := testing.Fake{} 45 fakePtr.AddReactor("*", "*", testing.ObjectReaction(o)) 46 fakePtr.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { 47 gvr := action.GetResource() 48 ns := action.GetNamespace() 49 watch, err := o.Watch(gvr, ns) 50 if err != nil { 51 return false, nil, err 52 } 53 return true, watch, nil 54 }) 55 56 return &Clientset{fakePtr, &fakediscovery.FakeDiscovery{Fake: &fakePtr}} 57 } 58 59 // Clientset implements clientset.Interface. Meant to be embedded into a 60 // struct to get a default implementation. This makes faking out just the method 61 // you want to test easier. 62 type Clientset struct { 63 testing.Fake 64 discovery *fakediscovery.FakeDiscovery 65 } 66 67 func (c *Clientset) Discovery() discovery.DiscoveryInterface { 68 return c.discovery 69 } 70 71 var _ clientset.Interface = &Clientset{} 72 73 // VirtletV1 retrieves the VirtletV1Client 74 func (c *Clientset) VirtletV1() virtletv1.VirtletV1Interface { 75 return &fakevirtletv1.FakeVirtletV1{Fake: &c.Fake} 76 } 77 78 // Virtlet retrieves the VirtletV1Client 79 func (c *Clientset) Virtlet() virtletv1.VirtletV1Interface { 80 return &fakevirtletv1.FakeVirtletV1{Fake: &c.Fake} 81 }