github.com/openebs/api@v1.12.0/pkg/client/clientset/versioned/clientset.go (about) 1 /* 2 Copyright 2020 The OpenEBS 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 cstorv1 "github.com/openebs/api/pkg/client/clientset/versioned/typed/cstor/v1" 25 openebsv1alpha1 "github.com/openebs/api/pkg/client/clientset/versioned/typed/openebs.io/v1alpha1" 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 CstorV1() cstorv1.CstorV1Interface 34 OpenebsV1alpha1() openebsv1alpha1.OpenebsV1alpha1Interface 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 cstorV1 *cstorv1.CstorV1Client 42 openebsV1alpha1 *openebsv1alpha1.OpenebsV1alpha1Client 43 } 44 45 // CstorV1 retrieves the CstorV1Client 46 func (c *Clientset) CstorV1() cstorv1.CstorV1Interface { 47 return c.cstorV1 48 } 49 50 // OpenebsV1alpha1 retrieves the OpenebsV1alpha1Client 51 func (c *Clientset) OpenebsV1alpha1() openebsv1alpha1.OpenebsV1alpha1Interface { 52 return c.openebsV1alpha1 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.cstorV1, err = cstorv1.NewForConfig(&configShallowCopy) 77 if err != nil { 78 return nil, err 79 } 80 cs.openebsV1alpha1, err = openebsv1alpha1.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.cstorV1 = cstorv1.NewForConfigOrDie(c) 97 cs.openebsV1alpha1 = openebsv1alpha1.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.cstorV1 = cstorv1.New(c) 107 cs.openebsV1alpha1 = openebsv1alpha1.New(c) 108 109 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 110 return &cs 111 }