clientset.go 2.9 KB

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