github.com/k8snetworkplumbingwg/sriov-network-operator@v1.2.1-0.20240408194816-2d2e5a45d453/pkg/client/clientset/versioned/clientset.go (about) 1 // Code generated by client-gen. DO NOT EDIT. 2 3 package versioned 4 5 import ( 6 "fmt" 7 8 sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/client/clientset/versioned/typed/sriovnetwork/v1" 9 discovery "k8s.io/client-go/discovery" 10 rest "k8s.io/client-go/rest" 11 flowcontrol "k8s.io/client-go/util/flowcontrol" 12 ) 13 14 type Interface interface { 15 Discovery() discovery.DiscoveryInterface 16 SriovnetworkV1() sriovnetworkv1.SriovnetworkV1Interface 17 } 18 19 // Clientset contains the clients for groups. Each group has exactly one 20 // version included in a Clientset. 21 type Clientset struct { 22 *discovery.DiscoveryClient 23 sriovnetworkV1 *sriovnetworkv1.SriovnetworkV1Client 24 } 25 26 // SriovnetworkV1 retrieves the SriovnetworkV1Client 27 func (c *Clientset) SriovnetworkV1() sriovnetworkv1.SriovnetworkV1Interface { 28 return c.sriovnetworkV1 29 } 30 31 // Discovery retrieves the DiscoveryClient 32 func (c *Clientset) Discovery() discovery.DiscoveryInterface { 33 if c == nil { 34 return nil 35 } 36 return c.DiscoveryClient 37 } 38 39 // NewForConfig creates a new Clientset for the given config. 40 // If config's RateLimiter is not set and QPS and Burst are acceptable, 41 // NewForConfig will generate a rate-limiter in configShallowCopy. 42 func NewForConfig(c *rest.Config) (*Clientset, error) { 43 configShallowCopy := *c 44 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 45 if configShallowCopy.Burst <= 0 { 46 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") 47 } 48 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 49 } 50 var cs Clientset 51 var err error 52 cs.sriovnetworkV1, err = sriovnetworkv1.NewForConfig(&configShallowCopy) 53 if err != nil { 54 return nil, err 55 } 56 57 cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) 58 if err != nil { 59 return nil, err 60 } 61 return &cs, nil 62 } 63 64 // NewForConfigOrDie creates a new Clientset for the given config and 65 // panics if there is an error in the config. 66 func NewForConfigOrDie(c *rest.Config) *Clientset { 67 var cs Clientset 68 cs.sriovnetworkV1 = sriovnetworkv1.NewForConfigOrDie(c) 69 70 cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) 71 return &cs 72 } 73 74 // New creates a new Clientset for the given RESTClient. 75 func New(c rest.Interface) *Clientset { 76 var cs Clientset 77 cs.sriovnetworkV1 = sriovnetworkv1.New(c) 78 79 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 80 return &cs 81 }