mirror of
https://github.com/rancher/types.git
synced 2025-09-16 06:49:21 +00:00
Updated generated code
This commit is contained in:
@@ -5,7 +5,9 @@ import (
|
||||
|
||||
"github.com/rancher/norman/clientbase"
|
||||
"github.com/rancher/norman/controller"
|
||||
"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/watch"
|
||||
@@ -34,14 +36,22 @@ type ClusterList struct {
|
||||
|
||||
type ClusterHandlerFunc func(key string, obj *Cluster) error
|
||||
|
||||
type ClusterLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*Cluster, err error)
|
||||
Get(namespace, name string) (*Cluster, error)
|
||||
}
|
||||
|
||||
type ClusterController interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() ClusterLister
|
||||
AddHandler(handler ClusterHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type ClusterInterface interface {
|
||||
ObjectClient() *clientbase.ObjectClient
|
||||
Create(*Cluster) (*Cluster, error)
|
||||
Get(name string, opts metav1.GetOptions) (*Cluster, error)
|
||||
Update(*Cluster) (*Cluster, error)
|
||||
@@ -52,10 +62,41 @@ type ClusterInterface interface {
|
||||
Controller() ClusterController
|
||||
}
|
||||
|
||||
type clusterLister struct {
|
||||
controller *clusterController
|
||||
}
|
||||
|
||||
func (l *clusterLister) List(namespace string, selector labels.Selector) (ret []*Cluster, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*Cluster))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *clusterLister) Get(namespace, name string) (*Cluster, error) {
|
||||
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(schema.GroupResource{
|
||||
Group: ClusterGroupVersionKind.Group,
|
||||
Resource: "cluster",
|
||||
}, name)
|
||||
}
|
||||
return obj.(*Cluster), nil
|
||||
}
|
||||
|
||||
type clusterController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *clusterController) Lister() ClusterLister {
|
||||
return &clusterLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *clusterController) AddHandler(handler ClusterHandlerFunc) {
|
||||
c.GenericController.AddHandler(func(key string) error {
|
||||
obj, exists, err := c.Informer().GetStore().GetByKey(key)
|
||||
@@ -97,6 +138,7 @@ func (s *clusterClient) Controller() ClusterController {
|
||||
}
|
||||
|
||||
s.client.clusterControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
@@ -108,6 +150,10 @@ type clusterClient struct {
|
||||
controller ClusterController
|
||||
}
|
||||
|
||||
func (s *clusterClient) ObjectClient() *clientbase.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *clusterClient) Create(o *Cluster) (*Cluster, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*Cluster), err
|
||||
|
@@ -5,7 +5,9 @@ import (
|
||||
|
||||
"github.com/rancher/norman/clientbase"
|
||||
"github.com/rancher/norman/controller"
|
||||
"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/watch"
|
||||
@@ -34,14 +36,22 @@ type ClusterNodeList struct {
|
||||
|
||||
type ClusterNodeHandlerFunc func(key string, obj *ClusterNode) error
|
||||
|
||||
type ClusterNodeLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*ClusterNode, err error)
|
||||
Get(namespace, name string) (*ClusterNode, error)
|
||||
}
|
||||
|
||||
type ClusterNodeController interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() ClusterNodeLister
|
||||
AddHandler(handler ClusterNodeHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type ClusterNodeInterface interface {
|
||||
ObjectClient() *clientbase.ObjectClient
|
||||
Create(*ClusterNode) (*ClusterNode, error)
|
||||
Get(name string, opts metav1.GetOptions) (*ClusterNode, error)
|
||||
Update(*ClusterNode) (*ClusterNode, error)
|
||||
@@ -52,10 +62,41 @@ type ClusterNodeInterface interface {
|
||||
Controller() ClusterNodeController
|
||||
}
|
||||
|
||||
type clusterNodeLister struct {
|
||||
controller *clusterNodeController
|
||||
}
|
||||
|
||||
func (l *clusterNodeLister) List(namespace string, selector labels.Selector) (ret []*ClusterNode, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*ClusterNode))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *clusterNodeLister) Get(namespace, name string) (*ClusterNode, error) {
|
||||
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(schema.GroupResource{
|
||||
Group: ClusterNodeGroupVersionKind.Group,
|
||||
Resource: "clusterNode",
|
||||
}, name)
|
||||
}
|
||||
return obj.(*ClusterNode), nil
|
||||
}
|
||||
|
||||
type clusterNodeController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *clusterNodeController) Lister() ClusterNodeLister {
|
||||
return &clusterNodeLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *clusterNodeController) AddHandler(handler ClusterNodeHandlerFunc) {
|
||||
c.GenericController.AddHandler(func(key string) error {
|
||||
obj, exists, err := c.Informer().GetStore().GetByKey(key)
|
||||
@@ -97,6 +138,7 @@ func (s *clusterNodeClient) Controller() ClusterNodeController {
|
||||
}
|
||||
|
||||
s.client.clusterNodeControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
@@ -108,6 +150,10 @@ type clusterNodeClient struct {
|
||||
controller ClusterNodeController
|
||||
}
|
||||
|
||||
func (s *clusterNodeClient) ObjectClient() *clientbase.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *clusterNodeClient) Create(o *ClusterNode) (*ClusterNode, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*ClusterNode), err
|
||||
|
@@ -1,15 +1,18 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/rancher/norman/clientbase"
|
||||
"github.com/rancher/norman/controller"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
controller.Starter
|
||||
|
||||
ClustersGetter
|
||||
ClusterNodesGetter
|
||||
@@ -18,6 +21,7 @@ type Interface interface {
|
||||
type Client struct {
|
||||
sync.Mutex
|
||||
restClient rest.Interface
|
||||
starters []controller.Starter
|
||||
|
||||
clusterControllers map[string]ClusterController
|
||||
clusterNodeControllers map[string]ClusterNodeController
|
||||
@@ -46,6 +50,14 @@ 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 ClustersGetter interface {
|
||||
Clusters(namespace string) ClusterInterface
|
||||
}
|
||||
|
Reference in New Issue
Block a user