github.com/nginxinc/kubernetes-ingress@v1.12.5/pkg/client/clientset/versioned/clientset.go (about) 1 // Code generated by client-gen. DO NOT EDIT. 2 3 package versioned 4 5 import ( 6 "fmt" 7 "net/http" 8 9 k8sv1 "github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned/typed/configuration/v1" 10 k8sv1alpha1 "github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned/typed/configuration/v1alpha1" 11 discovery "k8s.io/client-go/discovery" 12 rest "k8s.io/client-go/rest" 13 flowcontrol "k8s.io/client-go/util/flowcontrol" 14 ) 15 16 type Interface interface { 17 Discovery() discovery.DiscoveryInterface 18 K8sV1alpha1() k8sv1alpha1.K8sV1alpha1Interface 19 K8sV1() k8sv1.K8sV1Interface 20 } 21 22 // Clientset contains the clients for groups. Each group has exactly one 23 // version included in a Clientset. 24 type Clientset struct { 25 *discovery.DiscoveryClient 26 k8sV1alpha1 *k8sv1alpha1.K8sV1alpha1Client 27 k8sV1 *k8sv1.K8sV1Client 28 } 29 30 // K8sV1alpha1 retrieves the K8sV1alpha1Client 31 func (c *Clientset) K8sV1alpha1() k8sv1alpha1.K8sV1alpha1Interface { 32 return c.k8sV1alpha1 33 } 34 35 // K8sV1 retrieves the K8sV1Client 36 func (c *Clientset) K8sV1() k8sv1.K8sV1Interface { 37 return c.k8sV1 38 } 39 40 // Discovery retrieves the DiscoveryClient 41 func (c *Clientset) Discovery() discovery.DiscoveryInterface { 42 if c == nil { 43 return nil 44 } 45 return c.DiscoveryClient 46 } 47 48 // NewForConfig creates a new Clientset for the given config. 49 // If config's RateLimiter is not set and QPS and Burst are acceptable, 50 // NewForConfig will generate a rate-limiter in configShallowCopy. 51 // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), 52 // where httpClient was generated with rest.HTTPClientFor(c). 53 func NewForConfig(c *rest.Config) (*Clientset, error) { 54 configShallowCopy := *c 55 56 if configShallowCopy.UserAgent == "" { 57 configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() 58 } 59 60 // share the transport between all clients 61 httpClient, err := rest.HTTPClientFor(&configShallowCopy) 62 if err != nil { 63 return nil, err 64 } 65 66 return NewForConfigAndClient(&configShallowCopy, httpClient) 67 } 68 69 // NewForConfigAndClient creates a new Clientset for the given config and http client. 70 // Note the http client provided takes precedence over the configured transport values. 71 // If config's RateLimiter is not set and QPS and Burst are acceptable, 72 // NewForConfigAndClient will generate a rate-limiter in configShallowCopy. 73 func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { 74 configShallowCopy := *c 75 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 76 if configShallowCopy.Burst <= 0 { 77 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") 78 } 79 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 80 } 81 82 var cs Clientset 83 var err error 84 cs.k8sV1alpha1, err = k8sv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 85 if err != nil { 86 return nil, err 87 } 88 cs.k8sV1, err = k8sv1.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.k8sV1alpha1 = k8sv1alpha1.New(c) 114 cs.k8sV1 = k8sv1.New(c) 115 116 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 117 return &cs 118 }