Files
velero/pkg/generated/clientset/clientset.go
T
2017-08-02 13:27:17 -04:00

89 lines
2.3 KiB
Go

package clientset
import (
glog "github.com/golang/glog"
arkv1 "github.com/heptio/ark/pkg/generated/clientset/typed/ark/v1"
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol"
)
type Interface interface {
Discovery() discovery.DiscoveryInterface
ArkV1() arkv1.ArkV1Interface
// Deprecated: please explicitly pick a version if possible.
Ark() arkv1.ArkV1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
type Clientset struct {
*discovery.DiscoveryClient
*arkv1.ArkV1Client
}
// ArkV1 retrieves the ArkV1Client
func (c *Clientset) ArkV1() arkv1.ArkV1Interface {
if c == nil {
return nil
}
return c.ArkV1Client
}
// Deprecated: Ark retrieves the default version of ArkClient.
// Please explicitly pick a version.
func (c *Clientset) Ark() arkv1.ArkV1Interface {
if c == nil {
return nil
}
return c.ArkV1Client
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
return nil
}
return c.DiscoveryClient
}
// NewForConfig creates a new Clientset for the given config.
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var cs Clientset
var err error
cs.ArkV1Client, err = arkv1.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
glog.Errorf("failed to create the DiscoveryClient: %v", err)
return nil, err
}
return &cs, nil
}
// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset
cs.ArkV1Client = arkv1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
}
// New creates a new Clientset for the given RESTClient.
func New(c rest.Interface) *Clientset {
var cs Clientset
cs.ArkV1Client = arkv1.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs
}