...

Source file src/kubevirt.io/client-go/generated/external-snapshotter/clientset/versioned/clientset.go

Documentation: kubevirt.io/client-go/generated/external-snapshotter/clientset/versioned

     1  /*
     2  Copyright The KubeVirt 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  
     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  
    24  	discovery "k8s.io/client-go/discovery"
    25  	rest "k8s.io/client-go/rest"
    26  	flowcontrol "k8s.io/client-go/util/flowcontrol"
    27  	snapshotv1 "kubevirt.io/client-go/generated/external-snapshotter/clientset/versioned/typed/volumesnapshot/v1"
    28  )
    29  
    30  type Interface interface {
    31  	Discovery() discovery.DiscoveryInterface
    32  	SnapshotV1() snapshotv1.SnapshotV1Interface
    33  }
    34  
    35  // Clientset contains the clients for groups. Each group has exactly one
    36  // version included in a Clientset.
    37  type Clientset struct {
    38  	*discovery.DiscoveryClient
    39  	snapshotV1 *snapshotv1.SnapshotV1Client
    40  }
    41  
    42  // SnapshotV1 retrieves the SnapshotV1Client
    43  func (c *Clientset) SnapshotV1() snapshotv1.SnapshotV1Interface {
    44  	return c.snapshotV1
    45  }
    46  
    47  // Discovery retrieves the DiscoveryClient
    48  func (c *Clientset) Discovery() discovery.DiscoveryInterface {
    49  	if c == nil {
    50  		return nil
    51  	}
    52  	return c.DiscoveryClient
    53  }
    54  
    55  // NewForConfig creates a new Clientset for the given config.
    56  // If config's RateLimiter is not set and QPS and Burst are acceptable,
    57  // NewForConfig will generate a rate-limiter in configShallowCopy.
    58  func NewForConfig(c *rest.Config) (*Clientset, error) {
    59  	configShallowCopy := *c
    60  	if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
    61  		if configShallowCopy.Burst <= 0 {
    62  			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")
    63  		}
    64  		configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
    65  	}
    66  	var cs Clientset
    67  	var err error
    68  	cs.snapshotV1, err = snapshotv1.NewForConfig(&configShallowCopy)
    69  	if err != nil {
    70  		return nil, err
    71  	}
    72  
    73  	cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
    74  	if err != nil {
    75  		return nil, err
    76  	}
    77  	return &cs, nil
    78  }
    79  
    80  // NewForConfigOrDie creates a new Clientset for the given config and
    81  // panics if there is an error in the config.
    82  func NewForConfigOrDie(c *rest.Config) *Clientset {
    83  	var cs Clientset
    84  	cs.snapshotV1 = snapshotv1.NewForConfigOrDie(c)
    85  
    86  	cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
    87  	return &cs
    88  }
    89  
    90  // New creates a new Clientset for the given RESTClient.
    91  func New(c rest.Interface) *Clientset {
    92  	var cs Clientset
    93  	cs.snapshotV1 = snapshotv1.New(c)
    94  
    95  	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
    96  	return &cs
    97  }
    98  

View as plain text