|
| 1 | +package clientset |
| 2 | + |
| 3 | +import ( |
| 4 | + discovery "k8s.io/client-go/discovery" |
| 5 | + rest "k8s.io/client-go/rest" |
| 6 | + flowcontrol "k8s.io/client-go/util/flowcontrol" |
| 7 | + |
| 8 | + appsV1 "github.com/openshift/origin/pkg/deploy/generated/clientset/typed/apps/v1" |
| 9 | +) |
| 10 | + |
| 11 | +type Interface interface { |
| 12 | + AppsV1() appsV1.AppsV1Interface |
| 13 | +} |
| 14 | + |
| 15 | +// Clientset contains the clients for groups. Each group has exactly one |
| 16 | +// version included in a Clientset. |
| 17 | +type Clientset struct { |
| 18 | + *discovery.DiscoveryClient |
| 19 | + appsV1 *appsV1.AppsV1Client |
| 20 | +} |
| 21 | + |
| 22 | +// Make sure Clientset implements Interface |
| 23 | +var _ Interface = &Clientset{} |
| 24 | + |
| 25 | +// AppsV1 retrieves the AppsV1Client |
| 26 | +func (c *Clientset) AppsV1() appsV1.AppsV1Interface { |
| 27 | + return c.appsV1 |
| 28 | +} |
| 29 | + |
| 30 | +// NewForConfig creates a new Clientset for the given config. |
| 31 | +func NewForConfig(c *rest.Config) (*Clientset, error) { |
| 32 | + configShallowCopy := *c |
| 33 | + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { |
| 34 | + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) |
| 35 | + } |
| 36 | + |
| 37 | + var cs Clientset |
| 38 | + var err error |
| 39 | + |
| 40 | + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) |
| 41 | + if err != nil { |
| 42 | + return nil, err |
| 43 | + } |
| 44 | + |
| 45 | + cs.appsV1, err = appsV1.NewForConfig(&configShallowCopy) |
| 46 | + if err != nil { |
| 47 | + return nil, err |
| 48 | + } |
| 49 | + |
| 50 | + return &cs, nil |
| 51 | +} |
| 52 | + |
| 53 | +// NewForConfigOrDie creates a new Clientset for the given config and |
| 54 | +// panics if there is an error in the config. |
| 55 | +func NewForConfigOrDie(c *rest.Config) *Clientset { |
| 56 | + cs, err := NewForConfig(c) |
| 57 | + if err != nil { |
| 58 | + panic(err) |
| 59 | + } |
| 60 | + return cs |
| 61 | +} |
0 commit comments