github.com/oam-dev/cluster-gateway@v1.9.0/pkg/generated/clientset/versioned/clientset.go (about)

     1  /*
     2  Copyright 2021 The KubeVela 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      http://www.apache.org/licenses/LICENSE-2.0
     8  Unless required by applicable law or agreed to in writing, software
     9  distributed under the License is distributed on an "AS IS" BASIS,
    10  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  See the License for the specific language governing permissions and
    12  limitations under the License.
    13  */
    14  // Code generated by client-gen. DO NOT EDIT.
    15  
    16  package versioned
    17  
    18  import (
    19  	"fmt"
    20  
    21  	clusterv1alpha1 "github.com/oam-dev/cluster-gateway/pkg/generated/clientset/versioned/typed/cluster/v1alpha1"
    22  	discovery "k8s.io/client-go/discovery"
    23  	rest "k8s.io/client-go/rest"
    24  	flowcontrol "k8s.io/client-go/util/flowcontrol"
    25  )
    26  
    27  type Interface interface {
    28  	Discovery() discovery.DiscoveryInterface
    29  	ClusterV1alpha1() clusterv1alpha1.ClusterV1alpha1Interface
    30  }
    31  
    32  // Clientset contains the clients for groups. Each group has exactly one
    33  // version included in a Clientset.
    34  type Clientset struct {
    35  	*discovery.DiscoveryClient
    36  	clusterV1alpha1 *clusterv1alpha1.ClusterV1alpha1Client
    37  }
    38  
    39  // ClusterV1alpha1 retrieves the ClusterV1alpha1Client
    40  func (c *Clientset) ClusterV1alpha1() clusterv1alpha1.ClusterV1alpha1Interface {
    41  	return c.clusterV1alpha1
    42  }
    43  
    44  // Discovery retrieves the DiscoveryClient
    45  func (c *Clientset) Discovery() discovery.DiscoveryInterface {
    46  	if c == nil {
    47  		return nil
    48  	}
    49  	return c.DiscoveryClient
    50  }
    51  
    52  // NewForConfig creates a new Clientset for the given config.
    53  // If config's RateLimiter is not set and QPS and Burst are acceptable,
    54  // NewForConfig will generate a rate-limiter in configShallowCopy.
    55  func NewForConfig(c *rest.Config) (*Clientset, error) {
    56  	configShallowCopy := *c
    57  	if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
    58  		if configShallowCopy.Burst <= 0 {
    59  			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")
    60  		}
    61  		configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
    62  	}
    63  	var cs Clientset
    64  	var err error
    65  	cs.clusterV1alpha1, err = clusterv1alpha1.NewForConfig(&configShallowCopy)
    66  	if err != nil {
    67  		return nil, err
    68  	}
    69  
    70  	cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
    71  	if err != nil {
    72  		return nil, err
    73  	}
    74  	return &cs, nil
    75  }
    76  
    77  // NewForConfigOrDie creates a new Clientset for the given config and
    78  // panics if there is an error in the config.
    79  func NewForConfigOrDie(c *rest.Config) *Clientset {
    80  	var cs Clientset
    81  	cs.clusterV1alpha1 = clusterv1alpha1.NewForConfigOrDie(c)
    82  
    83  	cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
    84  	return &cs
    85  }
    86  
    87  // New creates a new Clientset for the given RESTClient.
    88  func New(c rest.Interface) *Clientset {
    89  	var cs Clientset
    90  	cs.clusterV1alpha1 = clusterv1alpha1.New(c)
    91  
    92  	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
    93  	return &cs
    94  }