github.com/argoproj/argo-events@v1.9.1/pkg/client/sensor/clientset/versioned/clientset.go (about) 1 /* 2 Copyright 2021 BlackRock, Inc. 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 argoprojv1alpha1 "github.com/argoproj/argo-events/pkg/client/sensor/clientset/versioned/typed/sensor/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 ArgoprojV1alpha1() argoprojv1alpha1.ArgoprojV1alpha1Interface 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 argoprojV1alpha1 *argoprojv1alpha1.ArgoprojV1alpha1Client 41 } 42 43 // ArgoprojV1alpha1 retrieves the ArgoprojV1alpha1Client 44 func (c *Clientset) ArgoprojV1alpha1() argoprojv1alpha1.ArgoprojV1alpha1Interface { 45 return c.argoprojV1alpha1 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 // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), 60 // where httpClient was generated with rest.HTTPClientFor(c). 61 func NewForConfig(c *rest.Config) (*Clientset, error) { 62 configShallowCopy := *c 63 64 // share the transport between all clients 65 httpClient, err := rest.HTTPClientFor(&configShallowCopy) 66 if err != nil { 67 return nil, err 68 } 69 70 return NewForConfigAndClient(&configShallowCopy, httpClient) 71 } 72 73 // NewForConfigAndClient creates a new Clientset for the given config and http client. 74 // Note the http client provided takes precedence over the configured transport values. 75 // If config's RateLimiter is not set and QPS and Burst are acceptable, 76 // NewForConfigAndClient will generate a rate-limiter in configShallowCopy. 77 func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { 78 configShallowCopy := *c 79 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 80 if configShallowCopy.Burst <= 0 { 81 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") 82 } 83 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 84 } 85 86 var cs Clientset 87 var err error 88 cs.argoprojV1alpha1, err = argoprojv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 89 if err != nil { 90 return nil, err 91 } 92 93 cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) 94 if err != nil { 95 return nil, err 96 } 97 return &cs, nil 98 } 99 100 // NewForConfigOrDie creates a new Clientset for the given config and 101 // panics if there is an error in the config. 102 func NewForConfigOrDie(c *rest.Config) *Clientset { 103 cs, err := NewForConfig(c) 104 if err != nil { 105 panic(err) 106 } 107 return cs 108 } 109 110 // New creates a new Clientset for the given RESTClient. 111 func New(c rest.Interface) *Clientset { 112 var cs Clientset 113 cs.argoprojV1alpha1 = argoprojv1alpha1.New(c) 114 115 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 116 return &cs 117 }