github.com/operator-framework/operator-lifecycle-manager@v0.30.0/pkg/api/client/clientset/versioned/clientset.go (about) 1 /* 2 Copyright Red Hat, Inc. 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 operatorsv1 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1" 26 operatorsv1alpha1 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha1" 27 operatorsv1alpha2 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1alpha2" 28 operatorsv2 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v2" 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 OperatorsV1() operatorsv1.OperatorsV1Interface 37 OperatorsV1alpha1() operatorsv1alpha1.OperatorsV1alpha1Interface 38 OperatorsV1alpha2() operatorsv1alpha2.OperatorsV1alpha2Interface 39 OperatorsV2() operatorsv2.OperatorsV2Interface 40 } 41 42 // Clientset contains the clients for groups. 43 type Clientset struct { 44 *discovery.DiscoveryClient 45 operatorsV1 *operatorsv1.OperatorsV1Client 46 operatorsV1alpha1 *operatorsv1alpha1.OperatorsV1alpha1Client 47 operatorsV1alpha2 *operatorsv1alpha2.OperatorsV1alpha2Client 48 operatorsV2 *operatorsv2.OperatorsV2Client 49 } 50 51 // OperatorsV1 retrieves the OperatorsV1Client 52 func (c *Clientset) OperatorsV1() operatorsv1.OperatorsV1Interface { 53 return c.operatorsV1 54 } 55 56 // OperatorsV1alpha1 retrieves the OperatorsV1alpha1Client 57 func (c *Clientset) OperatorsV1alpha1() operatorsv1alpha1.OperatorsV1alpha1Interface { 58 return c.operatorsV1alpha1 59 } 60 61 // OperatorsV1alpha2 retrieves the OperatorsV1alpha2Client 62 func (c *Clientset) OperatorsV1alpha2() operatorsv1alpha2.OperatorsV1alpha2Interface { 63 return c.operatorsV1alpha2 64 } 65 66 // OperatorsV2 retrieves the OperatorsV2Client 67 func (c *Clientset) OperatorsV2() operatorsv2.OperatorsV2Interface { 68 return c.operatorsV2 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.operatorsV1, err = operatorsv1.NewForConfigAndClient(&configShallowCopy, httpClient) 116 if err != nil { 117 return nil, err 118 } 119 cs.operatorsV1alpha1, err = operatorsv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) 120 if err != nil { 121 return nil, err 122 } 123 cs.operatorsV1alpha2, err = operatorsv1alpha2.NewForConfigAndClient(&configShallowCopy, httpClient) 124 if err != nil { 125 return nil, err 126 } 127 cs.operatorsV2, err = operatorsv2.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.operatorsV1 = operatorsv1.New(c) 153 cs.operatorsV1alpha1 = operatorsv1alpha1.New(c) 154 cs.operatorsV1alpha2 = operatorsv1alpha2.New(c) 155 cs.operatorsV2 = operatorsv2.New(c) 156 157 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 158 return &cs 159 }