github.com/spotahome/redis-operator@v1.2.4/client/k8s/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 databasesv1 "github.com/spotahome/redis-operator/client/k8s/clientset/versioned/typed/redisfailover/v1" 10 discovery "k8s.io/client-go/discovery" 11 rest "k8s.io/client-go/rest" 12 flowcontrol "k8s.io/client-go/util/flowcontrol" 13 ) 14 15 type Interface interface { 16 Discovery() discovery.DiscoveryInterface 17 DatabasesV1() databasesv1.DatabasesV1Interface 18 } 19 20 // Clientset contains the clients for groups. Each group has exactly one 21 // version included in a Clientset. 22 type Clientset struct { 23 *discovery.DiscoveryClient 24 databasesV1 *databasesv1.DatabasesV1Client 25 } 26 27 // DatabasesV1 retrieves the DatabasesV1Client 28 func (c *Clientset) DatabasesV1() databasesv1.DatabasesV1Interface { 29 return c.databasesV1 30 } 31 32 // Discovery retrieves the DiscoveryClient 33 func (c *Clientset) Discovery() discovery.DiscoveryInterface { 34 if c == nil { 35 return nil 36 } 37 return c.DiscoveryClient 38 } 39 40 // NewForConfig creates a new Clientset for the given config. 41 // If config's RateLimiter is not set and QPS and Burst are acceptable, 42 // NewForConfig will generate a rate-limiter in configShallowCopy. 43 // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), 44 // where httpClient was generated with rest.HTTPClientFor(c). 45 func NewForConfig(c *rest.Config) (*Clientset, error) { 46 configShallowCopy := *c 47 48 // share the transport between all clients 49 httpClient, err := rest.HTTPClientFor(&configShallowCopy) 50 if err != nil { 51 return nil, err 52 } 53 54 return NewForConfigAndClient(&configShallowCopy, httpClient) 55 } 56 57 // NewForConfigAndClient creates a new Clientset for the given config and http client. 58 // Note the http client provided takes precedence over the configured transport values. 59 // If config's RateLimiter is not set and QPS and Burst are acceptable, 60 // NewForConfigAndClient will generate a rate-limiter in configShallowCopy. 61 func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { 62 configShallowCopy := *c 63 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 64 if configShallowCopy.Burst <= 0 { 65 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") 66 } 67 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 68 } 69 70 var cs Clientset 71 var err error 72 cs.databasesV1, err = databasesv1.NewForConfigAndClient(&configShallowCopy, httpClient) 73 if err != nil { 74 return nil, err 75 } 76 77 cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) 78 if err != nil { 79 return nil, err 80 } 81 return &cs, nil 82 } 83 84 // NewForConfigOrDie creates a new Clientset for the given config and 85 // panics if there is an error in the config. 86 func NewForConfigOrDie(c *rest.Config) *Clientset { 87 cs, err := NewForConfig(c) 88 if err != nil { 89 panic(err) 90 } 91 return cs 92 } 93 94 // New creates a new Clientset for the given RESTClient. 95 func New(c rest.Interface) *Clientset { 96 var cs Clientset 97 cs.databasesV1 = databasesv1.New(c) 98 99 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 100 return &cs 101 }