github.com/verrazzano/verrazzano@v1.7.0/application-operator/clientset/versioned/clientset.go (about) 1 // Copyright (c) 2021, 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 appv1alpha1 "github.com/verrazzano/verrazzano/application-operator/clientset/versioned/typed/app/v1alpha1" 13 clustersv1alpha1 "github.com/verrazzano/verrazzano/application-operator/clientset/versioned/typed/clusters/v1alpha1" 14 oamv1alpha1 "github.com/verrazzano/verrazzano/application-operator/clientset/versioned/typed/oam/v1alpha1" 15 discovery "k8s.io/client-go/discovery" 16 rest "k8s.io/client-go/rest" 17 flowcontrol "k8s.io/client-go/util/flowcontrol" 18 ) 19 20 type Interface interface { 21 Discovery() discovery.DiscoveryInterface 22 AppV1alpha1() appv1alpha1.AppV1alpha1Interface 23 ClustersV1alpha1() clustersv1alpha1.ClustersV1alpha1Interface 24 OamV1alpha1() oamv1alpha1.OamV1alpha1Interface 25 } 26 27 // Clientset contains the clients for groups. Each group has exactly one 28 // version included in a Clientset. 29 type Clientset struct { 30 *discovery.DiscoveryClient 31 appV1alpha1 *appv1alpha1.AppV1alpha1Client 32 clustersV1alpha1 *clustersv1alpha1.ClustersV1alpha1Client 33 oamV1alpha1 *oamv1alpha1.OamV1alpha1Client 34 } 35 36 // AppV1alpha1 retrieves the AppV1alpha1Client 37 func (c *Clientset) AppV1alpha1() appv1alpha1.AppV1alpha1Interface { 38 return c.appV1alpha1 39 } 40 41 // ClustersV1alpha1 retrieves the ClustersV1alpha1Client 42 func (c *Clientset) ClustersV1alpha1() clustersv1alpha1.ClustersV1alpha1Interface { 43 return c.clustersV1alpha1 44 } 45 46 // OamV1alpha1 retrieves the OamV1alpha1Client 47 func (c *Clientset) OamV1alpha1() oamv1alpha1.OamV1alpha1Interface { 48 return c.oamV1alpha1 49 } 50 51 // Discovery retrieves the DiscoveryClient 52 func (c *Clientset) Discovery() discovery.DiscoveryInterface { 53 if c == nil { 54 return nil 55 } 56 return c.DiscoveryClient 57 } 58 59 // NewForConfig creates a new Clientset for the given config. 60 // If config's RateLimiter is not set and QPS and Burst are acceptable, 61 // NewForConfig will generate a rate-limiter in configShallowCopy. 62 // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), 63 // where httpClient was generated with rest.HTTPClientFor(c). 64 func NewForConfig(c *rest.Config) (*Clientset, error) { 65 configShallowCopy := *c 66 67 if configShallowCopy.UserAgent == "" { 68 configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() 69 } 70 71 // share the transport between all clients 72 httpClient, err := rest.HTTPClientFor(&configShallowCopy) 73 if err != nil { 74 return nil, err 75 } 76 77 return NewForConfigAndClient(&configShallowCopy, httpClient) 78 } 79 80 // NewForConfigAndClient creates a new Clientset for the given config and http client. 81 // Note the http client provided takes precedence over the configured transport values. 82 // If config's RateLimiter is not set and QPS and Burst are acceptable, 83 // NewForConfigAndClient will generate a rate-limiter in configShallowCopy. 84 func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { 85 configShallowCopy := *c 86 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 87 if configShallowCopy.Burst <= 0 { 88 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") 89 } 90 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 91 } 92 93 var cs Clientset 94 var err error 95 cs.appV1alpha1, err = appv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 96 if err != nil { 97 return nil, err 98 } 99 cs.clustersV1alpha1, err = clustersv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 100 if err != nil { 101 return nil, err 102 } 103 cs.oamV1alpha1, err = oamv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 104 if err != nil { 105 return nil, err 106 } 107 108 cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) 109 if err != nil { 110 return nil, err 111 } 112 return &cs, nil 113 } 114 115 // NewForConfigOrDie creates a new Clientset for the given config and 116 // panics if there is an error in the config. 117 func NewForConfigOrDie(c *rest.Config) *Clientset { 118 cs, err := NewForConfig(c) 119 if err != nil { 120 panic(err) 121 } 122 return cs 123 } 124 125 // New creates a new Clientset for the given RESTClient. 126 func New(c rest.Interface) *Clientset { 127 var cs Clientset 128 cs.appV1alpha1 = appv1alpha1.New(c) 129 cs.clustersV1alpha1 = clustersv1alpha1.New(c) 130 cs.oamV1alpha1 = oamv1alpha1.New(c) 131 132 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 133 return &cs 134 }