github.com/kubernetes-csi/external-snapshotter/client/v4@v4.2.0/clientset/versioned/clientset.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 versioned 20 21 import ( 22 "fmt" 23 24 snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/clientset/versioned/typed/volumesnapshot/v1" 25 snapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/client/v4/clientset/versioned/typed/volumesnapshot/v1beta1" 26 discovery "k8s.io/client-go/discovery" 27 rest "k8s.io/client-go/rest" 28 flowcontrol "k8s.io/client-go/util/flowcontrol" 29 ) 30 31 type Interface interface { 32 Discovery() discovery.DiscoveryInterface 33 SnapshotV1beta1() snapshotv1beta1.SnapshotV1beta1Interface 34 SnapshotV1() snapshotv1.SnapshotV1Interface 35 } 36 37 // Clientset contains the clients for groups. Each group has exactly one 38 // version included in a Clientset. 39 type Clientset struct { 40 *discovery.DiscoveryClient 41 snapshotV1beta1 *snapshotv1beta1.SnapshotV1beta1Client 42 snapshotV1 *snapshotv1.SnapshotV1Client 43 } 44 45 // SnapshotV1beta1 retrieves the SnapshotV1beta1Client 46 func (c *Clientset) SnapshotV1beta1() snapshotv1beta1.SnapshotV1beta1Interface { 47 return c.snapshotV1beta1 48 } 49 50 // SnapshotV1 retrieves the SnapshotV1Client 51 func (c *Clientset) SnapshotV1() snapshotv1.SnapshotV1Interface { 52 return c.snapshotV1 53 } 54 55 // Discovery retrieves the DiscoveryClient 56 func (c *Clientset) Discovery() discovery.DiscoveryInterface { 57 if c == nil { 58 return nil 59 } 60 return c.DiscoveryClient 61 } 62 63 // NewForConfig creates a new Clientset for the given config. 64 // If config's RateLimiter is not set and QPS and Burst are acceptable, 65 // NewForConfig will generate a rate-limiter in configShallowCopy. 66 func NewForConfig(c *rest.Config) (*Clientset, error) { 67 configShallowCopy := *c 68 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 69 if configShallowCopy.Burst <= 0 { 70 return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") 71 } 72 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 73 } 74 var cs Clientset 75 var err error 76 cs.snapshotV1beta1, err = snapshotv1beta1.NewForConfig(&configShallowCopy) 77 if err != nil { 78 return nil, err 79 } 80 cs.snapshotV1, err = snapshotv1.NewForConfig(&configShallowCopy) 81 if err != nil { 82 return nil, err 83 } 84 85 cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) 86 if err != nil { 87 return nil, err 88 } 89 return &cs, nil 90 } 91 92 // NewForConfigOrDie creates a new Clientset for the given config and 93 // panics if there is an error in the config. 94 func NewForConfigOrDie(c *rest.Config) *Clientset { 95 var cs Clientset 96 cs.snapshotV1beta1 = snapshotv1beta1.NewForConfigOrDie(c) 97 cs.snapshotV1 = snapshotv1.NewForConfigOrDie(c) 98 99 cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) 100 return &cs 101 } 102 103 // New creates a new Clientset for the given RESTClient. 104 func New(c rest.Interface) *Clientset { 105 var cs Clientset 106 cs.snapshotV1beta1 = snapshotv1beta1.New(c) 107 cs.snapshotV1 = snapshotv1.New(c) 108 109 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 110 return &cs 111 }