github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/pkg/client/clientset/versioned/clientset.go (about) 1 /* 2 Copyright (C) 2022-2023 ApeCloud Co., Ltd 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 "net/http" 24 25 appsv1alpha1 "github.com/1aal/kubeblocks/pkg/client/clientset/versioned/typed/apps/v1alpha1" 26 dataprotectionv1alpha1 "github.com/1aal/kubeblocks/pkg/client/clientset/versioned/typed/dataprotection/v1alpha1" 27 extensionsv1alpha1 "github.com/1aal/kubeblocks/pkg/client/clientset/versioned/typed/extensions/v1alpha1" 28 storagev1alpha1 "github.com/1aal/kubeblocks/pkg/client/clientset/versioned/typed/storage/v1alpha1" 29 workloadsv1alpha1 "github.com/1aal/kubeblocks/pkg/client/clientset/versioned/typed/workloads/v1alpha1" 30 discovery "k8s.io/client-go/discovery" 31 rest "k8s.io/client-go/rest" 32 flowcontrol "k8s.io/client-go/util/flowcontrol" 33 ) 34 35 type Interface interface { 36 Discovery() discovery.DiscoveryInterface 37 AppsV1alpha1() appsv1alpha1.AppsV1alpha1Interface 38 DataprotectionV1alpha1() dataprotectionv1alpha1.DataprotectionV1alpha1Interface 39 ExtensionsV1alpha1() extensionsv1alpha1.ExtensionsV1alpha1Interface 40 StorageV1alpha1() storagev1alpha1.StorageV1alpha1Interface 41 WorkloadsV1alpha1() workloadsv1alpha1.WorkloadsV1alpha1Interface 42 } 43 44 // Clientset contains the clients for groups. 45 type Clientset struct { 46 *discovery.DiscoveryClient 47 appsV1alpha1 *appsv1alpha1.AppsV1alpha1Client 48 dataprotectionV1alpha1 *dataprotectionv1alpha1.DataprotectionV1alpha1Client 49 extensionsV1alpha1 *extensionsv1alpha1.ExtensionsV1alpha1Client 50 storageV1alpha1 *storagev1alpha1.StorageV1alpha1Client 51 workloadsV1alpha1 *workloadsv1alpha1.WorkloadsV1alpha1Client 52 } 53 54 // AppsV1alpha1 retrieves the AppsV1alpha1Client 55 func (c *Clientset) AppsV1alpha1() appsv1alpha1.AppsV1alpha1Interface { 56 return c.appsV1alpha1 57 } 58 59 // DataprotectionV1alpha1 retrieves the DataprotectionV1alpha1Client 60 func (c *Clientset) DataprotectionV1alpha1() dataprotectionv1alpha1.DataprotectionV1alpha1Interface { 61 return c.dataprotectionV1alpha1 62 } 63 64 // ExtensionsV1alpha1 retrieves the ExtensionsV1alpha1Client 65 func (c *Clientset) ExtensionsV1alpha1() extensionsv1alpha1.ExtensionsV1alpha1Interface { 66 return c.extensionsV1alpha1 67 } 68 69 // StorageV1alpha1 retrieves the StorageV1alpha1Client 70 func (c *Clientset) StorageV1alpha1() storagev1alpha1.StorageV1alpha1Interface { 71 return c.storageV1alpha1 72 } 73 74 // WorkloadsV1alpha1 retrieves the WorkloadsV1alpha1Client 75 func (c *Clientset) WorkloadsV1alpha1() workloadsv1alpha1.WorkloadsV1alpha1Interface { 76 return c.workloadsV1alpha1 77 } 78 79 // Discovery retrieves the DiscoveryClient 80 func (c *Clientset) Discovery() discovery.DiscoveryInterface { 81 if c == nil { 82 return nil 83 } 84 return c.DiscoveryClient 85 } 86 87 // NewForConfig creates a new Clientset for the given config. 88 // If config's RateLimiter is not set and QPS and Burst are acceptable, 89 // NewForConfig will generate a rate-limiter in configShallowCopy. 90 // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), 91 // where httpClient was generated with rest.HTTPClientFor(c). 92 func NewForConfig(c *rest.Config) (*Clientset, error) { 93 configShallowCopy := *c 94 95 if configShallowCopy.UserAgent == "" { 96 configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() 97 } 98 99 // share the transport between all clients 100 httpClient, err := rest.HTTPClientFor(&configShallowCopy) 101 if err != nil { 102 return nil, err 103 } 104 105 return NewForConfigAndClient(&configShallowCopy, httpClient) 106 } 107 108 // NewForConfigAndClient creates a new Clientset for the given config and http client. 109 // Note the http client provided takes precedence over the configured transport values. 110 // If config's RateLimiter is not set and QPS and Burst are acceptable, 111 // NewForConfigAndClient will generate a rate-limiter in configShallowCopy. 112 func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { 113 configShallowCopy := *c 114 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 115 if configShallowCopy.Burst <= 0 { 116 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") 117 } 118 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 119 } 120 121 var cs Clientset 122 var err error 123 cs.appsV1alpha1, err = appsv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 124 if err != nil { 125 return nil, err 126 } 127 cs.dataprotectionV1alpha1, err = dataprotectionv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 128 if err != nil { 129 return nil, err 130 } 131 cs.extensionsV1alpha1, err = extensionsv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 132 if err != nil { 133 return nil, err 134 } 135 cs.storageV1alpha1, err = storagev1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 136 if err != nil { 137 return nil, err 138 } 139 cs.workloadsV1alpha1, err = workloadsv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 140 if err != nil { 141 return nil, err 142 } 143 144 cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) 145 if err != nil { 146 return nil, err 147 } 148 return &cs, nil 149 } 150 151 // NewForConfigOrDie creates a new Clientset for the given config and 152 // panics if there is an error in the config. 153 func NewForConfigOrDie(c *rest.Config) *Clientset { 154 cs, err := NewForConfig(c) 155 if err != nil { 156 panic(err) 157 } 158 return cs 159 } 160 161 // New creates a new Clientset for the given RESTClient. 162 func New(c rest.Interface) *Clientset { 163 var cs Clientset 164 cs.appsV1alpha1 = appsv1alpha1.New(c) 165 cs.dataprotectionV1alpha1 = dataprotectionv1alpha1.New(c) 166 cs.extensionsV1alpha1 = extensionsv1alpha1.New(c) 167 cs.storageV1alpha1 = storagev1alpha1.New(c) 168 cs.workloadsV1alpha1 = workloadsv1alpha1.New(c) 169 170 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 171 return &cs 172 }