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