github.com/abayer/test-infra@v0.0.5/prow/client/clientset/versioned/clientset.go (about) 1 /* 2 Copyright 2018 The Kubernetes 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 glog "github.com/golang/glog" 23 discovery "k8s.io/client-go/discovery" 24 rest "k8s.io/client-go/rest" 25 flowcontrol "k8s.io/client-go/util/flowcontrol" 26 prowv1 "k8s.io/test-infra/prow/client/clientset/versioned/typed/prowjobs/v1" 27 ) 28 29 type Interface interface { 30 Discovery() discovery.DiscoveryInterface 31 ProwV1() prowv1.ProwV1Interface 32 // Deprecated: please explicitly pick a version if possible. 33 Prow() prowv1.ProwV1Interface 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 prowV1 *prowv1.ProwV1Client 41 } 42 43 // ProwV1 retrieves the ProwV1Client 44 func (c *Clientset) ProwV1() prowv1.ProwV1Interface { 45 return c.prowV1 46 } 47 48 // Deprecated: Prow retrieves the default version of ProwClient. 49 // Please explicitly pick a version. 50 func (c *Clientset) Prow() prowv1.ProwV1Interface { 51 return c.prowV1 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.prowV1, err = prowv1.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.prowV1 = prowv1.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.prowV1 = prowv1.New(c) 97 98 cs.DiscoveryClient = discovery.NewDiscoveryClient(c) 99 return &cs 100 }