1
0
mirror of https://github.com/rancher/types.git synced 2025-08-28 08:40:31 +00:00

go generate

This commit is contained in:
orangedeng 2019-03-28 21:19:58 +08:00 committed by Craig Jellick
parent 5694548201
commit 668e468c02
26 changed files with 2454 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
package v2beta2
import (
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HorizontalPodAutoscalerList) DeepCopyInto(out *HorizontalPodAutoscalerList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]autoscalingv2beta2.HorizontalPodAutoscaler, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HorizontalPodAutoscalerList.
func (in *HorizontalPodAutoscalerList) DeepCopy() *HorizontalPodAutoscalerList {
if in == nil {
return nil
}
out := new(HorizontalPodAutoscalerList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *HorizontalPodAutoscalerList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}

View File

@ -0,0 +1,453 @@
package v2beta2
import (
"context"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
"github.com/rancher/norman/resource"
"k8s.io/api/autoscaling/v2beta2"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
HorizontalPodAutoscalerGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "HorizontalPodAutoscaler",
}
HorizontalPodAutoscalerResource = metav1.APIResource{
Name: "horizontalpodautoscalers",
SingularName: "horizontalpodautoscaler",
Namespaced: true,
Kind: HorizontalPodAutoscalerGroupVersionKind.Kind,
}
HorizontalPodAutoscalerGroupVersionResource = schema.GroupVersionResource{
Group: GroupName,
Version: Version,
Resource: "horizontalpodautoscalers",
}
)
func init() {
resource.Put(HorizontalPodAutoscalerGroupVersionResource)
}
func NewHorizontalPodAutoscaler(namespace, name string, obj v2beta2.HorizontalPodAutoscaler) *v2beta2.HorizontalPodAutoscaler {
obj.APIVersion, obj.Kind = HorizontalPodAutoscalerGroupVersionKind.ToAPIVersionAndKind()
obj.Name = name
obj.Namespace = namespace
return &obj
}
type HorizontalPodAutoscalerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []v2beta2.HorizontalPodAutoscaler `json:"items"`
}
type HorizontalPodAutoscalerHandlerFunc func(key string, obj *v2beta2.HorizontalPodAutoscaler) (runtime.Object, error)
type HorizontalPodAutoscalerChangeHandlerFunc func(obj *v2beta2.HorizontalPodAutoscaler) (runtime.Object, error)
type HorizontalPodAutoscalerLister interface {
List(namespace string, selector labels.Selector) (ret []*v2beta2.HorizontalPodAutoscaler, err error)
Get(namespace, name string) (*v2beta2.HorizontalPodAutoscaler, error)
}
type HorizontalPodAutoscalerController interface {
Generic() controller.GenericController
Informer() cache.SharedIndexInformer
Lister() HorizontalPodAutoscalerLister
AddHandler(ctx context.Context, name string, handler HorizontalPodAutoscalerHandlerFunc)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler HorizontalPodAutoscalerHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type HorizontalPodAutoscalerInterface interface {
ObjectClient() *objectclient.ObjectClient
Create(*v2beta2.HorizontalPodAutoscaler) (*v2beta2.HorizontalPodAutoscaler, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v2beta2.HorizontalPodAutoscaler, error)
Get(name string, opts metav1.GetOptions) (*v2beta2.HorizontalPodAutoscaler, error)
Update(*v2beta2.HorizontalPodAutoscaler) (*v2beta2.HorizontalPodAutoscaler, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*HorizontalPodAutoscalerList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() HorizontalPodAutoscalerController
AddHandler(ctx context.Context, name string, sync HorizontalPodAutoscalerHandlerFunc)
AddLifecycle(ctx context.Context, name string, lifecycle HorizontalPodAutoscalerLifecycle)
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync HorizontalPodAutoscalerHandlerFunc)
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle HorizontalPodAutoscalerLifecycle)
}
type horizontalPodAutoscalerLister struct {
controller *horizontalPodAutoscalerController
}
func (l *horizontalPodAutoscalerLister) List(namespace string, selector labels.Selector) (ret []*v2beta2.HorizontalPodAutoscaler, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*v2beta2.HorizontalPodAutoscaler))
})
return
}
func (l *horizontalPodAutoscalerLister) Get(namespace, name string) (*v2beta2.HorizontalPodAutoscaler, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: HorizontalPodAutoscalerGroupVersionKind.Group,
Resource: "horizontalPodAutoscaler",
}, key)
}
return obj.(*v2beta2.HorizontalPodAutoscaler), nil
}
type horizontalPodAutoscalerController struct {
controller.GenericController
}
func (c *horizontalPodAutoscalerController) Generic() controller.GenericController {
return c.GenericController
}
func (c *horizontalPodAutoscalerController) Lister() HorizontalPodAutoscalerLister {
return &horizontalPodAutoscalerLister{
controller: c,
}
}
func (c *horizontalPodAutoscalerController) AddHandler(ctx context.Context, name string, handler HorizontalPodAutoscalerHandlerFunc) {
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v2beta2.HorizontalPodAutoscaler); ok {
return handler(key, v)
} else {
return nil, nil
}
})
}
func (c *horizontalPodAutoscalerController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler HorizontalPodAutoscalerHandlerFunc) {
resource.PutClusterScoped(HorizontalPodAutoscalerGroupVersionResource)
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)
} else if v, ok := obj.(*v2beta2.HorizontalPodAutoscaler); ok && controller.ObjectInCluster(cluster, obj) {
return handler(key, v)
} else {
return nil, nil
}
})
}
type horizontalPodAutoscalerFactory struct {
}
func (c horizontalPodAutoscalerFactory) Object() runtime.Object {
return &v2beta2.HorizontalPodAutoscaler{}
}
func (c horizontalPodAutoscalerFactory) List() runtime.Object {
return &HorizontalPodAutoscalerList{}
}
func (s *horizontalPodAutoscalerClient) Controller() HorizontalPodAutoscalerController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.horizontalPodAutoscalerControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(HorizontalPodAutoscalerGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &horizontalPodAutoscalerController{
GenericController: genericController,
}
s.client.horizontalPodAutoscalerControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type horizontalPodAutoscalerClient struct {
client *Client
ns string
objectClient *objectclient.ObjectClient
controller HorizontalPodAutoscalerController
}
func (s *horizontalPodAutoscalerClient) ObjectClient() *objectclient.ObjectClient {
return s.objectClient
}
func (s *horizontalPodAutoscalerClient) Create(o *v2beta2.HorizontalPodAutoscaler) (*v2beta2.HorizontalPodAutoscaler, error) {
obj, err := s.objectClient.Create(o)
return obj.(*v2beta2.HorizontalPodAutoscaler), err
}
func (s *horizontalPodAutoscalerClient) Get(name string, opts metav1.GetOptions) (*v2beta2.HorizontalPodAutoscaler, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*v2beta2.HorizontalPodAutoscaler), err
}
func (s *horizontalPodAutoscalerClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v2beta2.HorizontalPodAutoscaler, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*v2beta2.HorizontalPodAutoscaler), err
}
func (s *horizontalPodAutoscalerClient) Update(o *v2beta2.HorizontalPodAutoscaler) (*v2beta2.HorizontalPodAutoscaler, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*v2beta2.HorizontalPodAutoscaler), err
}
func (s *horizontalPodAutoscalerClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *horizontalPodAutoscalerClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *horizontalPodAutoscalerClient) List(opts metav1.ListOptions) (*HorizontalPodAutoscalerList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*HorizontalPodAutoscalerList), err
}
func (s *horizontalPodAutoscalerClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *horizontalPodAutoscalerClient) Patch(o *v2beta2.HorizontalPodAutoscaler, patchType types.PatchType, data []byte, subresources ...string) (*v2beta2.HorizontalPodAutoscaler, error) {
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
return obj.(*v2beta2.HorizontalPodAutoscaler), err
}
func (s *horizontalPodAutoscalerClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *horizontalPodAutoscalerClient) AddHandler(ctx context.Context, name string, sync HorizontalPodAutoscalerHandlerFunc) {
s.Controller().AddHandler(ctx, name, sync)
}
func (s *horizontalPodAutoscalerClient) AddLifecycle(ctx context.Context, name string, lifecycle HorizontalPodAutoscalerLifecycle) {
sync := NewHorizontalPodAutoscalerLifecycleAdapter(name, false, s, lifecycle)
s.Controller().AddHandler(ctx, name, sync)
}
func (s *horizontalPodAutoscalerClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync HorizontalPodAutoscalerHandlerFunc) {
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
func (s *horizontalPodAutoscalerClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle HorizontalPodAutoscalerLifecycle) {
sync := NewHorizontalPodAutoscalerLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
}
type HorizontalPodAutoscalerIndexer func(obj *v2beta2.HorizontalPodAutoscaler) ([]string, error)
type HorizontalPodAutoscalerClientCache interface {
Get(namespace, name string) (*v2beta2.HorizontalPodAutoscaler, error)
List(namespace string, selector labels.Selector) ([]*v2beta2.HorizontalPodAutoscaler, error)
Index(name string, indexer HorizontalPodAutoscalerIndexer)
GetIndexed(name, key string) ([]*v2beta2.HorizontalPodAutoscaler, error)
}
type HorizontalPodAutoscalerClient interface {
Create(*v2beta2.HorizontalPodAutoscaler) (*v2beta2.HorizontalPodAutoscaler, error)
Get(namespace, name string, opts metav1.GetOptions) (*v2beta2.HorizontalPodAutoscaler, error)
Update(*v2beta2.HorizontalPodAutoscaler) (*v2beta2.HorizontalPodAutoscaler, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*HorizontalPodAutoscalerList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() HorizontalPodAutoscalerClientCache
OnCreate(ctx context.Context, name string, sync HorizontalPodAutoscalerChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync HorizontalPodAutoscalerChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync HorizontalPodAutoscalerChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() HorizontalPodAutoscalerInterface
}
type horizontalPodAutoscalerClientCache struct {
client *horizontalPodAutoscalerClient2
}
type horizontalPodAutoscalerClient2 struct {
iface HorizontalPodAutoscalerInterface
controller HorizontalPodAutoscalerController
}
func (n *horizontalPodAutoscalerClient2) Interface() HorizontalPodAutoscalerInterface {
return n.iface
}
func (n *horizontalPodAutoscalerClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *horizontalPodAutoscalerClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *horizontalPodAutoscalerClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *horizontalPodAutoscalerClient2) Create(obj *v2beta2.HorizontalPodAutoscaler) (*v2beta2.HorizontalPodAutoscaler, error) {
return n.iface.Create(obj)
}
func (n *horizontalPodAutoscalerClient2) Get(namespace, name string, opts metav1.GetOptions) (*v2beta2.HorizontalPodAutoscaler, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *horizontalPodAutoscalerClient2) Update(obj *v2beta2.HorizontalPodAutoscaler) (*v2beta2.HorizontalPodAutoscaler, error) {
return n.iface.Update(obj)
}
func (n *horizontalPodAutoscalerClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *horizontalPodAutoscalerClient2) List(namespace string, opts metav1.ListOptions) (*HorizontalPodAutoscalerList, error) {
return n.iface.List(opts)
}
func (n *horizontalPodAutoscalerClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *horizontalPodAutoscalerClientCache) Get(namespace, name string) (*v2beta2.HorizontalPodAutoscaler, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *horizontalPodAutoscalerClientCache) List(namespace string, selector labels.Selector) ([]*v2beta2.HorizontalPodAutoscaler, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *horizontalPodAutoscalerClient2) Cache() HorizontalPodAutoscalerClientCache {
n.loadController()
return &horizontalPodAutoscalerClientCache{
client: n,
}
}
func (n *horizontalPodAutoscalerClient2) OnCreate(ctx context.Context, name string, sync HorizontalPodAutoscalerChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &horizontalPodAutoscalerLifecycleDelegate{create: sync})
}
func (n *horizontalPodAutoscalerClient2) OnChange(ctx context.Context, name string, sync HorizontalPodAutoscalerChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &horizontalPodAutoscalerLifecycleDelegate{update: sync})
}
func (n *horizontalPodAutoscalerClient2) OnRemove(ctx context.Context, name string, sync HorizontalPodAutoscalerChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &horizontalPodAutoscalerLifecycleDelegate{remove: sync})
}
func (n *horizontalPodAutoscalerClientCache) Index(name string, indexer HorizontalPodAutoscalerIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*v2beta2.HorizontalPodAutoscaler); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *horizontalPodAutoscalerClientCache) GetIndexed(name, key string) ([]*v2beta2.HorizontalPodAutoscaler, error) {
var result []*v2beta2.HorizontalPodAutoscaler
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*v2beta2.HorizontalPodAutoscaler); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *horizontalPodAutoscalerClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type horizontalPodAutoscalerLifecycleDelegate struct {
create HorizontalPodAutoscalerChangeHandlerFunc
update HorizontalPodAutoscalerChangeHandlerFunc
remove HorizontalPodAutoscalerChangeHandlerFunc
}
func (n *horizontalPodAutoscalerLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *horizontalPodAutoscalerLifecycleDelegate) Create(obj *v2beta2.HorizontalPodAutoscaler) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *horizontalPodAutoscalerLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *horizontalPodAutoscalerLifecycleDelegate) Remove(obj *v2beta2.HorizontalPodAutoscaler) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *horizontalPodAutoscalerLifecycleDelegate) Updated(obj *v2beta2.HorizontalPodAutoscaler) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@ -0,0 +1,63 @@
package v2beta2
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/api/autoscaling/v2beta2"
"k8s.io/apimachinery/pkg/runtime"
)
type HorizontalPodAutoscalerLifecycle interface {
Create(obj *v2beta2.HorizontalPodAutoscaler) (runtime.Object, error)
Remove(obj *v2beta2.HorizontalPodAutoscaler) (runtime.Object, error)
Updated(obj *v2beta2.HorizontalPodAutoscaler) (runtime.Object, error)
}
type horizontalPodAutoscalerLifecycleAdapter struct {
lifecycle HorizontalPodAutoscalerLifecycle
}
func (w *horizontalPodAutoscalerLifecycleAdapter) HasCreate() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasCreate()
}
func (w *horizontalPodAutoscalerLifecycleAdapter) HasFinalize() bool {
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
return !ok || o.HasFinalize()
}
func (w *horizontalPodAutoscalerLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*v2beta2.HorizontalPodAutoscaler))
if o == nil {
return nil, err
}
return o, err
}
func (w *horizontalPodAutoscalerLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*v2beta2.HorizontalPodAutoscaler))
if o == nil {
return nil, err
}
return o, err
}
func (w *horizontalPodAutoscalerLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*v2beta2.HorizontalPodAutoscaler))
if o == nil {
return nil, err
}
return o, err
}
func NewHorizontalPodAutoscalerLifecycleAdapter(name string, clusterScoped bool, client HorizontalPodAutoscalerInterface, l HorizontalPodAutoscalerLifecycle) HorizontalPodAutoscalerHandlerFunc {
adapter := &horizontalPodAutoscalerLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *v2beta2.HorizontalPodAutoscaler) (runtime.Object, error) {
newObj, err := syncFn(key, obj)
if o, ok := newObj.(runtime.Object); ok {
return o, err
}
return nil, err
}
}

