clientset.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // Copyright 2026 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. "net/http"
  19. kilov1alpha1 "github.com/squat/kilo/pkg/k8s/clientset/versioned/typed/kilo/v1alpha1"
  20. discovery "k8s.io/client-go/discovery"
  21. rest "k8s.io/client-go/rest"
  22. flowcontrol "k8s.io/client-go/util/flowcontrol"
  23. )
  24. type Interface interface {
  25. Discovery() discovery.DiscoveryInterface
  26. KiloV1alpha1() kilov1alpha1.KiloV1alpha1Interface
  27. }
  28. // Clientset contains the clients for groups.
  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. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
  48. // where httpClient was generated with rest.HTTPClientFor(c).
  49. func NewForConfig(c *rest.Config) (*Clientset, error) {
  50. configShallowCopy := *c
  51. if configShallowCopy.UserAgent == "" {
  52. configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent()
  53. }
  54. // share the transport between all clients
  55. httpClient, err := rest.HTTPClientFor(&configShallowCopy)
  56. if err != nil {
  57. return nil, err
  58. }
  59. return NewForConfigAndClient(&configShallowCopy, httpClient)
  60. }
  61. // NewForConfigAndClient creates a new Clientset for the given config and http client.
  62. // Note the http client provided takes precedence over the configured transport values.
  63. // If config's RateLimiter is not set and QPS and Burst are acceptable,
  64. // NewForConfigAndClient will generate a rate-limiter in configShallowCopy.
  65. func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) {
  66. configShallowCopy := *c
  67. if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
  68. if configShallowCopy.Burst <= 0 {
  69. 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")
  70. }
  71. configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
  72. }
  73. var cs Clientset
  74. var err error
  75. cs.kiloV1alpha1, err = kilov1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
  76. if err != nil {
  77. return nil, err
  78. }
  79. cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient)
  80. if err != nil {
  81. return nil, err
  82. }
  83. return &cs, nil
  84. }
  85. // NewForConfigOrDie creates a new Clientset for the given config and
  86. // panics if there is an error in the config.
  87. func NewForConfigOrDie(c *rest.Config) *Clientset {
  88. cs, err := NewForConfig(c)
  89. if err != nil {
  90. panic(err)
  91. }
  92. return cs
  93. }
  94. // New creates a new Clientset for the given RESTClient.
  95. func New(c rest.Interface) *Clientset {
  96. var cs Clientset
  97. cs.kiloV1alpha1 = kilov1alpha1.New(c)
  98. cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
  99. return &cs
  100. }