agones.dev/agones@v1.53.0/pkg/client/clientset/versioned/clientset.go (about) 1 // Copyright 2024 Google LLC All Rights Reserved. 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 15 // This code was autogenerated. Do not edit directly. 16 17 // Code generated by client-gen. DO NOT EDIT. 18 19 package versioned 20 21 import ( 22 fmt "fmt" 23 http "net/http" 24 25 agonesv1 "agones.dev/agones/pkg/client/clientset/versioned/typed/agones/v1" 26 allocationv1 "agones.dev/agones/pkg/client/clientset/versioned/typed/allocation/v1" 27 autoscalingv1 "agones.dev/agones/pkg/client/clientset/versioned/typed/autoscaling/v1" 28 multiclusterv1 "agones.dev/agones/pkg/client/clientset/versioned/typed/multicluster/v1" 29 discovery "k8s.io/client-go/discovery" 30 rest "k8s.io/client-go/rest" 31 flowcontrol "k8s.io/client-go/util/flowcontrol" 32 ) 33 34 type Interface interface { 35 Discovery() discovery.DiscoveryInterface 36 AgonesV1() agonesv1.AgonesV1Interface 37 AllocationV1() allocationv1.AllocationV1Interface 38 AutoscalingV1() autoscalingv1.AutoscalingV1Interface 39 MulticlusterV1() multiclusterv1.MulticlusterV1Interface 40 } 41 42 // Clientset contains the clients for groups. 43 type Clientset struct { 44 *discovery.DiscoveryClient 45 agonesV1 *agonesv1.AgonesV1Client 46 allocationV1 *allocationv1.AllocationV1Client 47 autoscalingV1 *autoscalingv1.AutoscalingV1Client 48 multiclusterV1 *multiclusterv1.MulticlusterV1Client 49 } 50 51 // AgonesV1 retrieves the AgonesV1Client 52 func (c *Clientset) AgonesV1() agonesv1.AgonesV1Interface { 53 return c.agonesV1 54 } 55 56 // AllocationV1 retrieves the AllocationV1Client 57 func (c *Clientset) AllocationV1() allocationv1.AllocationV1Interface { 58 return c.allocationV1 59 } 60 61 // AutoscalingV1 retrieves the AutoscalingV1Client 62 func (c *Clientset) AutoscalingV1() autoscalingv1.AutoscalingV1Interface { 63 return c.autoscalingV1 64 } 65 66 // MulticlusterV1 retrieves the MulticlusterV1Client 67 func (c *Clientset) MulticlusterV1() multiclusterv1.MulticlusterV1Interface { 68 return c.multiclusterV1 69 } 70 71 // Discovery retrieves the DiscoveryClient 72 func (c *Clientset) Discovery() discovery.DiscoveryInterface { 73 if c == nil { 74 return nil 75 } 76 return c.DiscoveryClient 77 } 78 79 // NewForConfig creates a new Clientset for the given config. 80 // If config's RateLimiter is not set and QPS and Burst are acceptable, 81 // NewForConfig will generate a rate-limiter in configShallowCopy. 82 // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), 83 // where httpClient was generated with rest.HTTPClientFor(c). 84 func NewForConfig(c *rest.Config) (*Clientset, error) { 85 configShallowCopy := *c 86 87 if configShallowCopy.UserAgent == "" { 88 configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() 89 } 90 91 // share the transport between all clients 92 httpClient, err := rest.HTTPClientFor(&configShallowCopy) 93 if err != nil { 94 return nil, err 95 } 96 97 return NewForConfigAndClient(&configShallowCopy, httpClient) 98 } 99 100 // NewForConfigAndClient creates a new Clientset for the given config and http client. 101 // Note the http client provided takes precedence over the configured transport values. 102 // If config's RateLimiter is not set and QPS and Burst are acceptable, 103 // NewForConfigAndClient will generate a rate-limiter in configShallowCopy. 104 func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { 105 configShallowCopy := *c 106 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 107 if configShallowCopy.Burst <= 0 { 108 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") 109 } 110 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 111 } 112 113 var cs Clientset 114 var err error 115 cs.agonesV1, err = agonesv1.NewForConfigAndClient(&configShallowCopy, httpClient) 116 if err != nil { 117 return nil, err 118 } 119 cs.allocationV1, err = allocationv1.NewForConfigAndClient(&configShallowCopy, httpClient) 120 if err != nil { 121 return nil, err 122 } 123 cs.autoscalingV1, err = autoscalingv1.NewForConfigAndClient(&configShallowCopy, httpClient) 124 if err != nil { 125 return nil, err 126 } 127 cs.multiclusterV1, err = multiclusterv1.NewForConfigAndClient(&configShallowCopy, httpClient) 128 if err != nil { 129 return nil, err 130 } 131 132 cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) 133 if err != nil { 134 return nil, err 135 } 136 return &cs, nil 137 } 138 139 // NewForConfigOrDie creates a new Clientset for the given config and 140 // panics if there is an error in the config. 141 func NewForConfigOrDie(c *rest.Config) *Clientset { 142 cs, err := NewForConfig(c) 143 if err != nil { 144 panic(err) 145 } 146 return cs 147 } 148 149 // New creates a new Clientset for the given RESTClient. 150 func New(c rest.Interface) *Clientset { 151 var cs Clientset 152 cs.agonesV1 = agonesv1.New(c) 153 cs.allocationV1 = allocationv1.New(c) 154 cs.autoscalingV1 = autoscalingv1.New(c) 155 cs.multiclusterV1 = multiclusterv1.New(c) 156 157 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 158 return &cs 159 }