...

Source file src/sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/clientset.go

Documentation: sigs.k8s.io/gateway-api/pkg/client/clientset/versioned

     1  /*
     2  Copyright The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  // Code generated by client-gen. DO NOT EDIT.
    18  
    19  package versioned
    20  
    21  import (
    22  	"fmt"
    23  	"net/http"
    24  
    25  	discovery "k8s.io/client-go/discovery"
    26  	rest "k8s.io/client-go/rest"
    27  	flowcontrol "k8s.io/client-go/util/flowcontrol"
    28  	gatewayv1 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1"
    29  	gatewayv1alpha2 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1alpha2"
    30  	gatewayv1beta1 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1beta1"
    31  )
    32  
    33  type Interface interface {
    34  	Discovery() discovery.DiscoveryInterface
    35  	GatewayV1alpha2() gatewayv1alpha2.GatewayV1alpha2Interface
    36  	GatewayV1beta1() gatewayv1beta1.GatewayV1beta1Interface
    37  	GatewayV1() gatewayv1.GatewayV1Interface
    38  }
    39  
    40  // Clientset contains the clients for groups.
    41  type Clientset struct {
    42  	*discovery.DiscoveryClient
    43  	gatewayV1alpha2 *gatewayv1alpha2.GatewayV1alpha2Client
    44  	gatewayV1beta1  *gatewayv1beta1.GatewayV1beta1Client
    45  	gatewayV1       *gatewayv1.GatewayV1Client
    46  }
    47  
    48  // GatewayV1alpha2 retrieves the GatewayV1alpha2Client
    49  func (c *Clientset) GatewayV1alpha2() gatewayv1alpha2.GatewayV1alpha2Interface {
    50  	return c.gatewayV1alpha2
    51  }
    52  
    53  // GatewayV1beta1 retrieves the GatewayV1beta1Client
    54  func (c *Clientset) GatewayV1beta1() gatewayv1beta1.GatewayV1beta1Interface {
    55  	return c.gatewayV1beta1
    56  }
    57  
    58  // GatewayV1 retrieves the GatewayV1Client
    59  func (c *Clientset) GatewayV1() gatewayv1.GatewayV1Interface {
    60  	return c.gatewayV1
    61  }
    62  
    63  // Discovery retrieves the DiscoveryClient
    64  func (c *Clientset) Discovery() discovery.DiscoveryInterface {
    65  	if c == nil {
    66  		return nil
    67  	}
    68  	return c.DiscoveryClient
    69  }
    70  
    71  // NewForConfig creates a new Clientset for the given config.
    72  // If config's RateLimiter is not set and QPS and Burst are acceptable,
    73  // NewForConfig will generate a rate-limiter in configShallowCopy.
    74  // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
    75  // where httpClient was generated with rest.HTTPClientFor(c).
    76  func NewForConfig(c *rest.Config) (*Clientset, error) {
    77  	configShallowCopy := *c
    78  
    79  	if configShallowCopy.UserAgent == "" {
    80  		configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent()
    81  	}
    82  
    83  	// share the transport between all clients
    84  	httpClient, err := rest.HTTPClientFor(&configShallowCopy)
    85  	if err != nil {
    86  		return nil, err
    87  	}
    88  
    89  	return NewForConfigAndClient(&configShallowCopy, httpClient)
    90  }
    91  
    92  // NewForConfigAndClient creates a new Clientset for the given config and http client.
    93  // Note the http client provided takes precedence over the configured transport values.
    94  // If config's RateLimiter is not set and QPS and Burst are acceptable,
    95  // NewForConfigAndClient will generate a rate-limiter in configShallowCopy.
    96  func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) {
    97  	configShallowCopy := *c
    98  	if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
    99  		if configShallowCopy.Burst <= 0 {
   100  			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")
   101  		}
   102  		configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
   103  	}
   104  
   105  	var cs Clientset
   106  	var err error
   107  	cs.gatewayV1alpha2, err = gatewayv1alpha2.NewForConfigAndClient(&configShallowCopy, httpClient)
   108  	if err != nil {
   109  		return nil, err
   110  	}
   111  	cs.gatewayV1beta1, err = gatewayv1beta1.NewForConfigAndClient(&configShallowCopy, httpClient)
   112  	if err != nil {
   113  		return nil, err
   114  	}
   115  	cs.gatewayV1, err = gatewayv1.NewForConfigAndClient(&configShallowCopy, httpClient)
   116  	if err != nil {
   117  		return nil, err
   118  	}
   119  
   120  	cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient)
   121  	if err != nil {
   122  		return nil, err
   123  	}
   124  	return &cs, nil
   125  }
   126  
   127  // NewForConfigOrDie creates a new Clientset for the given config and
   128  // panics if there is an error in the config.
   129  func NewForConfigOrDie(c *rest.Config) *Clientset {
   130  	cs, err := NewForConfig(c)
   131  	if err != nil {
   132  		panic(err)
   133  	}
   134  	return cs
   135  }
   136  
   137  // New creates a new Clientset for the given RESTClient.
   138  func New(c rest.Interface) *Clientset {
   139  	var cs Clientset
   140  	cs.gatewayV1alpha2 = gatewayv1alpha2.New(c)
   141  	cs.gatewayV1beta1 = gatewayv1beta1.New(c)
   142  	cs.gatewayV1 = gatewayv1.New(c)
   143  
   144  	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
   145  	return &cs
   146  }
   147  

View as plain text