...
1
2
3 package versioned
4
5 import (
6 "fmt"
7
8 quotav1 "github.com/openshift/client-go/quota/clientset/versioned/typed/quota/v1"
9 discovery "k8s.io/client-go/discovery"
10 rest "k8s.io/client-go/rest"
11 flowcontrol "k8s.io/client-go/util/flowcontrol"
12 )
13
14 type Interface interface {
15 Discovery() discovery.DiscoveryInterface
16 QuotaV1() quotav1.QuotaV1Interface
17 }
18
19
20
21 type Clientset struct {
22 *discovery.DiscoveryClient
23 quotaV1 *quotav1.QuotaV1Client
24 }
25
26
27 func (c *Clientset) QuotaV1() quotav1.QuotaV1Interface {
28 return c.quotaV1
29 }
30
31
32 func (c *Clientset) Discovery() discovery.DiscoveryInterface {
33 if c == nil {
34 return nil
35 }
36 return c.DiscoveryClient
37 }
38
39
40
41
42 func NewForConfig(c *rest.Config) (*Clientset, error) {
43 configShallowCopy := *c
44 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
45 if configShallowCopy.Burst <= 0 {
46 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")
47 }
48 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
49 }
50 var cs Clientset
51 var err error
52 cs.quotaV1, err = quotav1.NewForConfig(&configShallowCopy)
53 if err != nil {
54 return nil, err
55 }
56
57 cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
58 if err != nil {
59 return nil, err
60 }
61 return &cs, nil
62 }
63
64
65
66 func NewForConfigOrDie(c *rest.Config) *Clientset {
67 var cs Clientset
68 cs.quotaV1 = quotav1.NewForConfigOrDie(c)
69
70 cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
71 return &cs
72 }
73
74
75 func New(c rest.Interface) *Clientset {
76 var cs Clientset
77 cs.quotaV1 = quotav1.New(c)
78
79 cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
80 return &cs
81 }
82
View as plain text