View File

@ -0,0 +1,119 @@
package v2beta2
import (
"context"
"sync"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
"github.com/rancher/norman/objectclient/dynamic"
"github.com/rancher/norman/restwatch"
"k8s.io/client-go/rest"
)
type (
contextKeyType struct{}
contextClientsKeyType struct{}
)
type Interface interface {
RESTClient() rest.Interface
controller.Starter
HorizontalPodAutoscalersGetter
}
type Clients struct {
Interface Interface
HorizontalPodAutoscaler HorizontalPodAutoscalerClient
}
type Client struct {
sync.Mutex
restClient rest.Interface
starters []controller.Starter
horizontalPodAutoscalerControllers map[string]HorizontalPodAutoscalerController
}
func Factory(ctx context.Context, config rest.Config) (context.Context, controller.Starter, error) {
c, err := NewForConfig(config)
if err != nil {
return ctx, nil, err
}
cs := NewClientsFromInterface(c)
ctx = context.WithValue(ctx, contextKeyType{}, c)
ctx = context.WithValue(ctx, contextClientsKeyType{}, cs)
return ctx, c, nil
}
func ClientsFrom(ctx context.Context) *Clients {
return ctx.Value(contextClientsKeyType{}).(*Clients)
}
func From(ctx context.Context) Interface {
return ctx.Value(contextKeyType{}).(Interface)
}
func NewClients(config rest.Config) (*Clients, error) {
iface, err := NewForConfig(config)
if err != nil {
return nil, err
}
return NewClientsFromInterface(iface), nil
}
func NewClientsFromInterface(iface Interface) *Clients {
return &Clients{
Interface: iface,
HorizontalPodAutoscaler: &horizontalPodAutoscalerClient2{
iface: iface.HorizontalPodAutoscalers(""),
},
}
}
func NewForConfig(config rest.Config) (Interface, error) {
if config.NegotiatedSerializer == nil {
config.NegotiatedSerializer = dynamic.NegotiatedSerializer
}
restClient, err := restwatch.UnversionedRESTClientFor(&config)
if err != nil {
return nil, err
}
return &Client{
restClient: restClient,
horizontalPodAutoscalerControllers: map[string]HorizontalPodAutoscalerController{},
}, nil
}
func (c *Client) RESTClient() rest.Interface {
return c.restClient
}
func (c *Client) Sync(ctx context.Context) error {
return controller.Sync(ctx, c.starters...)
}
func (c *Client) Start(ctx context.Context, threadiness int) error {
return controller.Start(ctx, threadiness, c.starters...)
}
type HorizontalPodAutoscalersGetter interface {
HorizontalPodAutoscalers(namespace string) HorizontalPodAutoscalerInterface
}
func (c *Client) HorizontalPodAutoscalers(namespace string) HorizontalPodAutoscalerInterface {
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &HorizontalPodAutoscalerResource, HorizontalPodAutoscalerGroupVersionKind, horizontalPodAutoscalerFactory{})
return &horizontalPodAutoscalerClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}

