github.com/mirantis/virtlet@v1.5.2-0.20191204181327-1659b8a48e9b/pkg/client/clientset/versioned/clientset.go (about) 1 /* 2 Copyright 2019 Mirantis 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 glog "github.com/golang/glog" 23 virtletv1 "github.com/Mirantis/virtlet/pkg/client/clientset/versioned/typed/virtlet.k8s/v1" 24 discovery "k8s.io/client-go/discovery" 25 rest "k8s.io/client-go/rest" 26 flowcontrol "k8s.io/client-go/util/flowcontrol" 27 ) 28 29 type Interface interface { 30 Discovery() discovery.DiscoveryInterface 31 VirtletV1() virtletv1.VirtletV1Interface 32 // Deprecated: please explicitly pick a version if possible. 33 Virtlet() virtletv1.VirtletV1Interface 34 } 35 36 // Clientset contains the clients for groups. Each group has exactly one 37 // version included in a Clientset. 38 type Clientset struct { 39 *discovery.DiscoveryClient 40 virtletV1 *virtletv1.VirtletV1Client 41 } 42 43 // VirtletV1 retrieves the VirtletV1Client 44 func (c *Clientset) VirtletV1() virtletv1.VirtletV1Interface { 45 return c.virtletV1 46 } 47 48 // Deprecated: Virtlet retrieves the default version of VirtletClient. 49 // Please explicitly pick a version. 50 func (c *Clientset) Virtlet() virtletv1.VirtletV1Interface { 51 return c.virtletV1 52 } 53 54 // Discovery retrieves the DiscoveryClient 55 func (c *Clientset) Discovery() discovery.DiscoveryInterface { 56 if c == nil { 57 return nil 58 } 59 return c.DiscoveryClient 60 } 61 62 // NewForConfig creates a new Clientset for the given config. 63 func NewForConfig(c *rest.Config) (*Clientset, error) { 64 configShallowCopy := *c 65 if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { 66 configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) 67 } 68 var cs Clientset 69 var err error 70 cs.virtletV1, err = virtletv1.NewForConfig(&configShallowCopy) 71 if err != nil { 72 return nil, err 73 } 74 75 cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) 76 if err != nil { 77 glog.Errorf("failed to create the DiscoveryClient: %v", err) 78 return nil, err 79 } 80 return &cs, nil 81 } 82 83 // NewForConfigOrDie creates a new Clientset for the given config and 84 // panics if there is an error in the config. 85 func NewForConfigOrDie(c *rest.Config) *Clientset { 86 var cs Clientset 87 cs.virtletV1 = virtletv1.NewForConfigOrDie(c) 88 89 cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) 90 return &cs 91 } 92 93 // New creates a new Clientset for the given RESTClient. 94 func New(c rest.Interface) *Clientset { 95 var cs Clientset 96 cs.virtletV1 = virtletv1.New(c) 97 98 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 99 return &cs 100 }