vitess.io/vitess@v0.16.2/go/vt/topo/k8stopo/client/clientset/versioned/clientset.go (about) 1 /* 2 Copyright 2020 The Vitess 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 discovery "k8s.io/client-go/discovery" 25 rest "k8s.io/client-go/rest" 26 flowcontrol "k8s.io/client-go/util/flowcontrol" 27 28 topov1beta1 "vitess.io/vitess/go/vt/topo/k8stopo/client/clientset/versioned/typed/topo/v1beta1" 29 ) 30 31 type Interface interface { 32 Discovery() discovery.DiscoveryInterface 33 TopoV1beta1() topov1beta1.TopoV1beta1Interface 34 } 35 36 // Clientset contains the clients for groups. Each group has exactly one 37 // version included in a Clientset. 38 type Clientset struct { 39 *discovery.DiscoveryClient 40 topoV1beta1 *topov1beta1.TopoV1beta1Client 41 } 42 43 // TopoV1beta1 retrieves the TopoV1beta1Client 44 func (c *Clientset) TopoV1beta1() topov1beta1.TopoV1beta1Interface { 45 return c.topoV1beta1 46 } 47 48 // Discovery retrieves the DiscoveryClient 49 func (c *Clientset) Discovery() discovery.DiscoveryInterface { 50 if c == nil { 51 return nil 52 } 53 return c.DiscoveryClient 54 } 55 56 // NewForConfig creates a new Clientset for the given config. 57 // If config's RateLimiter is not set and QPS and Burst are acceptable, 58 // NewForConfig will generate a rate-limiter in configShallowCopy. 59 func NewForConfig(c *rest.Config) (*Clientset, error) { 60 configShallowCopy := *c 61 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 62 if configShallowCopy.Burst <= 0 { 63 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") 64 } 65 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 66 } 67 var cs Clientset 68 var err error 69 cs.topoV1beta1, err = topov1beta1.NewForConfig(&configShallowCopy) 70 if err != nil { 71 return nil, err 72 } 73 74 cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) 75 if err != nil { 76 return nil, err 77 } 78 return &cs, nil 79 } 80 81 // NewForConfigOrDie creates a new Clientset for the given config and 82 // panics if there is an error in the config. 83 func NewForConfigOrDie(c *rest.Config) *Clientset { 84 var cs Clientset 85 cs.topoV1beta1 = topov1beta1.NewForConfigOrDie(c) 86 87 cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) 88 return &cs 89 } 90 91 // New creates a new Clientset for the given RESTClient. 92 func New(c rest.Interface) *Clientset { 93 var cs Clientset 94 cs.topoV1beta1 = topov1beta1.New(c) 95 96 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 97 return &cs 98 }