github.com/verrazzano/verrazzano@v1.7.0/platform-operator/clientset/versioned/clientset.go (about)

     1  // Copyright (c) 2020, 2023, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  // Code generated by client-gen. DO NOT EDIT.
     5  
     6  package versioned
     7  
     8  import (
     9  	"fmt"
    10  	"net/http"
    11  
    12  	verrazzanov1alpha1 "github.com/verrazzano/verrazzano/platform-operator/clientset/versioned/typed/verrazzano/v1alpha1"
    13  	verrazzanov1beta1 "github.com/verrazzano/verrazzano/platform-operator/clientset/versioned/typed/verrazzano/v1beta1"
    14  	discovery "k8s.io/client-go/discovery"
    15  	rest "k8s.io/client-go/rest"
    16  	flowcontrol "k8s.io/client-go/util/flowcontrol"
    17  )
    18  
    19  type Interface interface {
    20  	Discovery() discovery.DiscoveryInterface
    21  	VerrazzanoV1beta1() verrazzanov1beta1.VerrazzanoV1beta1Interface
    22  	VerrazzanoV1alpha1() verrazzanov1alpha1.VerrazzanoV1alpha1Interface
    23  }
    24  
    25  // Clientset contains the clients for groups. Each group has exactly one
    26  // version included in a Clientset.
    27  type Clientset struct {
    28  	*discovery.DiscoveryClient
    29  	verrazzanoV1beta1  *verrazzanov1beta1.VerrazzanoV1beta1Client
    30  	verrazzanoV1alpha1 *verrazzanov1alpha1.VerrazzanoV1alpha1Client
    31  }
    32  
    33  // VerrazzanoV1beta1 retrieves the VerrazzanoV1beta1Client
    34  func (c *Clientset) VerrazzanoV1beta1() verrazzanov1beta1.VerrazzanoV1beta1Interface {
    35  	return c.verrazzanoV1beta1
    36  }
    37  
    38  // VerrazzanoV1alpha1 retrieves the VerrazzanoV1alpha1Client
    39  func (c *Clientset) VerrazzanoV1alpha1() verrazzanov1alpha1.VerrazzanoV1alpha1Interface {
    40  	return c.verrazzanoV1alpha1
    41  }
    42  
    43  // Discovery retrieves the DiscoveryClient
    44  func (c *Clientset) Discovery() discovery.DiscoveryInterface {
    45  	if c == nil {
    46  		return nil
    47  	}
    48  	return c.DiscoveryClient
    49  }
    50  
    51  // NewForConfig creates a new Clientset for the given config.
    52  // If config's RateLimiter is not set and QPS and Burst are acceptable,
    53  // NewForConfig will generate a rate-limiter in configShallowCopy.
    54  // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
    55  // where httpClient was generated with rest.HTTPClientFor(c).
    56  func NewForConfig(c *rest.Config) (*Clientset, error) {
    57  	configShallowCopy := *c
    58  
    59  	if configShallowCopy.UserAgent == "" {
    60  		configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent()
    61  	}
    62  
    63  	// share the transport between all clients
    64  	httpClient, err := rest.HTTPClientFor(&configShallowCopy)
    65  	if err != nil {
    66  		return nil, err
    67  	}
    68  
    69  	return NewForConfigAndClient(&configShallowCopy, httpClient)
    70  }
    71  
    72  // NewForConfigAndClient creates a new Clientset for the given config and http client.
    73  // Note the http client provided takes precedence over the configured transport values.
    74  // If config's RateLimiter is not set and QPS and Burst are acceptable,
    75  // NewForConfigAndClient will generate a rate-limiter in configShallowCopy.
    76  func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) {
    77  	configShallowCopy := *c
    78  	if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
    79  		if configShallowCopy.Burst <= 0 {
    80  			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")
    81  		}
    82  		configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
    83  	}
    84  
    85  	var cs Clientset
    86  	var err error
    87  	cs.verrazzanoV1beta1, err = verrazzanov1beta1.NewForConfigAndClient(&configShallowCopy, httpClient)
    88  	if err != nil {
    89  		return nil, err
    90  	}
    91  	cs.verrazzanoV1alpha1, err = verrazzanov1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
    92  	if err != nil {
    93  		return nil, err
    94  	}
    95  
    96  	cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient)
    97  	if err != nil {
    98  		return nil, err
    99  	}
   100  	return &cs, nil
   101  }
   102  
   103  // NewForConfigOrDie creates a new Clientset for the given config and
   104  // panics if there is an error in the config.
   105  func NewForConfigOrDie(c *rest.Config) *Clientset {
   106  	cs, err := NewForConfig(c)
   107  	if err != nil {
   108  		panic(err)
   109  	}
   110  	return cs
   111  }
   112  
   113  // New creates a new Clientset for the given RESTClient.
   114  func New(c rest.Interface) *Clientset {
   115  	var cs Clientset
   116  	cs.verrazzanoV1beta1 = verrazzanov1beta1.New(c)
   117  	cs.verrazzanoV1alpha1 = verrazzanov1alpha1.New(c)
   118  
   119  	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
   120  	return &cs
   121  }