View File

@ -0,0 +1,41 @@
package v2beta2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
const (
GroupName = "autoscaling"
Version = "v2beta2"
)
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}
// Kind takes an unqualified kind and returns a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
// TODO this gets cleaned up when the types are fixed
scheme.AddKnownTypes(SchemeGroupVersion,
&HorizontalPodAutoscalerList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}

View File

@ -46,6 +46,7 @@ type Client struct {
ServiceMonitor ServiceMonitorOperations
PrometheusRule PrometheusRuleOperations
Alertmanager AlertmanagerOperations
HorizontalPodAutoscaler HorizontalPodAutoscalerOperations
}
func NewClient(opts *clientbase.ClientOpts) (*Client, error) {
@ -97,6 +98,7 @@ func NewClient(opts *clientbase.ClientOpts) (*Client, error) {
client.ServiceMonitor = newServiceMonitorClient(client)
client.PrometheusRule = newPrometheusRuleClient(client)
client.Alertmanager = newAlertmanagerClient(client)
client.HorizontalPodAutoscaler = newHorizontalPodAutoscalerClient(client)
return client, nil
}

View File

@ -0,0 +1,14 @@
package client
const (
CrossVersionObjectReferenceType = "crossVersionObjectReference"
CrossVersionObjectReferenceFieldAPIVersion = "apiVersion"
CrossVersionObjectReferenceFieldKind = "kind"
CrossVersionObjectReferenceFieldName = "name"
)
type CrossVersionObjectReference struct {
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
}

View File

@ -0,0 +1,12 @@
package client
const (
ExternalMetricSourceType = "externalMetricSource"
ExternalMetricSourceFieldMetric = "metric"
ExternalMetricSourceFieldTarget = "target"
)
type ExternalMetricSource struct {
Metric *MetricIdentifier `json:"metric,omitempty" yaml:"metric,omitempty"`
Target *MetricTarget `json:"target,omitempty" yaml:"target,omitempty"`
}

View File

@ -0,0 +1,12 @@
package client
const (
ExternalMetricStatusType = "externalMetricStatus"
ExternalMetricStatusFieldCurrent = "current"
ExternalMetricStatusFieldMetric = "metric"
)
type ExternalMetricStatus struct {
Current *MetricValueStatus `json:"current,omitempty" yaml:"current,omitempty"`
Metric *MetricIdentifier `json:"metric,omitempty" yaml:"metric,omitempty"`
}

View File

@ -0,0 +1,129 @@
package client
import (
"github.com/rancher/norman/types"
)
const (
HorizontalPodAutoscalerType = "horizontalPodAutoscaler"
HorizontalPodAutoscalerFieldAnnotations = "annotations"
HorizontalPodAutoscalerFieldConditions = "conditions"
HorizontalPodAutoscalerFieldCreated = "created"
HorizontalPodAutoscalerFieldCreatorID = "creatorId"
HorizontalPodAutoscalerFieldCurrentReplicas = "currentReplicas"
HorizontalPodAutoscalerFieldDescription = "description"
HorizontalPodAutoscalerFieldDesiredReplicas = "desiredReplicas"
HorizontalPodAutoscalerFieldLabels = "labels"
HorizontalPodAutoscalerFieldLastScaleTime = "lastScaleTime"
HorizontalPodAutoscalerFieldMaxReplicas = "maxReplicas"
HorizontalPodAutoscalerFieldMetrics = "metrics"
HorizontalPodAutoscalerFieldMinReplicas = "minReplicas"
HorizontalPodAutoscalerFieldName = "name"
HorizontalPodAutoscalerFieldNamespaceId = "namespaceId"
HorizontalPodAutoscalerFieldObservedGeneration = "observedGeneration"
HorizontalPodAutoscalerFieldOwnerReferences = "ownerReferences"
HorizontalPodAutoscalerFieldProjectID = "projectId"
HorizontalPodAutoscalerFieldRemoved = "removed"
HorizontalPodAutoscalerFieldState = "state"
HorizontalPodAutoscalerFieldTransitioning = "transitioning"
HorizontalPodAutoscalerFieldTransitioningMessage = "transitioningMessage"
HorizontalPodAutoscalerFieldUUID = "uuid"
HorizontalPodAutoscalerFieldWorkloadId = "workloadId"
)
type HorizontalPodAutoscaler struct {
types.Resource
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
Conditions []HorizontalPodAutoscalerCondition `json:"conditions,omitempty" yaml:"conditions,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
CreatorID string `json:"creatorId,omitempty" yaml:"creatorId,omitempty"`
CurrentReplicas int64 `json:"currentReplicas,omitempty" yaml:"currentReplicas,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
DesiredReplicas int64 `json:"desiredReplicas,omitempty" yaml:"desiredReplicas,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
LastScaleTime string `json:"lastScaleTime,omitempty" yaml:"lastScaleTime,omitempty"`
MaxReplicas int64 `json:"maxReplicas,omitempty" yaml:"maxReplicas,omitempty"`
Metrics []Metric `json:"metrics,omitempty" yaml:"metrics,omitempty"`
MinReplicas *int64 `json:"minReplicas,omitempty" yaml:"minReplicas,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
NamespaceId string `json:"namespaceId,omitempty" yaml:"namespaceId,omitempty"`
ObservedGeneration *int64 `json:"observedGeneration,omitempty" yaml:"observedGeneration,omitempty"`
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty" yaml:"ownerReferences,omitempty"`
ProjectID string `json:"projectId,omitempty" yaml:"projectId,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioningMessage,omitempty"`
UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
WorkloadId string `json:"workloadId,omitempty" yaml:"workloadId,omitempty"`
}
type HorizontalPodAutoscalerCollection struct {
types.Collection
Data []HorizontalPodAutoscaler `json:"data,omitempty"`
client *HorizontalPodAutoscalerClient
}
type HorizontalPodAutoscalerClient struct {
apiClient *Client
}
type HorizontalPodAutoscalerOperations interface {
List(opts *types.ListOpts) (*HorizontalPodAutoscalerCollection, error)
Create(opts *HorizontalPodAutoscaler) (*HorizontalPodAutoscaler, error)
Update(existing *HorizontalPodAutoscaler, updates interface{}) (*HorizontalPodAutoscaler, error)
Replace(existing *HorizontalPodAutoscaler) (*HorizontalPodAutoscaler, error)
ByID(id string) (*HorizontalPodAutoscaler, error)
Delete(container *HorizontalPodAutoscaler) error
}
func newHorizontalPodAutoscalerClient(apiClient *Client) *HorizontalPodAutoscalerClient {
return &HorizontalPodAutoscalerClient{
apiClient: apiClient,
}
}
func (c *HorizontalPodAutoscalerClient) Create(container *HorizontalPodAutoscaler) (*HorizontalPodAutoscaler, error) {
resp := &HorizontalPodAutoscaler{}
err := c.apiClient.Ops.DoCreate(HorizontalPodAutoscalerType, container, resp)
return resp, err
}
func (c *HorizontalPodAutoscalerClient) Update(existing *HorizontalPodAutoscaler, updates interface{}) (*HorizontalPodAutoscaler, error) {
resp := &HorizontalPodAutoscaler{}
err := c.apiClient.Ops.DoUpdate(HorizontalPodAutoscalerType, &existing.Resource, updates, resp)
return resp, err
}
func (c *HorizontalPodAutoscalerClient) Replace(obj *HorizontalPodAutoscaler) (*HorizontalPodAutoscaler, error) {
resp := &HorizontalPodAutoscaler{}
err := c.apiClient.Ops.DoReplace(HorizontalPodAutoscalerType, &obj.Resource, obj, resp)
return resp, err
}
func (c *HorizontalPodAutoscalerClient) List(opts *types.ListOpts) (*HorizontalPodAutoscalerCollection, error) {
resp := &HorizontalPodAutoscalerCollection{}
err := c.apiClient.Ops.DoList(HorizontalPodAutoscalerType, opts, resp)
resp.client = c
return resp, err
}
func (cc *HorizontalPodAutoscalerCollection) Next() (*HorizontalPodAutoscalerCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &HorizontalPodAutoscalerCollection{}
err := cc.client.apiClient.Ops.DoNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *HorizontalPodAutoscalerClient) ByID(id string) (*HorizontalPodAutoscaler, error) {
resp := &HorizontalPodAutoscaler{}
err := c.apiClient.Ops.DoByID(HorizontalPodAutoscalerType, id, resp)
return resp, err
}
func (c *HorizontalPodAutoscalerClient) Delete(container *HorizontalPodAutoscaler) error {
return c.apiClient.Ops.DoResourceDelete(HorizontalPodAutoscalerType, &container.Resource)
}

View File

@ -0,0 +1,18 @@
package client
const (
HorizontalPodAutoscalerConditionType = "horizontalPodAutoscalerCondition"
HorizontalPodAutoscalerConditionFieldLastTransitionTime = "lastTransitionTime"
HorizontalPodAutoscalerConditionFieldMessage = "message"
HorizontalPodAutoscalerConditionFieldReason = "reason"
HorizontalPodAutoscalerConditionFieldStatus = "status"
HorizontalPodAutoscalerConditionFieldType = "type"
)
type HorizontalPodAutoscalerCondition struct {
LastTransitionTime string `json:"lastTransitionTime,omitempty" yaml:"lastTransitionTime,omitempty"`
Message string `json:"message,omitempty" yaml:"message,omitempty"`
Reason string `json:"reason,omitempty" yaml:"reason,omitempty"`
Status string `json:"status,omitempty" yaml:"status,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
}

View File

@ -0,0 +1,16 @@
package client
const (
HorizontalPodAutoscalerSpecType = "horizontalPodAutoscalerSpec"
HorizontalPodAutoscalerSpecFieldMaxReplicas = "maxReplicas"
HorizontalPodAutoscalerSpecFieldMetrics = "metrics"
HorizontalPodAutoscalerSpecFieldMinReplicas = "minReplicas"
HorizontalPodAutoscalerSpecFieldScaleTargetRef = "scaleTargetRef"
)
type HorizontalPodAutoscalerSpec struct {
MaxReplicas int64 `json:"maxReplicas,omitempty" yaml:"maxReplicas,omitempty"`
Metrics []Metric `json:"metrics,omitempty" yaml:"metrics,omitempty"`
MinReplicas *int64 `json:"minReplicas,omitempty" yaml:"minReplicas,omitempty"`
ScaleTargetRef *CrossVersionObjectReference `json:"scaleTargetRef,omitempty" yaml:"scaleTargetRef,omitempty"`
}

View File

@ -0,0 +1,20 @@
package client
const (
HorizontalPodAutoscalerStatusType = "horizontalPodAutoscalerStatus"
HorizontalPodAutoscalerStatusFieldConditions = "conditions"
HorizontalPodAutoscalerStatusFieldCurrentMetrics = "currentMetrics"
HorizontalPodAutoscalerStatusFieldCurrentReplicas = "currentReplicas"
HorizontalPodAutoscalerStatusFieldDesiredReplicas = "desiredReplicas"
HorizontalPodAutoscalerStatusFieldLastScaleTime = "lastScaleTime"
HorizontalPodAutoscalerStatusFieldObservedGeneration = "observedGeneration"
)
type HorizontalPodAutoscalerStatus struct {
Conditions []HorizontalPodAutoscalerCondition `json:"conditions,omitempty" yaml:"conditions,omitempty"`
CurrentMetrics []MetricStatus `json:"currentMetrics,omitempty" yaml:"currentMetrics,omitempty"`
CurrentReplicas int64 `json:"currentReplicas,omitempty" yaml:"currentReplicas,omitempty"`
DesiredReplicas int64 `json:"desiredReplicas,omitempty" yaml:"desiredReplicas,omitempty"`
LastScaleTime string `json:"lastScaleTime,omitempty" yaml:"lastScaleTime,omitempty"`
ObservedGeneration *int64 `json:"observedGeneration,omitempty" yaml:"observedGeneration,omitempty"`
}

View File

@ -0,0 +1,20 @@
package client
const (
MetricType = "metric"
MetricFieldCurrent = "current"
MetricFieldDescribedObject = "describedObject"
MetricFieldName = "name"
MetricFieldSelector = "selector"
MetricFieldTarget = "target"
MetricFieldType = "type"
)
type Metric struct {
Current *MetricValueStatus `json:"current,omitempty" yaml:"current,omitempty"`
DescribedObject *CrossVersionObjectReference `json:"describedObject,omitempty" yaml:"describedObject,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Selector *LabelSelector `json:"selector,omitempty" yaml:"selector,omitempty"`
Target *MetricTarget `json:"target,omitempty" yaml:"target,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
}

View File

@ -0,0 +1,12 @@
package client
const (
MetricIdentifierType = "metricIdentifier"
MetricIdentifierFieldName = "name"
MetricIdentifierFieldSelector = "selector"
)
type MetricIdentifier struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Selector *LabelSelector `json:"selector,omitempty" yaml:"selector,omitempty"`
}

View File

@ -0,0 +1,20 @@
package client
const (
MetricStatusType = "metricStatus"
MetricStatusFieldCurrent = "current"
MetricStatusFieldExternal = "external"
MetricStatusFieldObject = "object"
MetricStatusFieldPods = "pods"
MetricStatusFieldResource = "resource"
MetricStatusFieldType = "type"
)
type MetricStatus struct {
Current *MetricValueStatus `json:"current,omitempty" yaml:"current,omitempty"`
External *ExternalMetricStatus `json:"external,omitempty" yaml:"external,omitempty"`
Object *ObjectMetricStatus `json:"object,omitempty" yaml:"object,omitempty"`
Pods *PodsMetricStatus `json:"pods,omitempty" yaml:"pods,omitempty"`
Resource *ResourceMetricStatus `json:"resource,omitempty" yaml:"resource,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
}

View File

@ -0,0 +1,16 @@
package client
const (
MetricTargetType = "metricTarget"
MetricTargetFieldAverageValue = "averageValue"
MetricTargetFieldType = "type"
MetricTargetFieldUtilization = "utilization"
MetricTargetFieldValue = "value"
)
type MetricTarget struct {
AverageValue string `json:"averageValue,omitempty" yaml:"averageValue,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Utilization *int64 `json:"utilization,omitempty" yaml:"utilization,omitempty"`
Value string `json:"value,omitempty" yaml:"value,omitempty"`
}

View File

@ -0,0 +1,14 @@
package client
const (
MetricValueStatusType = "metricValueStatus"
MetricValueStatusFieldAverageValue = "averageValue"
MetricValueStatusFieldUtilization = "utilization"
MetricValueStatusFieldValue = "value"
)
type MetricValueStatus struct {
AverageValue string `json:"averageValue,omitempty" yaml:"averageValue,omitempty"`
Utilization *int64 `json:"utilization,omitempty" yaml:"utilization,omitempty"`
Value string `json:"value,omitempty" yaml:"value,omitempty"`
}

View File

@ -0,0 +1,14 @@
package client
const (
ObjectMetricSourceType = "objectMetricSource"
ObjectMetricSourceFieldDescribedObject = "describedObject"
ObjectMetricSourceFieldMetric = "metric"
ObjectMetricSourceFieldTarget = "target"
)
type ObjectMetricSource struct {
DescribedObject *CrossVersionObjectReference `json:"describedObject,omitempty" yaml:"describedObject,omitempty"`
Metric *MetricIdentifier `json:"metric,omitempty" yaml:"metric,omitempty"`
Target *MetricTarget `json:"target,omitempty" yaml:"target,omitempty"`
}

View File

@ -0,0 +1,14 @@
package client
const (
ObjectMetricStatusType = "objectMetricStatus"
ObjectMetricStatusFieldCurrent = "current"
ObjectMetricStatusFieldDescribedObject = "describedObject"
ObjectMetricStatusFieldMetric = "metric"
)
type ObjectMetricStatus struct {
Current *MetricValueStatus `json:"current,omitempty" yaml:"current,omitempty"`
DescribedObject *CrossVersionObjectReference `json:"describedObject,omitempty" yaml:"describedObject,omitempty"`
Metric *MetricIdentifier `json:"metric,omitempty" yaml:"metric,omitempty"`
}

View File

@ -0,0 +1,12 @@
package client
const (
PodsMetricSourceType = "podsMetricSource"
PodsMetricSourceFieldMetric = "metric"
PodsMetricSourceFieldTarget = "target"
)
type PodsMetricSource struct {
Metric *MetricIdentifier `json:"metric,omitempty" yaml:"metric,omitempty"`
Target *MetricTarget `json:"target,omitempty" yaml:"target,omitempty"`
}

View File

@ -0,0 +1,12 @@
package client
const (
PodsMetricStatusType = "podsMetricStatus"
PodsMetricStatusFieldCurrent = "current"
PodsMetricStatusFieldMetric = "metric"
)
type PodsMetricStatus struct {
Current *MetricValueStatus `json:"current,omitempty" yaml:"current,omitempty"`
Metric *MetricIdentifier `json:"metric,omitempty" yaml:"metric,omitempty"`
}

View File

@ -0,0 +1,12 @@
package client
const (
ResourceMetricSourceType = "resourceMetricSource"
ResourceMetricSourceFieldName = "name"
ResourceMetricSourceFieldTarget = "target"
)
type ResourceMetricSource struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Target *MetricTarget `json:"target,omitempty" yaml:"target,omitempty"`
}

View File

@ -0,0 +1,12 @@
package client
const (
ResourceMetricStatusType = "resourceMetricStatus"
ResourceMetricStatusFieldCurrent = "current"
ResourceMetricStatusFieldName = "name"
)
type ResourceMetricStatus struct {
Current *MetricValueStatus `json:"current,omitempty" yaml:"current,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
}

View File

@ -107,4 +107,5 @@ type Config struct {
ServiceMonitors map[string]projectClient.ServiceMonitor `json:"serviceMonitors,omitempty" yaml:"serviceMonitors,omitempty"`
PrometheusRules map[string]projectClient.PrometheusRule `json:"prometheusRules,omitempty" yaml:"prometheusRules,omitempty"`
Alertmanagers map[string]projectClient.Alertmanager `json:"alertmanagers,omitempty" yaml:"alertmanagers,omitempty"`
HorizontalPodAutoscalers map[string]projectClient.HorizontalPodAutoscaler `json:"horizontalPodAutoscalers,omitempty" yaml:"horizontalPodAutoscalers,omitempty"`
}