github.com/verrazzano/verrazzano-monitoring-operator@v0.0.30/pkg/client/clientset/versioned/clientset.go (about)

     1  // Copyright (c) 2020, 2022, 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  	verrazzanov1 "github.com/verrazzano/verrazzano-monitoring-operator/pkg/client/clientset/versioned/typed/vmcontroller/v1"
    13  	discovery "k8s.io/client-go/discovery"
    14  	rest "k8s.io/client-go/rest"
    15  	flowcontrol "k8s.io/client-go/util/flowcontrol"
    16  )
    17  
    18  type Interface interface {
    19  	Discovery() discovery.DiscoveryInterface
    20  	VerrazzanoV1() verrazzanov1.VerrazzanoV1Interface
    21  }
    22  
    23  // Clientset contains the clients for groups. Each group has exactly one
    24  // version included in a Clientset.
    25  type Clientset struct {
    26  	*discovery.DiscoveryClient
    27  	verrazzanoV1 *verrazzanov1.VerrazzanoV1Client
    28  }
    29  
    30  // VerrazzanoV1 retrieves the VerrazzanoV1Client
    31  func (c *Clientset) VerrazzanoV1() verrazzanov1.VerrazzanoV1Interface {
    32  	return c.verrazzanoV1
    33  }
    34  
    35  // Discovery retrieves the DiscoveryClient
    36  func (c *Clientset) Discovery() discovery.DiscoveryInterface {
    37  	if c == nil {
    38  		return nil
    39  	}
    40  	return c.DiscoveryClient
    41  }
    42  
    43  // NewForConfig creates a new Clientset for the given config.
    44  // If config's RateLimiter is not set and QPS and Burst are acceptable,
    45  // NewForConfig will generate a rate-limiter in configShallowCopy.
    46  // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
    47  // where httpClient was generated with rest.HTTPClientFor(c).
    48  func NewForConfig(c *rest.Config) (*Clientset, error) {
    49  	configShallowCopy := *c
    50  
    51  	// share the transport between all clients
    52  	httpClient, err := rest.HTTPClientFor(&configShallowCopy)
    53  	if err != nil {
    54  		return nil, err
    55  	}
    56  
    57  	return NewForConfigAndClient(&configShallowCopy, httpClient)
    58  }
    59  
    60  // NewForConfigAndClient creates a new Clientset for the given config and http client.
    61  // Note the http client provided takes precedence over the configured transport values.
    62  // If config's RateLimiter is not set and QPS and Burst are acceptable,
    63  // NewForConfigAndClient will generate a rate-limiter in configShallowCopy.
    64  func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) {
    65  	configShallowCopy := *c
    66  	if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
    67  		if configShallowCopy.Burst <= 0 {
    68  			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")
    69  		}
    70  		configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
    71  	}
    72  
    73  	var cs Clientset
    74  	var err error
    75  	cs.verrazzanoV1, err = verrazzanov1.NewForConfigAndClient(&configShallowCopy, httpClient)
    76  	if err != nil {
    77  		return nil, err
    78  	}
    79  
    80  	cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient)
    81  	if err != nil {
    82  		return nil, err
    83  	}
    84  	return &cs, nil
    85  }
    86  
    87  // NewForConfigOrDie creates a new Clientset for the given config and
    88  // panics if there is an error in the config.
    89  func NewForConfigOrDie(c *rest.Config) *Clientset {
    90  	cs, err := NewForConfig(c)
    91  	if err != nil {
    92  		panic(err)
    93  	}
    94  	return cs
    95  }
    96  
    97  // New creates a new Clientset for the given RESTClient.
    98  func New(c rest.Interface) *Clientset {
    99  	var cs Clientset
   100  	cs.verrazzanoV1 = verrazzanov1.New(c)
   101  
   102  	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
   103  	return &cs
   104  }