clientset.go 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. Copyright The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. // Code generated by client-gen. DO NOT EDIT.
  14. package versioned
  15. import (
  16. "fmt"
  17. cephv1 "github.com/rook/rook/pkg/client/clientset/versioned/typed/ceph.rook.io/v1"
  18. discovery "k8s.io/client-go/discovery"
  19. rest "k8s.io/client-go/rest"
  20. flowcontrol "k8s.io/client-go/util/flowcontrol"
  21. )
  22. type Interface interface {
  23. Discovery() discovery.DiscoveryInterface
  24. CephV1() cephv1.CephV1Interface
  25. }
  26. // Clientset contains the clients for groups. Each group has exactly one
  27. // version included in a Clientset.
  28. type Clientset struct {
  29. *discovery.DiscoveryClient
  30. cephV1 *cephv1.CephV1Client
  31. }
  32. // CephV1 retrieves the CephV1Client
  33. func (c *Clientset) CephV1() cephv1.CephV1Interface {
  34. return c.cephV1
  35. }
  36. // Discovery retrieves the DiscoveryClient
  37. func (c *Clientset) Discovery() discovery.DiscoveryInterface {
  38. if c == nil {
  39. return nil
  40. }
  41. return c.DiscoveryClient
  42. }
  43. // NewForConfig creates a new Clientset for the given config.
  44. // If config's RateLimiter is not set and QPS and Burst are acceptable,
  45. // NewForConfig will generate a rate-limiter in configShallowCopy.
  46. func NewForConfig(c *rest.Config) (*Clientset, error) {
  47. configShallowCopy := *c
  48. if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
  49. if configShallowCopy.Burst <= 0 {
  50. 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")
  51. }
  52. configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
  53. }
  54. var cs Clientset
  55. var err error
  56. cs.cephV1, err = cephv1.NewForConfig(&configShallowCopy)
  57. if err != nil {
  58. return nil, err
  59. }
  60. cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
  61. if err != nil {
  62. return nil, err
  63. }
  64. return &cs, nil
  65. }
  66. // NewForConfigOrDie creates a new Clientset for the given config and
  67. // panics if there is an error in the config.
  68. func NewForConfigOrDie(c *rest.Config) *Clientset {
  69. var cs Clientset
  70. cs.cephV1 = cephv1.NewForConfigOrDie(c)
  71. cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
  72. return &cs
  73. }
  74. // New creates a new Clientset for the given RESTClient.
  75. func New(c rest.Interface) *Clientset {
  76. var cs Clientset
  77. cs.cephV1 = cephv1.New(c)
  78. cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
  79. return &cs
  80. }