mirror of https://github.com/k3s-io/k3s
go generate
parent
4af06882b6
commit
ac2114eafe
|
@ -0,0 +1,441 @@
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/rancher/norman/controller"
|
||||||
|
"github.com/rancher/norman/objectclient"
|
||||||
|
v1 "k8s.io/api/apps/v1"
|
||||||
|
"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 (
|
||||||
|
DaemonSetGroupVersionKind = schema.GroupVersionKind{
|
||||||
|
Version: Version,
|
||||||
|
Group: GroupName,
|
||||||
|
Kind: "DaemonSet",
|
||||||
|
}
|
||||||
|
DaemonSetResource = metav1.APIResource{
|
||||||
|
Name: "daemonsets",
|
||||||
|
SingularName: "daemonset",
|
||||||
|
Namespaced: true,
|
||||||
|
|
||||||
|
Kind: DaemonSetGroupVersionKind.Kind,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewDaemonSet(namespace, name string, obj v1.DaemonSet) *v1.DaemonSet {
|
||||||
|
obj.APIVersion, obj.Kind = DaemonSetGroupVersionKind.ToAPIVersionAndKind()
|
||||||
|
obj.Name = name
|
||||||
|
obj.Namespace = namespace
|
||||||
|
return &obj
|
||||||
|
}
|
||||||
|
|
||||||
|
type DaemonSetList struct {
|
||||||
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
metav1.ListMeta `json:"metadata,omitempty"`
|
||||||
|
Items []v1.DaemonSet
|
||||||
|
}
|
||||||
|
|
||||||
|
type DaemonSetHandlerFunc func(key string, obj *v1.DaemonSet) (runtime.Object, error)
|
||||||
|
|
||||||
|
type DaemonSetChangeHandlerFunc func(obj *v1.DaemonSet) (runtime.Object, error)
|
||||||
|
|
||||||
|
type DaemonSetLister interface {
|
||||||
|
List(namespace string, selector labels.Selector) (ret []*v1.DaemonSet, err error)
|
||||||
|
Get(namespace, name string) (*v1.DaemonSet, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type DaemonSetController interface {
|
||||||
|
Generic() controller.GenericController
|
||||||
|
Informer() cache.SharedIndexInformer
|
||||||
|
Lister() DaemonSetLister
|
||||||
|
AddHandler(ctx context.Context, name string, handler DaemonSetHandlerFunc)
|
||||||
|
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler DaemonSetHandlerFunc)
|
||||||
|
Enqueue(namespace, name string)
|
||||||
|
Sync(ctx context.Context) error
|
||||||
|
Start(ctx context.Context, threadiness int) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type DaemonSetInterface interface {
|
||||||
|
ObjectClient() *objectclient.ObjectClient
|
||||||
|
Create(*v1.DaemonSet) (*v1.DaemonSet, error)
|
||||||
|
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.DaemonSet, error)
|
||||||
|
Get(name string, opts metav1.GetOptions) (*v1.DaemonSet, error)
|
||||||
|
Update(*v1.DaemonSet) (*v1.DaemonSet, error)
|
||||||
|
Delete(name string, options *metav1.DeleteOptions) error
|
||||||
|
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
|
||||||
|
List(opts metav1.ListOptions) (*DaemonSetList, error)
|
||||||
|
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||||
|
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||||
|
Controller() DaemonSetController
|
||||||
|
AddHandler(ctx context.Context, name string, sync DaemonSetHandlerFunc)
|
||||||
|
AddLifecycle(ctx context.Context, name string, lifecycle DaemonSetLifecycle)
|
||||||
|
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync DaemonSetHandlerFunc)
|
||||||
|
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle DaemonSetLifecycle)
|
||||||
|
}
|
||||||
|
|
||||||
|
type daemonSetLister struct {
|
||||||
|
controller *daemonSetController
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *daemonSetLister) List(namespace string, selector labels.Selector) (ret []*v1.DaemonSet, err error) {
|
||||||
|
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||||
|
ret = append(ret, obj.(*v1.DaemonSet))
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *daemonSetLister) Get(namespace, name string) (*v1.DaemonSet, 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: DaemonSetGroupVersionKind.Group,
|
||||||
|
Resource: "daemonSet",
|
||||||
|
}, key)
|
||||||
|
}
|
||||||
|
return obj.(*v1.DaemonSet), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type daemonSetController struct {
|
||||||
|
controller.GenericController
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *daemonSetController) Generic() controller.GenericController {
|
||||||
|
return c.GenericController
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *daemonSetController) Lister() DaemonSetLister {
|
||||||
|
return &daemonSetLister{
|
||||||
|
controller: c,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *daemonSetController) AddHandler(ctx context.Context, name string, handler DaemonSetHandlerFunc) {
|
||||||
|
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
|
||||||
|
if obj == nil {
|
||||||
|
return handler(key, nil)
|
||||||
|
} else if v, ok := obj.(*v1.DaemonSet); ok {
|
||||||
|
return handler(key, v)
|
||||||
|
} else {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *daemonSetController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler DaemonSetHandlerFunc) {
|
||||||
|
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
|
||||||
|
if obj == nil {
|
||||||
|
return handler(key, nil)
|
||||||
|
} else if v, ok := obj.(*v1.DaemonSet); ok && controller.ObjectInCluster(cluster, obj) {
|
||||||
|
return handler(key, v)
|
||||||
|
} else {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type daemonSetFactory struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c daemonSetFactory) Object() runtime.Object {
|
||||||
|
return &v1.DaemonSet{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c daemonSetFactory) List() runtime.Object {
|
||||||
|
return &DaemonSetList{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) Controller() DaemonSetController {
|
||||||
|
s.client.Lock()
|
||||||
|
defer s.client.Unlock()
|
||||||
|
|
||||||
|
c, ok := s.client.daemonSetControllers[s.ns]
|
||||||
|
if ok {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
genericController := controller.NewGenericController(DaemonSetGroupVersionKind.Kind+"Controller",
|
||||||
|
s.objectClient)
|
||||||
|
|
||||||
|
c = &daemonSetController{
|
||||||
|
GenericController: genericController,
|
||||||
|
}
|
||||||
|
|
||||||
|
s.client.daemonSetControllers[s.ns] = c
|
||||||
|
s.client.starters = append(s.client.starters, c)
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
type daemonSetClient struct {
|
||||||
|
client *Client
|
||||||
|
ns string
|
||||||
|
objectClient *objectclient.ObjectClient
|
||||||
|
controller DaemonSetController
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) ObjectClient() *objectclient.ObjectClient {
|
||||||
|
return s.objectClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) Create(o *v1.DaemonSet) (*v1.DaemonSet, error) {
|
||||||
|
obj, err := s.objectClient.Create(o)
|
||||||
|
return obj.(*v1.DaemonSet), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) Get(name string, opts metav1.GetOptions) (*v1.DaemonSet, error) {
|
||||||
|
obj, err := s.objectClient.Get(name, opts)
|
||||||
|
return obj.(*v1.DaemonSet), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.DaemonSet, error) {
|
||||||
|
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
|
||||||
|
return obj.(*v1.DaemonSet), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) Update(o *v1.DaemonSet) (*v1.DaemonSet, error) {
|
||||||
|
obj, err := s.objectClient.Update(o.Name, o)
|
||||||
|
return obj.(*v1.DaemonSet), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) Delete(name string, options *metav1.DeleteOptions) error {
|
||||||
|
return s.objectClient.Delete(name, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
|
||||||
|
return s.objectClient.DeleteNamespaced(namespace, name, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) List(opts metav1.ListOptions) (*DaemonSetList, error) {
|
||||||
|
obj, err := s.objectClient.List(opts)
|
||||||
|
return obj.(*DaemonSetList), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||||
|
return s.objectClient.Watch(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Patch applies the patch and returns the patched deployment.
|
||||||
|
func (s *daemonSetClient) Patch(o *v1.DaemonSet, patchType types.PatchType, data []byte, subresources ...string) (*v1.DaemonSet, error) {
|
||||||
|
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
|
||||||
|
return obj.(*v1.DaemonSet), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||||
|
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) AddHandler(ctx context.Context, name string, sync DaemonSetHandlerFunc) {
|
||||||
|
s.Controller().AddHandler(ctx, name, sync)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) AddLifecycle(ctx context.Context, name string, lifecycle DaemonSetLifecycle) {
|
||||||
|
sync := NewDaemonSetLifecycleAdapter(name, false, s, lifecycle)
|
||||||
|
s.Controller().AddHandler(ctx, name, sync)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync DaemonSetHandlerFunc) {
|
||||||
|
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *daemonSetClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle DaemonSetLifecycle) {
|
||||||
|
sync := NewDaemonSetLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
|
||||||
|
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||||
|
}
|
||||||
|
|
||||||
|
type DaemonSetIndexer func(obj *v1.DaemonSet) ([]string, error)
|
||||||
|
|
||||||
|
type DaemonSetClientCache interface {
|
||||||
|
Get(namespace, name string) (*v1.DaemonSet, error)
|
||||||
|
List(namespace string, selector labels.Selector) ([]*v1.DaemonSet, error)
|
||||||
|
|
||||||
|
Index(name string, indexer DaemonSetIndexer)
|
||||||
|
GetIndexed(name, key string) ([]*v1.DaemonSet, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type DaemonSetClient interface {
|
||||||
|
Create(*v1.DaemonSet) (*v1.DaemonSet, error)
|
||||||
|
Get(namespace, name string, opts metav1.GetOptions) (*v1.DaemonSet, error)
|
||||||
|
Update(*v1.DaemonSet) (*v1.DaemonSet, error)
|
||||||
|
Delete(namespace, name string, options *metav1.DeleteOptions) error
|
||||||
|
List(namespace string, opts metav1.ListOptions) (*DaemonSetList, error)
|
||||||
|
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||||
|
|
||||||
|
Cache() DaemonSetClientCache
|
||||||
|
|
||||||
|
OnCreate(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc)
|
||||||
|
OnChange(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc)
|
||||||
|
OnRemove(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc)
|
||||||
|
Enqueue(namespace, name string)
|
||||||
|
|
||||||
|
Generic() controller.GenericController
|
||||||
|
ObjectClient() *objectclient.ObjectClient
|
||||||
|
Interface() DaemonSetInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
type daemonSetClientCache struct {
|
||||||
|
client *daemonSetClient2
|
||||||
|
}
|
||||||
|
|
||||||
|
type daemonSetClient2 struct {
|
||||||
|
iface DaemonSetInterface
|
||||||
|
controller DaemonSetController
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) Interface() DaemonSetInterface {
|
||||||
|
return n.iface
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) Generic() controller.GenericController {
|
||||||
|
return n.iface.Controller().Generic()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) ObjectClient() *objectclient.ObjectClient {
|
||||||
|
return n.Interface().ObjectClient()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) Enqueue(namespace, name string) {
|
||||||
|
n.iface.Controller().Enqueue(namespace, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) Create(obj *v1.DaemonSet) (*v1.DaemonSet, error) {
|
||||||
|
return n.iface.Create(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.DaemonSet, error) {
|
||||||
|
return n.iface.GetNamespaced(namespace, name, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) Update(obj *v1.DaemonSet) (*v1.DaemonSet, error) {
|
||||||
|
return n.iface.Update(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
|
||||||
|
return n.iface.DeleteNamespaced(namespace, name, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) List(namespace string, opts metav1.ListOptions) (*DaemonSetList, error) {
|
||||||
|
return n.iface.List(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||||
|
return n.iface.Watch(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClientCache) Get(namespace, name string) (*v1.DaemonSet, error) {
|
||||||
|
return n.client.controller.Lister().Get(namespace, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClientCache) List(namespace string, selector labels.Selector) ([]*v1.DaemonSet, error) {
|
||||||
|
return n.client.controller.Lister().List(namespace, selector)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) Cache() DaemonSetClientCache {
|
||||||
|
n.loadController()
|
||||||
|
return &daemonSetClientCache{
|
||||||
|
client: n,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) OnCreate(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc) {
|
||||||
|
n.loadController()
|
||||||
|
n.iface.AddLifecycle(ctx, name+"-create", &daemonSetLifecycleDelegate{create: sync})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) OnChange(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc) {
|
||||||
|
n.loadController()
|
||||||
|
n.iface.AddLifecycle(ctx, name+"-change", &daemonSetLifecycleDelegate{update: sync})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) OnRemove(ctx context.Context, name string, sync DaemonSetChangeHandlerFunc) {
|
||||||
|
n.loadController()
|
||||||
|
n.iface.AddLifecycle(ctx, name, &daemonSetLifecycleDelegate{remove: sync})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClientCache) Index(name string, indexer DaemonSetIndexer) {
|
||||||
|
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
|
||||||
|
name: func(obj interface{}) ([]string, error) {
|
||||||
|
if v, ok := obj.(*v1.DaemonSet); ok {
|
||||||
|
return indexer(v)
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClientCache) GetIndexed(name, key string) ([]*v1.DaemonSet, error) {
|
||||||
|
var result []*v1.DaemonSet
|
||||||
|
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, obj := range objs {
|
||||||
|
if v, ok := obj.(*v1.DaemonSet); ok {
|
||||||
|
result = append(result, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetClient2) loadController() {
|
||||||
|
if n.controller == nil {
|
||||||
|
n.controller = n.iface.Controller()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type daemonSetLifecycleDelegate struct {
|
||||||
|
create DaemonSetChangeHandlerFunc
|
||||||
|
update DaemonSetChangeHandlerFunc
|
||||||
|
remove DaemonSetChangeHandlerFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetLifecycleDelegate) HasCreate() bool {
|
||||||
|
return n.create != nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetLifecycleDelegate) Create(obj *v1.DaemonSet) (runtime.Object, error) {
|
||||||
|
if n.create == nil {
|
||||||
|
return obj, nil
|
||||||
|
}
|
||||||
|
return n.create(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetLifecycleDelegate) HasFinalize() bool {
|
||||||
|
return n.remove != nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetLifecycleDelegate) Remove(obj *v1.DaemonSet) (runtime.Object, error) {
|
||||||
|
if n.remove == nil {
|
||||||
|
return obj, nil
|
||||||
|
}
|
||||||
|
return n.remove(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *daemonSetLifecycleDelegate) Updated(obj *v1.DaemonSet) (runtime.Object, error) {
|
||||||
|
if n.update == nil {
|
||||||
|
return obj, nil
|
||||||
|
}
|
||||||
|
return n.update(obj)
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/rancher/norman/lifecycle"
|
||||||
|
v1 "k8s.io/api/apps/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DaemonSetLifecycle interface {
|
||||||
|
Create(obj *v1.DaemonSet) (runtime.Object, error)
|
||||||
|
Remove(obj *v1.DaemonSet) (runtime.Object, error)
|
||||||
|
Updated(obj *v1.DaemonSet) (runtime.Object, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type daemonSetLifecycleAdapter struct {
|
||||||
|
lifecycle DaemonSetLifecycle
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *daemonSetLifecycleAdapter) HasCreate() bool {
|
||||||
|
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||||
|
return !ok || o.HasCreate()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *daemonSetLifecycleAdapter) HasFinalize() bool {
|
||||||
|
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||||
|
return !ok || o.HasFinalize()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *daemonSetLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
|
||||||
|
o, err := w.lifecycle.Create(obj.(*v1.DaemonSet))
|
||||||
|
if o == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return o, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *daemonSetLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
|
||||||
|
o, err := w.lifecycle.Remove(obj.(*v1.DaemonSet))
|
||||||
|
if o == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return o, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *daemonSetLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
|
||||||
|
o, err := w.lifecycle.Updated(obj.(*v1.DaemonSet))
|
||||||
|
if o == nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return o, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDaemonSetLifecycleAdapter(name string, clusterScoped bool, client DaemonSetInterface, l DaemonSetLifecycle) DaemonSetHandlerFunc {
|
||||||
|
adapter := &daemonSetLifecycleAdapter{lifecycle: l}
|
||||||
|
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
|
||||||
|
return func(key string, obj *v1.DaemonSet) (runtime.Object, error) {
|
||||||
|
newObj, err := syncFn(key, obj)
|
||||||
|
if o, ok := newObj.(runtime.Object); ok {
|
||||||
|
return o, err
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,13 +6,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *DeploymentList) DeepCopyInto(out *DeploymentList) {
|
func (in *DaemonSetList) DeepCopyInto(out *DaemonSetList) {
|
||||||
*out = *in
|
*out = *in
|
||||||
out.TypeMeta = in.TypeMeta
|
out.TypeMeta = in.TypeMeta
|
||||||
out.ListMeta = in.ListMeta
|
out.ListMeta = in.ListMeta
|
||||||
if in.Items != nil {
|
if in.Items != nil {
|
||||||
in, out := &in.Items, &out.Items
|
in, out := &in.Items, &out.Items
|
||||||
*out = make([]appsv1.Deployment, len(*in))
|
*out = make([]appsv1.DaemonSet, len(*in))
|
||||||
for i := range *in {
|
for i := range *in {
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
|
@ -20,18 +20,18 @@ func (in *DeploymentList) DeepCopyInto(out *DeploymentList) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentList.
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonSetList.
|
||||||
func (in *DeploymentList) DeepCopy() *DeploymentList {
|
func (in *DaemonSetList) DeepCopy() *DaemonSetList {
|
||||||
if in == nil {
|
if in == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
out := new(DeploymentList)
|
out := new(DaemonSetList)
|
||||||
in.DeepCopyInto(out)
|
in.DeepCopyInto(out)
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||||
func (in *DeploymentList) DeepCopyObject() runtime.Object {
|
func (in *DaemonSetList) DeepCopyObject() runtime.Object {
|
||||||
if c := in.DeepCopy(); c != nil {
|
if c := in.DeepCopy(); c != nil {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,441 +0,0 @@
|
||||||
package v1
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/rancher/norman/controller"
|
|
||||||
"github.com/rancher/norman/objectclient"
|
|
||||||
v1 "k8s.io/api/apps/v1"
|
|
||||||
"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 (
|
|
||||||
DeploymentGroupVersionKind = schema.GroupVersionKind{
|
|
||||||
Version: Version,
|
|
||||||
Group: GroupName,
|
|
||||||
Kind: "Deployment",
|
|
||||||
}
|
|
||||||
DeploymentResource = metav1.APIResource{
|
|
||||||
Name: "deployments",
|
|
||||||
SingularName: "deployment",
|
|
||||||
Namespaced: true,
|
|
||||||
|
|
||||||
Kind: DeploymentGroupVersionKind.Kind,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewDeployment(namespace, name string, obj v1.Deployment) *v1.Deployment {
|
|
||||||
obj.APIVersion, obj.Kind = DeploymentGroupVersionKind.ToAPIVersionAndKind()
|
|
||||||
obj.Name = name
|
|
||||||
obj.Namespace = namespace
|
|
||||||
return &obj
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeploymentList struct {
|
|
||||||
metav1.TypeMeta `json:",inline"`
|
|
||||||
metav1.ListMeta `json:"metadata,omitempty"`
|
|
||||||
Items []v1.Deployment
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeploymentHandlerFunc func(key string, obj *v1.Deployment) (runtime.Object, error)
|
|
||||||
|
|
||||||
type DeploymentChangeHandlerFunc func(obj *v1.Deployment) (runtime.Object, error)
|
|
||||||
|
|
||||||
type DeploymentLister interface {
|
|
||||||
List(namespace string, selector labels.Selector) (ret []*v1.Deployment, err error)
|
|
||||||
Get(namespace, name string) (*v1.Deployment, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeploymentController interface {
|
|
||||||
Generic() controller.GenericController
|
|
||||||
Informer() cache.SharedIndexInformer
|
|
||||||
Lister() DeploymentLister
|
|
||||||
AddHandler(ctx context.Context, name string, handler DeploymentHandlerFunc)
|
|
||||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler DeploymentHandlerFunc)
|
|
||||||
Enqueue(namespace, name string)
|
|
||||||
Sync(ctx context.Context) error
|
|
||||||
Start(ctx context.Context, threadiness int) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeploymentInterface interface {
|
|
||||||
ObjectClient() *objectclient.ObjectClient
|
|
||||||
Create(*v1.Deployment) (*v1.Deployment, error)
|
|
||||||
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Deployment, error)
|
|
||||||
Get(name string, opts metav1.GetOptions) (*v1.Deployment, error)
|
|
||||||
Update(*v1.Deployment) (*v1.Deployment, error)
|
|
||||||
Delete(name string, options *metav1.DeleteOptions) error
|
|
||||||
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
|
|
||||||
List(opts metav1.ListOptions) (*DeploymentList, error)
|
|
||||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
|
||||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
|
||||||
Controller() DeploymentController
|
|
||||||
AddHandler(ctx context.Context, name string, sync DeploymentHandlerFunc)
|
|
||||||
AddLifecycle(ctx context.Context, name string, lifecycle DeploymentLifecycle)
|
|
||||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync DeploymentHandlerFunc)
|
|
||||||
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle DeploymentLifecycle)
|
|
||||||
}
|
|
||||||
|
|
||||||
type deploymentLister struct {
|
|
||||||
controller *deploymentController
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *deploymentLister) List(namespace string, selector labels.Selector) (ret []*v1.Deployment, err error) {
|
|
||||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
|
||||||
ret = append(ret, obj.(*v1.Deployment))
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *deploymentLister) Get(namespace, name string) (*v1.Deployment, 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: DeploymentGroupVersionKind.Group,
|
|
||||||
Resource: "deployment",
|
|
||||||
}, key)
|
|
||||||
}
|
|
||||||
return obj.(*v1.Deployment), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type deploymentController struct {
|
|
||||||
controller.GenericController
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *deploymentController) Generic() controller.GenericController {
|
|
||||||
return c.GenericController
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *deploymentController) Lister() DeploymentLister {
|
|
||||||
return &deploymentLister{
|
|
||||||
controller: c,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *deploymentController) AddHandler(ctx context.Context, name string, handler DeploymentHandlerFunc) {
|
|
||||||
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
|
|
||||||
if obj == nil {
|
|
||||||
return handler(key, nil)
|
|
||||||
} else if v, ok := obj.(*v1.Deployment); ok {
|
|
||||||
return handler(key, v)
|
|
||||||
} else {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *deploymentController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler DeploymentHandlerFunc) {
|
|
||||||
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
|
|
||||||
if obj == nil {
|
|
||||||
return handler(key, nil)
|
|
||||||
} else if v, ok := obj.(*v1.Deployment); ok && controller.ObjectInCluster(cluster, obj) {
|
|
||||||
return handler(key, v)
|
|
||||||
} else {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
type deploymentFactory struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c deploymentFactory) Object() runtime.Object {
|
|
||||||
return &v1.Deployment{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c deploymentFactory) List() runtime.Object {
|
|
||||||
return &DeploymentList{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) Controller() DeploymentController {
|
|
||||||
s.client.Lock()
|
|
||||||
defer s.client.Unlock()
|
|
||||||
|
|
||||||
c, ok := s.client.deploymentControllers[s.ns]
|
|
||||||
if ok {
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
genericController := controller.NewGenericController(DeploymentGroupVersionKind.Kind+"Controller",
|
|
||||||
s.objectClient)
|
|
||||||
|
|
||||||
c = &deploymentController{
|
|
||||||
GenericController: genericController,
|
|
||||||
}
|
|
||||||
|
|
||||||
s.client.deploymentControllers[s.ns] = c
|
|
||||||
s.client.starters = append(s.client.starters, c)
|
|
||||||
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
type deploymentClient struct {
|
|
||||||
client *Client
|
|
||||||
ns string
|
|
||||||
objectClient *objectclient.ObjectClient
|
|
||||||
controller DeploymentController
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) ObjectClient() *objectclient.ObjectClient {
|
|
||||||
return s.objectClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) Create(o *v1.Deployment) (*v1.Deployment, error) {
|
|
||||||
obj, err := s.objectClient.Create(o)
|
|
||||||
return obj.(*v1.Deployment), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) Get(name string, opts metav1.GetOptions) (*v1.Deployment, error) {
|
|
||||||
obj, err := s.objectClient.Get(name, opts)
|
|
||||||
return obj.(*v1.Deployment), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Deployment, error) {
|
|
||||||
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
|
|
||||||
return obj.(*v1.Deployment), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) Update(o *v1.Deployment) (*v1.Deployment, error) {
|
|
||||||
obj, err := s.objectClient.Update(o.Name, o)
|
|
||||||
return obj.(*v1.Deployment), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) Delete(name string, options *metav1.DeleteOptions) error {
|
|
||||||
return s.objectClient.Delete(name, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
|
|
||||||
return s.objectClient.DeleteNamespaced(namespace, name, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) List(opts metav1.ListOptions) (*DeploymentList, error) {
|
|
||||||
obj, err := s.objectClient.List(opts)
|
|
||||||
return obj.(*DeploymentList), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
|
||||||
return s.objectClient.Watch(opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched deployment.
|
|
||||||
func (s *deploymentClient) Patch(o *v1.Deployment, patchType types.PatchType, data []byte, subresources ...string) (*v1.Deployment, error) {
|
|
||||||
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
|
|
||||||
return obj.(*v1.Deployment), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
|
||||||
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) AddHandler(ctx context.Context, name string, sync DeploymentHandlerFunc) {
|
|
||||||
s.Controller().AddHandler(ctx, name, sync)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) AddLifecycle(ctx context.Context, name string, lifecycle DeploymentLifecycle) {
|
|
||||||
sync := NewDeploymentLifecycleAdapter(name, false, s, lifecycle)
|
|
||||||
s.Controller().AddHandler(ctx, name, sync)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync DeploymentHandlerFunc) {
|
|
||||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *deploymentClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle DeploymentLifecycle) {
|
|
||||||
sync := NewDeploymentLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
|
|
||||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeploymentIndexer func(obj *v1.Deployment) ([]string, error)
|
|
||||||
|
|
||||||
type DeploymentClientCache interface {
|
|
||||||
Get(namespace, name string) (*v1.Deployment, error)
|
|
||||||
List(namespace string, selector labels.Selector) ([]*v1.Deployment, error)
|
|
||||||
|
|
||||||
Index(name string, indexer DeploymentIndexer)
|
|
||||||
GetIndexed(name, key string) ([]*v1.Deployment, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeploymentClient interface {
|
|
||||||
Create(*v1.Deployment) (*v1.Deployment, error)
|
|
||||||
Get(namespace, name string, opts metav1.GetOptions) (*v1.Deployment, error)
|
|
||||||
Update(*v1.Deployment) (*v1.Deployment, error)
|
|
||||||
Delete(namespace, name string, options *metav1.DeleteOptions) error
|
|
||||||
List(namespace string, opts metav1.ListOptions) (*DeploymentList, error)
|
|
||||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
|
||||||
|
|
||||||
Cache() DeploymentClientCache
|
|
||||||
|
|
||||||
OnCreate(ctx context.Context, name string, sync DeploymentChangeHandlerFunc)
|
|
||||||
OnChange(ctx context.Context, name string, sync DeploymentChangeHandlerFunc)
|
|
||||||
OnRemove(ctx context.Context, name string, sync DeploymentChangeHandlerFunc)
|
|
||||||
Enqueue(namespace, name string)
|
|
||||||
|
|
||||||
Generic() controller.GenericController
|
|
||||||
ObjectClient() *objectclient.ObjectClient
|
|
||||||
Interface() DeploymentInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
type deploymentClientCache struct {
|
|
||||||
client *deploymentClient2
|
|
||||||
}
|
|
||||||
|
|
||||||
type deploymentClient2 struct {
|
|
||||||
iface DeploymentInterface
|
|
||||||
controller DeploymentController
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) Interface() DeploymentInterface {
|
|
||||||
return n.iface
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) Generic() controller.GenericController {
|
|
||||||
return n.iface.Controller().Generic()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) ObjectClient() *objectclient.ObjectClient {
|
|
||||||
return n.Interface().ObjectClient()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) Enqueue(namespace, name string) {
|
|
||||||
n.iface.Controller().Enqueue(namespace, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) Create(obj *v1.Deployment) (*v1.Deployment, error) {
|
|
||||||
return n.iface.Create(obj)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.Deployment, error) {
|
|
||||||
return n.iface.GetNamespaced(namespace, name, opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) Update(obj *v1.Deployment) (*v1.Deployment, error) {
|
|
||||||
return n.iface.Update(obj)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
|
|
||||||
return n.iface.DeleteNamespaced(namespace, name, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) List(namespace string, opts metav1.ListOptions) (*DeploymentList, error) {
|
|
||||||
return n.iface.List(opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
|
||||||
return n.iface.Watch(opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClientCache) Get(namespace, name string) (*v1.Deployment, error) {
|
|
||||||
return n.client.controller.Lister().Get(namespace, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClientCache) List(namespace string, selector labels.Selector) ([]*v1.Deployment, error) {
|
|
||||||
return n.client.controller.Lister().List(namespace, selector)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) Cache() DeploymentClientCache {
|
|
||||||
n.loadController()
|
|
||||||
return &deploymentClientCache{
|
|
||||||
client: n,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) OnCreate(ctx context.Context, name string, sync DeploymentChangeHandlerFunc) {
|
|
||||||
n.loadController()
|
|
||||||
n.iface.AddLifecycle(ctx, name+"-create", &deploymentLifecycleDelegate{create: sync})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) OnChange(ctx context.Context, name string, sync DeploymentChangeHandlerFunc) {
|
|
||||||
n.loadController()
|
|
||||||
n.iface.AddLifecycle(ctx, name+"-change", &deploymentLifecycleDelegate{update: sync})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) OnRemove(ctx context.Context, name string, sync DeploymentChangeHandlerFunc) {
|
|
||||||
n.loadController()
|
|
||||||
n.iface.AddLifecycle(ctx, name, &deploymentLifecycleDelegate{remove: sync})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClientCache) Index(name string, indexer DeploymentIndexer) {
|
|
||||||
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
|
|
||||||
name: func(obj interface{}) ([]string, error) {
|
|
||||||
if v, ok := obj.(*v1.Deployment); ok {
|
|
||||||
return indexer(v)
|
|
||||||
}
|
|
||||||
return nil, nil
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClientCache) GetIndexed(name, key string) ([]*v1.Deployment, error) {
|
|
||||||
var result []*v1.Deployment
|
|
||||||
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
for _, obj := range objs {
|
|
||||||
if v, ok := obj.(*v1.Deployment); ok {
|
|
||||||
result = append(result, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentClient2) loadController() {
|
|
||||||
if n.controller == nil {
|
|
||||||
n.controller = n.iface.Controller()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type deploymentLifecycleDelegate struct {
|
|
||||||
create DeploymentChangeHandlerFunc
|
|
||||||
update DeploymentChangeHandlerFunc
|
|
||||||
remove DeploymentChangeHandlerFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentLifecycleDelegate) HasCreate() bool {
|
|
||||||
return n.create != nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentLifecycleDelegate) Create(obj *v1.Deployment) (runtime.Object, error) {
|
|
||||||
if n.create == nil {
|
|
||||||
return obj, nil
|
|
||||||
}
|
|
||||||
return n.create(obj)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentLifecycleDelegate) HasFinalize() bool {
|
|
||||||
return n.remove != nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentLifecycleDelegate) Remove(obj *v1.Deployment) (runtime.Object, error) {
|
|
||||||
if n.remove == nil {
|
|
||||||
return obj, nil
|
|
||||||
}
|
|
||||||
return n.remove(obj)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *deploymentLifecycleDelegate) Updated(obj *v1.Deployment) (runtime.Object, error) {
|
|
||||||
if n.update == nil {
|
|
||||||
return obj, nil
|
|
||||||
}
|
|
||||||
return n.update(obj)
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
package v1
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/rancher/norman/lifecycle"
|
|
||||||
v1 "k8s.io/api/apps/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DeploymentLifecycle interface {
|
|
||||||
Create(obj *v1.Deployment) (runtime.Object, error)
|
|
||||||
Remove(obj *v1.Deployment) (runtime.Object, error)
|
|
||||||
Updated(obj *v1.Deployment) (runtime.Object, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type deploymentLifecycleAdapter struct {
|
|
||||||
lifecycle DeploymentLifecycle
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *deploymentLifecycleAdapter) HasCreate() bool {
|
|
||||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
|
||||||
return !ok || o.HasCreate()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *deploymentLifecycleAdapter) HasFinalize() bool {
|
|
||||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
|
||||||
return !ok || o.HasFinalize()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *deploymentLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
|
|
||||||
o, err := w.lifecycle.Create(obj.(*v1.Deployment))
|
|
||||||
if o == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return o, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *deploymentLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
|
|
||||||
o, err := w.lifecycle.Remove(obj.(*v1.Deployment))
|
|
||||||
if o == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return o, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *deploymentLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
|
|
||||||
o, err := w.lifecycle.Updated(obj.(*v1.Deployment))
|
|
||||||
if o == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return o, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDeploymentLifecycleAdapter(name string, clusterScoped bool, client DeploymentInterface, l DeploymentLifecycle) DeploymentHandlerFunc {
|
|
||||||
adapter := &deploymentLifecycleAdapter{lifecycle: l}
|
|
||||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
|
|
||||||
return func(key string, obj *v1.Deployment) (runtime.Object, error) {
|
|
||||||
newObj, err := syncFn(key, obj)
|
|
||||||
if o, ok := newObj.(runtime.Object); ok {
|
|
||||||
return o, err
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,13 +20,13 @@ type Interface interface {
|
||||||
RESTClient() rest.Interface
|
RESTClient() rest.Interface
|
||||||
controller.Starter
|
controller.Starter
|
||||||
|
|
||||||
DeploymentsGetter
|
DaemonSetsGetter
|
||||||
}
|
}
|
||||||
|
|
||||||
type Clients struct {
|
type Clients struct {
|
||||||
Interface Interface
|
Interface Interface
|
||||||
|
|
||||||
Deployment DeploymentClient
|
DaemonSet DaemonSetClient
|
||||||
}
|
}
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
@ -34,7 +34,7 @@ type Client struct {
|
||||||
restClient rest.Interface
|
restClient rest.Interface
|
||||||
starters []controller.Starter
|
starters []controller.Starter
|
||||||
|
|
||||||
deploymentControllers map[string]DeploymentController
|
daemonSetControllers map[string]DaemonSetController
|
||||||
}
|
}
|
||||||
|
|
||||||
func Factory(ctx context.Context, config rest.Config) (context.Context, controller.Starter, error) {
|
func Factory(ctx context.Context, config rest.Config) (context.Context, controller.Starter, error) {
|
||||||
|
@ -70,8 +70,8 @@ func NewClientsFromInterface(iface Interface) *Clients {
|
||||||
return &Clients{
|
return &Clients{
|
||||||
Interface: iface,
|
Interface: iface,
|
||||||
|
|
||||||
Deployment: &deploymentClient2{
|
DaemonSet: &daemonSetClient2{
|
||||||
iface: iface.Deployments(""),
|
iface: iface.DaemonSets(""),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ func NewForConfig(config rest.Config) (Interface, error) {
|
||||||
return &Client{
|
return &Client{
|
||||||
restClient: restClient,
|
restClient: restClient,
|
||||||
|
|
||||||
deploymentControllers: map[string]DeploymentController{},
|
daemonSetControllers: map[string]DaemonSetController{},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,13 +105,13 @@ func (c *Client) Start(ctx context.Context, threadiness int) error {
|
||||||
return controller.Start(ctx, threadiness, c.starters...)
|
return controller.Start(ctx, threadiness, c.starters...)
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeploymentsGetter interface {
|
type DaemonSetsGetter interface {
|
||||||
Deployments(namespace string) DeploymentInterface
|
DaemonSets(namespace string) DaemonSetInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Deployments(namespace string) DeploymentInterface {
|
func (c *Client) DaemonSets(namespace string) DaemonSetInterface {
|
||||||
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &DeploymentResource, DeploymentGroupVersionKind, deploymentFactory{})
|
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &DaemonSetResource, DaemonSetGroupVersionKind, daemonSetFactory{})
|
||||||
return &deploymentClient{
|
return &daemonSetClient{
|
||||||
ns: namespace,
|
ns: namespace,
|
||||||
client: c,
|
client: c,
|
||||||
objectClient: objectClient,
|
objectClient: objectClient,
|
||||||
|
|
|
@ -33,7 +33,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
||||||
// TODO this gets cleaned up when the types are fixed
|
// TODO this gets cleaned up when the types are fixed
|
||||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
|
|
||||||
&DeploymentList{},
|
&DaemonSetList{},
|
||||||
)
|
)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := generator.ControllersForForeignTypes(basePackage, appsv1.SchemeGroupVersion, []interface{}{
|
if err := generator.ControllersForForeignTypes(basePackage, appsv1.SchemeGroupVersion, []interface{}{
|
||||||
appsv1.Deployment{},
|
appsv1.DaemonSet{},
|
||||||
}, nil); err != nil {
|
}, nil); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue