mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Update generated code
This commit is contained in:
parent
1d666d9515
commit
bd269f8d3e
@ -1,6 +1,7 @@
|
||||
// Code generated by go-bindata.
|
||||
// sources:
|
||||
// manifests/coredns.yaml
|
||||
// manifests/nginx-ingress.yaml
|
||||
// DO NOT EDIT!
|
||||
|
||||
package deploy
|
||||
@ -88,6 +89,26 @@ func corednsYaml() (*asset, error) {
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var _nginxIngressYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\xcc\x31\xae\xc2\x30\x0c\x87\xf1\x3d\xa7\xf0\x05\xda\xea\xe9\x6d\x5e\x59\x38\x01\xbb\x9b\xfe\x55\xac\x24\x6e\x14\x1b\x04\xb7\x47\x95\x58\x58\x3f\xe9\xf7\x49\xd7\x1b\x86\xeb\x61\x4c\xe5\xdf\xe7\x2c\x11\x15\xb3\x1e\xcb\xf3\x2f\x15\xb5\x8d\xe9\x8a\xda\x2e\x77\x19\x91\x1a\x42\x36\x09\xe1\x44\x64\xd2\xc0\x64\xbb\xda\x6b\x52\xdb\x07\xdc\xbf\xd5\xbb\x64\x30\x95\xc7\x8a\xc9\xdf\x1e\x68\xc9\x3b\xf2\x89\xf2\xb9\x61\xf2\x90\xb5\x62\xf9\xc5\x9f\x00\x00\x00\xff\xff\x2d\x6c\xb9\xb9\x8a\x00\x00\x00")
|
||||
|
||||
func nginxIngressYamlBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
_nginxIngressYaml,
|
||||
"nginx-ingress.yaml",
|
||||
)
|
||||
}
|
||||
|
||||
func nginxIngressYaml() (*asset, error) {
|
||||
bytes, err := nginxIngressYamlBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "nginx-ingress.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// Asset loads and returns the asset for the given name.
|
||||
// It returns an error if the asset could not be found or
|
||||
// could not be loaded.
|
||||
@ -141,6 +162,7 @@ func AssetNames() []string {
|
||||
// _bindata is a table, holding each asset generator, mapped to its name.
|
||||
var _bindata = map[string]func() (*asset, error){
|
||||
"coredns.yaml": corednsYaml,
|
||||
"nginx-ingress.yaml": nginxIngressYaml,
|
||||
}
|
||||
|
||||
// AssetDir returns the file names below a certain
|
||||
@ -185,6 +207,7 @@ type bintree struct {
|
||||
|
||||
var _bintree = &bintree{nil, map[string]*bintree{
|
||||
"coredns.yaml": &bintree{corednsYaml, map[string]*bintree{}},
|
||||
"nginx-ingress.yaml": &bintree{nginxIngressYaml, map[string]*bintree{}},
|
||||
}}
|
||||
|
||||
// RestoreAsset restores an asset under the given directory
|
||||
|
39
types/apis/batch/v1/zz_generated_deepcopy.go
Normal file
39
types/apis/batch/v1/zz_generated_deepcopy.go
Normal file
@ -0,0 +1,39 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
batchv1 "k8s.io/api/batch/v1"
|
||||
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 *JobList) DeepCopyInto(out *JobList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]batchv1.Job, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JobList.
|
||||
func (in *JobList) DeepCopy() *JobList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(JobList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *JobList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
441
types/apis/batch/v1/zz_generated_job_controller.go
Normal file
441
types/apis/batch/v1/zz_generated_job_controller.go
Normal file
@ -0,0 +1,441 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
v1 "k8s.io/api/batch/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 (
|
||||
JobGroupVersionKind = schema.GroupVersionKind{
|
||||
Version: Version,
|
||||
Group: GroupName,
|
||||
Kind: "Job",
|
||||
}
|
||||
JobResource = metav1.APIResource{
|
||||
Name: "jobs",
|
||||
SingularName: "job",
|
||||
Namespaced: true,
|
||||
|
||||
Kind: JobGroupVersionKind.Kind,
|
||||
}
|
||||
)
|
||||
|
||||
func NewJob(namespace, name string, obj v1.Job) *v1.Job {
|
||||
obj.APIVersion, obj.Kind = JobGroupVersionKind.ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
type JobList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []v1.Job
|
||||
}
|
||||
|
||||
type JobHandlerFunc func(key string, obj *v1.Job) (runtime.Object, error)
|
||||
|
||||
type JobChangeHandlerFunc func(obj *v1.Job) (runtime.Object, error)
|
||||
|
||||
type JobLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*v1.Job, err error)
|
||||
Get(namespace, name string) (*v1.Job, error)
|
||||
}
|
||||
|
||||
type JobController interface {
|
||||
Generic() controller.GenericController
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() JobLister
|
||||
AddHandler(ctx context.Context, name string, handler JobHandlerFunc)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler JobHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type JobInterface interface {
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Create(*v1.Job) (*v1.Job, error)
|
||||
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Job, error)
|
||||
Get(name string, opts metav1.GetOptions) (*v1.Job, error)
|
||||
Update(*v1.Job) (*v1.Job, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*JobList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() JobController
|
||||
AddHandler(ctx context.Context, name string, sync JobHandlerFunc)
|
||||
AddLifecycle(ctx context.Context, name string, lifecycle JobLifecycle)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync JobHandlerFunc)
|
||||
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle JobLifecycle)
|
||||
}
|
||||
|
||||
type jobLister struct {
|
||||
controller *jobController
|
||||
}
|
||||
|
||||
func (l *jobLister) List(namespace string, selector labels.Selector) (ret []*v1.Job, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*v1.Job))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *jobLister) Get(namespace, name string) (*v1.Job, 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: JobGroupVersionKind.Group,
|
||||
Resource: "job",
|
||||
}, key)
|
||||
}
|
||||
return obj.(*v1.Job), nil
|
||||
}
|
||||
|
||||
type jobController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *jobController) Generic() controller.GenericController {
|
||||
return c.GenericController
|
||||
}
|
||||
|
||||
func (c *jobController) Lister() JobLister {
|
||||
return &jobLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *jobController) AddHandler(ctx context.Context, name string, handler JobHandlerFunc) {
|
||||
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.Job); ok {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (c *jobController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler JobHandlerFunc) {
|
||||
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.Job); ok && controller.ObjectInCluster(cluster, obj) {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type jobFactory struct {
|
||||
}
|
||||
|
||||
func (c jobFactory) Object() runtime.Object {
|
||||
return &v1.Job{}
|
||||
}
|
||||
|
||||
func (c jobFactory) List() runtime.Object {
|
||||
return &JobList{}
|
||||
}
|
||||
|
||||
func (s *jobClient) Controller() JobController {
|
||||
s.client.Lock()
|
||||
defer s.client.Unlock()
|
||||
|
||||
c, ok := s.client.jobControllers[s.ns]
|
||||
if ok {
|
||||
return c
|
||||
}
|
||||
|
||||
genericController := controller.NewGenericController(JobGroupVersionKind.Kind+"Controller",
|
||||
s.objectClient)
|
||||
|
||||
c = &jobController{
|
||||
GenericController: genericController,
|
||||
}
|
||||
|
||||
s.client.jobControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type jobClient struct {
|
||||
client *Client
|
||||
ns string
|
||||
objectClient *objectclient.ObjectClient
|
||||
controller JobController
|
||||
}
|
||||
|
||||
func (s *jobClient) ObjectClient() *objectclient.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *jobClient) Create(o *v1.Job) (*v1.Job, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*v1.Job), err
|
||||
}
|
||||
|
||||
func (s *jobClient) Get(name string, opts metav1.GetOptions) (*v1.Job, error) {
|
||||
obj, err := s.objectClient.Get(name, opts)
|
||||
return obj.(*v1.Job), err
|
||||
}
|
||||
|
||||
func (s *jobClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.Job, error) {
|
||||
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
|
||||
return obj.(*v1.Job), err
|
||||
}
|
||||
|
||||
func (s *jobClient) Update(o *v1.Job) (*v1.Job, error) {
|
||||
obj, err := s.objectClient.Update(o.Name, o)
|
||||
return obj.(*v1.Job), err
|
||||
}
|
||||
|
||||
func (s *jobClient) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.Delete(name, options)
|
||||
}
|
||||
|
||||
func (s *jobClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (s *jobClient) List(opts metav1.ListOptions) (*JobList, error) {
|
||||
obj, err := s.objectClient.List(opts)
|
||||
return obj.(*JobList), err
|
||||
}
|
||||
|
||||
func (s *jobClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return s.objectClient.Watch(opts)
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched deployment.
|
||||
func (s *jobClient) Patch(o *v1.Job, patchType types.PatchType, data []byte, subresources ...string) (*v1.Job, error) {
|
||||
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
|
||||
return obj.(*v1.Job), err
|
||||
}
|
||||
|
||||
func (s *jobClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
||||
}
|
||||
|
||||
func (s *jobClient) AddHandler(ctx context.Context, name string, sync JobHandlerFunc) {
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *jobClient) AddLifecycle(ctx context.Context, name string, lifecycle JobLifecycle) {
|
||||
sync := NewJobLifecycleAdapter(name, false, s, lifecycle)
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *jobClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync JobHandlerFunc) {
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
func (s *jobClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle JobLifecycle) {
|
||||
sync := NewJobLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
type JobIndexer func(obj *v1.Job) ([]string, error)
|
||||
|
||||
type JobClientCache interface {
|
||||
Get(namespace, name string) (*v1.Job, error)
|
||||
List(namespace string, selector labels.Selector) ([]*v1.Job, error)
|
||||
|
||||
Index(name string, indexer JobIndexer)
|
||||
GetIndexed(name, key string) ([]*v1.Job, error)
|
||||
}
|
||||
|
||||
type JobClient interface {
|
||||
Create(*v1.Job) (*v1.Job, error)
|
||||
Get(namespace, name string, opts metav1.GetOptions) (*v1.Job, error)
|
||||
Update(*v1.Job) (*v1.Job, error)
|
||||
Delete(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(namespace string, opts metav1.ListOptions) (*JobList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
|
||||
Cache() JobClientCache
|
||||
|
||||
OnCreate(ctx context.Context, name string, sync JobChangeHandlerFunc)
|
||||
OnChange(ctx context.Context, name string, sync JobChangeHandlerFunc)
|
||||
OnRemove(ctx context.Context, name string, sync JobChangeHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
|
||||
Generic() controller.GenericController
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Interface() JobInterface
|
||||
}
|
||||
|
||||
type jobClientCache struct {
|
||||
client *jobClient2
|
||||
}
|
||||
|
||||
type jobClient2 struct {
|
||||
iface JobInterface
|
||||
controller JobController
|
||||
}
|
||||
|
||||
func (n *jobClient2) Interface() JobInterface {
|
||||
return n.iface
|
||||
}
|
||||
|
||||
func (n *jobClient2) Generic() controller.GenericController {
|
||||
return n.iface.Controller().Generic()
|
||||
}
|
||||
|
||||
func (n *jobClient2) ObjectClient() *objectclient.ObjectClient {
|
||||
return n.Interface().ObjectClient()
|
||||
}
|
||||
|
||||
func (n *jobClient2) Enqueue(namespace, name string) {
|
||||
n.iface.Controller().Enqueue(namespace, name)
|
||||
}
|
||||
|
||||
func (n *jobClient2) Create(obj *v1.Job) (*v1.Job, error) {
|
||||
return n.iface.Create(obj)
|
||||
}
|
||||
|
||||
func (n *jobClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.Job, error) {
|
||||
return n.iface.GetNamespaced(namespace, name, opts)
|
||||
}
|
||||
|
||||
func (n *jobClient2) Update(obj *v1.Job) (*v1.Job, error) {
|
||||
return n.iface.Update(obj)
|
||||
}
|
||||
|
||||
func (n *jobClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return n.iface.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (n *jobClient2) List(namespace string, opts metav1.ListOptions) (*JobList, error) {
|
||||
return n.iface.List(opts)
|
||||
}
|
||||
|
||||
func (n *jobClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return n.iface.Watch(opts)
|
||||
}
|
||||
|
||||
func (n *jobClientCache) Get(namespace, name string) (*v1.Job, error) {
|
||||
return n.client.controller.Lister().Get(namespace, name)
|
||||
}
|
||||
|
||||
func (n *jobClientCache) List(namespace string, selector labels.Selector) ([]*v1.Job, error) {
|
||||
return n.client.controller.Lister().List(namespace, selector)
|
||||
}
|
||||
|
||||
func (n *jobClient2) Cache() JobClientCache {
|
||||
n.loadController()
|
||||
return &jobClientCache{
|
||||
client: n,
|
||||
}
|
||||
}
|
||||
|
||||
func (n *jobClient2) OnCreate(ctx context.Context, name string, sync JobChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-create", &jobLifecycleDelegate{create: sync})
|
||||
}
|
||||
|
||||
func (n *jobClient2) OnChange(ctx context.Context, name string, sync JobChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-change", &jobLifecycleDelegate{update: sync})
|
||||
}
|
||||
|
||||
func (n *jobClient2) OnRemove(ctx context.Context, name string, sync JobChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name, &jobLifecycleDelegate{remove: sync})
|
||||
}
|
||||
|
||||
func (n *jobClientCache) Index(name string, indexer JobIndexer) {
|
||||
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
|
||||
name: func(obj interface{}) ([]string, error) {
|
||||
if v, ok := obj.(*v1.Job); ok {
|
||||
return indexer(v)
|
||||
}
|
||||
return nil, nil
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *jobClientCache) GetIndexed(name, key string) ([]*v1.Job, error) {
|
||||
var result []*v1.Job
|
||||
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.Job); ok {
|
||||
result = append(result, v)
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (n *jobClient2) loadController() {
|
||||
if n.controller == nil {
|
||||
n.controller = n.iface.Controller()
|
||||
}
|
||||
}
|
||||
|
||||
type jobLifecycleDelegate struct {
|
||||
create JobChangeHandlerFunc
|
||||
update JobChangeHandlerFunc
|
||||
remove JobChangeHandlerFunc
|
||||
}
|
||||
|
||||
func (n *jobLifecycleDelegate) HasCreate() bool {
|
||||
return n.create != nil
|
||||
}
|
||||
|
||||
func (n *jobLifecycleDelegate) Create(obj *v1.Job) (runtime.Object, error) {
|
||||
if n.create == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.create(obj)
|
||||
}
|
||||
|
||||
func (n *jobLifecycleDelegate) HasFinalize() bool {
|
||||
return n.remove != nil
|
||||
}
|
||||
|
||||
func (n *jobLifecycleDelegate) Remove(obj *v1.Job) (runtime.Object, error) {
|
||||
if n.remove == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.remove(obj)
|
||||
}
|
||||
|
||||
func (n *jobLifecycleDelegate) Updated(obj *v1.Job) (runtime.Object, error) {
|
||||
if n.update == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.update(obj)
|
||||
}
|
63
types/apis/batch/v1/zz_generated_job_lifecycle_adapter.go
Normal file
63
types/apis/batch/v1/zz_generated_job_lifecycle_adapter.go
Normal file
@ -0,0 +1,63 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
v1 "k8s.io/api/batch/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type JobLifecycle interface {
|
||||
Create(obj *v1.Job) (runtime.Object, error)
|
||||
Remove(obj *v1.Job) (runtime.Object, error)
|
||||
Updated(obj *v1.Job) (runtime.Object, error)
|
||||
}
|
||||
|
||||
type jobLifecycleAdapter struct {
|
||||
lifecycle JobLifecycle
|
||||
}
|
||||
|
||||
func (w *jobLifecycleAdapter) HasCreate() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasCreate()
|
||||
}
|
||||
|
||||
func (w *jobLifecycleAdapter) HasFinalize() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasFinalize()
|
||||
}
|
||||
|
||||
func (w *jobLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Create(obj.(*v1.Job))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *jobLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Remove(obj.(*v1.Job))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *jobLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Updated(obj.(*v1.Job))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func NewJobLifecycleAdapter(name string, clusterScoped bool, client JobInterface, l JobLifecycle) JobHandlerFunc {
|
||||
adapter := &jobLifecycleAdapter{lifecycle: l}
|
||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
|
||||
return func(key string, obj *v1.Job) (runtime.Object, error) {
|
||||
newObj, err := syncFn(key, obj)
|
||||
if o, ok := newObj.(runtime.Object); ok {
|
||||
return o, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
}
|
119
types/apis/batch/v1/zz_generated_k8s_client.go
Normal file
119
types/apis/batch/v1/zz_generated_k8s_client.go
Normal file
@ -0,0 +1,119 @@
|
||||
package v1
|
||||
|
||||
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
|
||||
|
||||
JobsGetter
|
||||
}
|
||||
|
||||
type Clients struct {
|
||||
Interface Interface
|
||||
|
||||
Job JobClient
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
sync.Mutex
|
||||
restClient rest.Interface
|
||||
starters []controller.Starter
|
||||
|
||||
jobControllers map[string]JobController
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
Job: &jobClient2{
|
||||
iface: iface.Jobs(""),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
jobControllers: map[string]JobController{},
|
||||
}, 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 JobsGetter interface {
|
||||
Jobs(namespace string) JobInterface
|
||||
}
|
||||
|
||||
func (c *Client) Jobs(namespace string) JobInterface {
|
||||
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &JobResource, JobGroupVersionKind, jobFactory{})
|
||||
return &jobClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
39
types/apis/batch/v1/zz_generated_scheme.go
Normal file
39
types/apis/batch/v1/zz_generated_scheme.go
Normal file
@ -0,0 +1,39 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
GroupName = "batch"
|
||||
Version = "v1"
|
||||
)
|
||||
|
||||
// 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,
|
||||
|
||||
&JobList{},
|
||||
)
|
||||
return nil
|
||||
}
|
441
types/apis/core/v1/zz_generated_config_map_controller.go
Normal file
441
types/apis/core/v1/zz_generated_config_map_controller.go
Normal file
@ -0,0 +1,441 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
v1 "k8s.io/api/core/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 (
|
||||
ConfigMapGroupVersionKind = schema.GroupVersionKind{
|
||||
Version: Version,
|
||||
Group: GroupName,
|
||||
Kind: "ConfigMap",
|
||||
}
|
||||
ConfigMapResource = metav1.APIResource{
|
||||
Name: "configmaps",
|
||||
SingularName: "configmap",
|
||||
Namespaced: true,
|
||||
|
||||
Kind: ConfigMapGroupVersionKind.Kind,
|
||||
}
|
||||
)
|
||||
|
||||
func NewConfigMap(namespace, name string, obj v1.ConfigMap) *v1.ConfigMap {
|
||||
obj.APIVersion, obj.Kind = ConfigMapGroupVersionKind.ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
type ConfigMapList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []v1.ConfigMap
|
||||
}
|
||||
|
||||
type ConfigMapHandlerFunc func(key string, obj *v1.ConfigMap) (runtime.Object, error)
|
||||
|
||||
type ConfigMapChangeHandlerFunc func(obj *v1.ConfigMap) (runtime.Object, error)
|
||||
|
||||
type ConfigMapLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*v1.ConfigMap, err error)
|
||||
Get(namespace, name string) (*v1.ConfigMap, error)
|
||||
}
|
||||
|
||||
type ConfigMapController interface {
|
||||
Generic() controller.GenericController
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() ConfigMapLister
|
||||
AddHandler(ctx context.Context, name string, handler ConfigMapHandlerFunc)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler ConfigMapHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type ConfigMapInterface interface {
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Create(*v1.ConfigMap) (*v1.ConfigMap, error)
|
||||
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ConfigMap, error)
|
||||
Get(name string, opts metav1.GetOptions) (*v1.ConfigMap, error)
|
||||
Update(*v1.ConfigMap) (*v1.ConfigMap, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*ConfigMapList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() ConfigMapController
|
||||
AddHandler(ctx context.Context, name string, sync ConfigMapHandlerFunc)
|
||||
AddLifecycle(ctx context.Context, name string, lifecycle ConfigMapLifecycle)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ConfigMapHandlerFunc)
|
||||
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ConfigMapLifecycle)
|
||||
}
|
||||
|
||||
type configMapLister struct {
|
||||
controller *configMapController
|
||||
}
|
||||
|
||||
func (l *configMapLister) List(namespace string, selector labels.Selector) (ret []*v1.ConfigMap, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*v1.ConfigMap))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *configMapLister) Get(namespace, name string) (*v1.ConfigMap, 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: ConfigMapGroupVersionKind.Group,
|
||||
Resource: "configMap",
|
||||
}, key)
|
||||
}
|
||||
return obj.(*v1.ConfigMap), nil
|
||||
}
|
||||
|
||||
type configMapController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *configMapController) Generic() controller.GenericController {
|
||||
return c.GenericController
|
||||
}
|
||||
|
||||
func (c *configMapController) Lister() ConfigMapLister {
|
||||
return &configMapLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *configMapController) AddHandler(ctx context.Context, name string, handler ConfigMapHandlerFunc) {
|
||||
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.ConfigMap); ok {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (c *configMapController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler ConfigMapHandlerFunc) {
|
||||
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.ConfigMap); ok && controller.ObjectInCluster(cluster, obj) {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type configMapFactory struct {
|
||||
}
|
||||
|
||||
func (c configMapFactory) Object() runtime.Object {
|
||||
return &v1.ConfigMap{}
|
||||
}
|
||||
|
||||
func (c configMapFactory) List() runtime.Object {
|
||||
return &ConfigMapList{}
|
||||
}
|
||||
|
||||
func (s *configMapClient) Controller() ConfigMapController {
|
||||
s.client.Lock()
|
||||
defer s.client.Unlock()
|
||||
|
||||
c, ok := s.client.configMapControllers[s.ns]
|
||||
if ok {
|
||||
return c
|
||||
}
|
||||
|
||||
genericController := controller.NewGenericController(ConfigMapGroupVersionKind.Kind+"Controller",
|
||||
s.objectClient)
|
||||
|
||||
c = &configMapController{
|
||||
GenericController: genericController,
|
||||
}
|
||||
|
||||
s.client.configMapControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type configMapClient struct {
|
||||
client *Client
|
||||
ns string
|
||||
objectClient *objectclient.ObjectClient
|
||||
controller ConfigMapController
|
||||
}
|
||||
|
||||
func (s *configMapClient) ObjectClient() *objectclient.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *configMapClient) Create(o *v1.ConfigMap) (*v1.ConfigMap, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*v1.ConfigMap), err
|
||||
}
|
||||
|
||||
func (s *configMapClient) Get(name string, opts metav1.GetOptions) (*v1.ConfigMap, error) {
|
||||
obj, err := s.objectClient.Get(name, opts)
|
||||
return obj.(*v1.ConfigMap), err
|
||||
}
|
||||
|
||||
func (s *configMapClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ConfigMap, error) {
|
||||
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
|
||||
return obj.(*v1.ConfigMap), err
|
||||
}
|
||||
|
||||
func (s *configMapClient) Update(o *v1.ConfigMap) (*v1.ConfigMap, error) {
|
||||
obj, err := s.objectClient.Update(o.Name, o)
|
||||
return obj.(*v1.ConfigMap), err
|
||||
}
|
||||
|
||||
func (s *configMapClient) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.Delete(name, options)
|
||||
}
|
||||
|
||||
func (s *configMapClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (s *configMapClient) List(opts metav1.ListOptions) (*ConfigMapList, error) {
|
||||
obj, err := s.objectClient.List(opts)
|
||||
return obj.(*ConfigMapList), err
|
||||
}
|
||||
|
||||
func (s *configMapClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return s.objectClient.Watch(opts)
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched deployment.
|
||||
func (s *configMapClient) Patch(o *v1.ConfigMap, patchType types.PatchType, data []byte, subresources ...string) (*v1.ConfigMap, error) {
|
||||
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
|
||||
return obj.(*v1.ConfigMap), err
|
||||
}
|
||||
|
||||
func (s *configMapClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
||||
}
|
||||
|
||||
func (s *configMapClient) AddHandler(ctx context.Context, name string, sync ConfigMapHandlerFunc) {
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *configMapClient) AddLifecycle(ctx context.Context, name string, lifecycle ConfigMapLifecycle) {
|
||||
sync := NewConfigMapLifecycleAdapter(name, false, s, lifecycle)
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *configMapClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ConfigMapHandlerFunc) {
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
func (s *configMapClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ConfigMapLifecycle) {
|
||||
sync := NewConfigMapLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
type ConfigMapIndexer func(obj *v1.ConfigMap) ([]string, error)
|
||||
|
||||
type ConfigMapClientCache interface {
|
||||
Get(namespace, name string) (*v1.ConfigMap, error)
|
||||
List(namespace string, selector labels.Selector) ([]*v1.ConfigMap, error)
|
||||
|
||||
Index(name string, indexer ConfigMapIndexer)
|
||||
GetIndexed(name, key string) ([]*v1.ConfigMap, error)
|
||||
}
|
||||
|
||||
type ConfigMapClient interface {
|
||||
Create(*v1.ConfigMap) (*v1.ConfigMap, error)
|
||||
Get(namespace, name string, opts metav1.GetOptions) (*v1.ConfigMap, error)
|
||||
Update(*v1.ConfigMap) (*v1.ConfigMap, error)
|
||||
Delete(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(namespace string, opts metav1.ListOptions) (*ConfigMapList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
|
||||
Cache() ConfigMapClientCache
|
||||
|
||||
OnCreate(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc)
|
||||
OnChange(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc)
|
||||
OnRemove(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
|
||||
Generic() controller.GenericController
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Interface() ConfigMapInterface
|
||||
}
|
||||
|
||||
type configMapClientCache struct {
|
||||
client *configMapClient2
|
||||
}
|
||||
|
||||
type configMapClient2 struct {
|
||||
iface ConfigMapInterface
|
||||
controller ConfigMapController
|
||||
}
|
||||
|
||||
func (n *configMapClient2) Interface() ConfigMapInterface {
|
||||
return n.iface
|
||||
}
|
||||
|
||||
func (n *configMapClient2) Generic() controller.GenericController {
|
||||
return n.iface.Controller().Generic()
|
||||
}
|
||||
|
||||
func (n *configMapClient2) ObjectClient() *objectclient.ObjectClient {
|
||||
return n.Interface().ObjectClient()
|
||||
}
|
||||
|
||||
func (n *configMapClient2) Enqueue(namespace, name string) {
|
||||
n.iface.Controller().Enqueue(namespace, name)
|
||||
}
|
||||
|
||||
func (n *configMapClient2) Create(obj *v1.ConfigMap) (*v1.ConfigMap, error) {
|
||||
return n.iface.Create(obj)
|
||||
}
|
||||
|
||||
func (n *configMapClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.ConfigMap, error) {
|
||||
return n.iface.GetNamespaced(namespace, name, opts)
|
||||
}
|
||||
|
||||
func (n *configMapClient2) Update(obj *v1.ConfigMap) (*v1.ConfigMap, error) {
|
||||
return n.iface.Update(obj)
|
||||
}
|
||||
|
||||
func (n *configMapClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return n.iface.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (n *configMapClient2) List(namespace string, opts metav1.ListOptions) (*ConfigMapList, error) {
|
||||
return n.iface.List(opts)
|
||||
}
|
||||
|
||||
func (n *configMapClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return n.iface.Watch(opts)
|
||||
}
|
||||
|
||||
func (n *configMapClientCache) Get(namespace, name string) (*v1.ConfigMap, error) {
|
||||
return n.client.controller.Lister().Get(namespace, name)
|
||||
}
|
||||
|
||||
func (n *configMapClientCache) List(namespace string, selector labels.Selector) ([]*v1.ConfigMap, error) {
|
||||
return n.client.controller.Lister().List(namespace, selector)
|
||||
}
|
||||
|
||||
func (n *configMapClient2) Cache() ConfigMapClientCache {
|
||||
n.loadController()
|
||||
return &configMapClientCache{
|
||||
client: n,
|
||||
}
|
||||
}
|
||||
|
||||
func (n *configMapClient2) OnCreate(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-create", &configMapLifecycleDelegate{create: sync})
|
||||
}
|
||||
|
||||
func (n *configMapClient2) OnChange(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-change", &configMapLifecycleDelegate{update: sync})
|
||||
}
|
||||
|
||||
func (n *configMapClient2) OnRemove(ctx context.Context, name string, sync ConfigMapChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name, &configMapLifecycleDelegate{remove: sync})
|
||||
}
|
||||
|
||||
func (n *configMapClientCache) Index(name string, indexer ConfigMapIndexer) {
|
||||
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
|
||||
name: func(obj interface{}) ([]string, error) {
|
||||
if v, ok := obj.(*v1.ConfigMap); ok {
|
||||
return indexer(v)
|
||||
}
|
||||
return nil, nil
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *configMapClientCache) GetIndexed(name, key string) ([]*v1.ConfigMap, error) {
|
||||
var result []*v1.ConfigMap
|
||||
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.ConfigMap); ok {
|
||||
result = append(result, v)
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (n *configMapClient2) loadController() {
|
||||
if n.controller == nil {
|
||||
n.controller = n.iface.Controller()
|
||||
}
|
||||
}
|
||||
|
||||
type configMapLifecycleDelegate struct {
|
||||
create ConfigMapChangeHandlerFunc
|
||||
update ConfigMapChangeHandlerFunc
|
||||
remove ConfigMapChangeHandlerFunc
|
||||
}
|
||||
|
||||
func (n *configMapLifecycleDelegate) HasCreate() bool {
|
||||
return n.create != nil
|
||||
}
|
||||
|
||||
func (n *configMapLifecycleDelegate) Create(obj *v1.ConfigMap) (runtime.Object, error) {
|
||||
if n.create == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.create(obj)
|
||||
}
|
||||
|
||||
func (n *configMapLifecycleDelegate) HasFinalize() bool {
|
||||
return n.remove != nil
|
||||
}
|
||||
|
||||
func (n *configMapLifecycleDelegate) Remove(obj *v1.ConfigMap) (runtime.Object, error) {
|
||||
if n.remove == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.remove(obj)
|
||||
}
|
||||
|
||||
func (n *configMapLifecycleDelegate) Updated(obj *v1.ConfigMap) (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/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type ConfigMapLifecycle interface {
|
||||
Create(obj *v1.ConfigMap) (runtime.Object, error)
|
||||
Remove(obj *v1.ConfigMap) (runtime.Object, error)
|
||||
Updated(obj *v1.ConfigMap) (runtime.Object, error)
|
||||
}
|
||||
|
||||
type configMapLifecycleAdapter struct {
|
||||
lifecycle ConfigMapLifecycle
|
||||
}
|
||||
|
||||
func (w *configMapLifecycleAdapter) HasCreate() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasCreate()
|
||||
}
|
||||
|
||||
func (w *configMapLifecycleAdapter) HasFinalize() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasFinalize()
|
||||
}
|
||||
|
||||
func (w *configMapLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Create(obj.(*v1.ConfigMap))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *configMapLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Remove(obj.(*v1.ConfigMap))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *configMapLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Updated(obj.(*v1.ConfigMap))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func NewConfigMapLifecycleAdapter(name string, clusterScoped bool, client ConfigMapInterface, l ConfigMapLifecycle) ConfigMapHandlerFunc {
|
||||
adapter := &configMapLifecycleAdapter{lifecycle: l}
|
||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
|
||||
return func(key string, obj *v1.ConfigMap) (runtime.Object, error) {
|
||||
newObj, err := syncFn(key, obj)
|
||||
if o, ok := newObj.(runtime.Object); ok {
|
||||
return o, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
}
|
@ -5,6 +5,39 @@ import (
|
||||
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 *ConfigMapList) DeepCopyInto(out *ConfigMapList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]corev1.ConfigMap, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigMapList.
|
||||
func (in *ConfigMapList) DeepCopy() *ConfigMapList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ConfigMapList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ConfigMapList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NodeList) DeepCopyInto(out *NodeList) {
|
||||
*out = *in
|
||||
@ -71,6 +104,39 @@ func (in *PodList) DeepCopyObject() runtime.Object {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ServiceAccountList) DeepCopyInto(out *ServiceAccountList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]corev1.ServiceAccount, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceAccountList.
|
||||
func (in *ServiceAccountList) DeepCopy() *ServiceAccountList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ServiceAccountList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ServiceAccountList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ServiceList) DeepCopyInto(out *ServiceList) {
|
||||
*out = *in
|
||||
|
@ -21,16 +21,20 @@ type Interface interface {
|
||||
controller.Starter
|
||||
|
||||
NodesGetter
|
||||
ServiceAccountsGetter
|
||||
ServicesGetter
|
||||
PodsGetter
|
||||
ConfigMapsGetter
|
||||
}
|
||||
|
||||
type Clients struct {
|
||||
Interface Interface
|
||||
|
||||
Node NodeClient
|
||||
ServiceAccount ServiceAccountClient
|
||||
Service ServiceClient
|
||||
Pod PodClient
|
||||
ConfigMap ConfigMapClient
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
@ -39,8 +43,10 @@ type Client struct {
|
||||
starters []controller.Starter
|
||||
|
||||
nodeControllers map[string]NodeController
|
||||
serviceAccountControllers map[string]ServiceAccountController
|
||||
serviceControllers map[string]ServiceController
|
||||
podControllers map[string]PodController
|
||||
configMapControllers map[string]ConfigMapController
|
||||
}
|
||||
|
||||
func Factory(ctx context.Context, config rest.Config) (context.Context, controller.Starter, error) {
|
||||
@ -79,12 +85,18 @@ func NewClientsFromInterface(iface Interface) *Clients {
|
||||
Node: &nodeClient2{
|
||||
iface: iface.Nodes(""),
|
||||
},
|
||||
ServiceAccount: &serviceAccountClient2{
|
||||
iface: iface.ServiceAccounts(""),
|
||||
},
|
||||
Service: &serviceClient2{
|
||||
iface: iface.Services(""),
|
||||
},
|
||||
Pod: &podClient2{
|
||||
iface: iface.Pods(""),
|
||||
},
|
||||
ConfigMap: &configMapClient2{
|
||||
iface: iface.ConfigMaps(""),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,8 +114,10 @@ func NewForConfig(config rest.Config) (Interface, error) {
|
||||
restClient: restClient,
|
||||
|
||||
nodeControllers: map[string]NodeController{},
|
||||
serviceAccountControllers: map[string]ServiceAccountController{},
|
||||
serviceControllers: map[string]ServiceController{},
|
||||
podControllers: map[string]PodController{},
|
||||
configMapControllers: map[string]ConfigMapController{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -132,6 +146,19 @@ func (c *Client) Nodes(namespace string) NodeInterface {
|
||||
}
|
||||
}
|
||||
|
||||
type ServiceAccountsGetter interface {
|
||||
ServiceAccounts(namespace string) ServiceAccountInterface
|
||||
}
|
||||
|
||||
func (c *Client) ServiceAccounts(namespace string) ServiceAccountInterface {
|
||||
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &ServiceAccountResource, ServiceAccountGroupVersionKind, serviceAccountFactory{})
|
||||
return &serviceAccountClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
||||
|
||||
type ServicesGetter interface {
|
||||
Services(namespace string) ServiceInterface
|
||||
}
|
||||
@ -157,3 +184,16 @@ func (c *Client) Pods(namespace string) PodInterface {
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
||||
|
||||
type ConfigMapsGetter interface {
|
||||
ConfigMaps(namespace string) ConfigMapInterface
|
||||
}
|
||||
|
||||
func (c *Client) ConfigMaps(namespace string) ConfigMapInterface {
|
||||
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &ConfigMapResource, ConfigMapGroupVersionKind, configMapFactory{})
|
||||
return &configMapClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,10 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
|
||||
&NodeList{},
|
||||
&ServiceAccountList{},
|
||||
&ServiceList{},
|
||||
&PodList{},
|
||||
&ConfigMapList{},
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
441
types/apis/core/v1/zz_generated_service_account_controller.go
Normal file
441
types/apis/core/v1/zz_generated_service_account_controller.go
Normal file
@ -0,0 +1,441 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
v1 "k8s.io/api/core/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 (
|
||||
ServiceAccountGroupVersionKind = schema.GroupVersionKind{
|
||||
Version: Version,
|
||||
Group: GroupName,
|
||||
Kind: "ServiceAccount",
|
||||
}
|
||||
ServiceAccountResource = metav1.APIResource{
|
||||
Name: "serviceaccounts",
|
||||
SingularName: "serviceaccount",
|
||||
Namespaced: true,
|
||||
|
||||
Kind: ServiceAccountGroupVersionKind.Kind,
|
||||
}
|
||||
)
|
||||
|
||||
func NewServiceAccount(namespace, name string, obj v1.ServiceAccount) *v1.ServiceAccount {
|
||||
obj.APIVersion, obj.Kind = ServiceAccountGroupVersionKind.ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
type ServiceAccountList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []v1.ServiceAccount
|
||||
}
|
||||
|
||||
type ServiceAccountHandlerFunc func(key string, obj *v1.ServiceAccount) (runtime.Object, error)
|
||||
|
||||
type ServiceAccountChangeHandlerFunc func(obj *v1.ServiceAccount) (runtime.Object, error)
|
||||
|
||||
type ServiceAccountLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*v1.ServiceAccount, err error)
|
||||
Get(namespace, name string) (*v1.ServiceAccount, error)
|
||||
}
|
||||
|
||||
type ServiceAccountController interface {
|
||||
Generic() controller.GenericController
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() ServiceAccountLister
|
||||
AddHandler(ctx context.Context, name string, handler ServiceAccountHandlerFunc)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler ServiceAccountHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type ServiceAccountInterface interface {
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Create(*v1.ServiceAccount) (*v1.ServiceAccount, error)
|
||||
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ServiceAccount, error)
|
||||
Get(name string, opts metav1.GetOptions) (*v1.ServiceAccount, error)
|
||||
Update(*v1.ServiceAccount) (*v1.ServiceAccount, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*ServiceAccountList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() ServiceAccountController
|
||||
AddHandler(ctx context.Context, name string, sync ServiceAccountHandlerFunc)
|
||||
AddLifecycle(ctx context.Context, name string, lifecycle ServiceAccountLifecycle)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ServiceAccountHandlerFunc)
|
||||
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ServiceAccountLifecycle)
|
||||
}
|
||||
|
||||
type serviceAccountLister struct {
|
||||
controller *serviceAccountController
|
||||
}
|
||||
|
||||
func (l *serviceAccountLister) List(namespace string, selector labels.Selector) (ret []*v1.ServiceAccount, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*v1.ServiceAccount))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *serviceAccountLister) Get(namespace, name string) (*v1.ServiceAccount, 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: ServiceAccountGroupVersionKind.Group,
|
||||
Resource: "serviceAccount",
|
||||
}, key)
|
||||
}
|
||||
return obj.(*v1.ServiceAccount), nil
|
||||
}
|
||||
|
||||
type serviceAccountController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *serviceAccountController) Generic() controller.GenericController {
|
||||
return c.GenericController
|
||||
}
|
||||
|
||||
func (c *serviceAccountController) Lister() ServiceAccountLister {
|
||||
return &serviceAccountLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *serviceAccountController) AddHandler(ctx context.Context, name string, handler ServiceAccountHandlerFunc) {
|
||||
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.ServiceAccount); ok {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (c *serviceAccountController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler ServiceAccountHandlerFunc) {
|
||||
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.ServiceAccount); ok && controller.ObjectInCluster(cluster, obj) {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type serviceAccountFactory struct {
|
||||
}
|
||||
|
||||
func (c serviceAccountFactory) Object() runtime.Object {
|
||||
return &v1.ServiceAccount{}
|
||||
}
|
||||
|
||||
func (c serviceAccountFactory) List() runtime.Object {
|
||||
return &ServiceAccountList{}
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) Controller() ServiceAccountController {
|
||||
s.client.Lock()
|
||||
defer s.client.Unlock()
|
||||
|
||||
c, ok := s.client.serviceAccountControllers[s.ns]
|
||||
if ok {
|
||||
return c
|
||||
}
|
||||
|
||||
genericController := controller.NewGenericController(ServiceAccountGroupVersionKind.Kind+"Controller",
|
||||
s.objectClient)
|
||||
|
||||
c = &serviceAccountController{
|
||||
GenericController: genericController,
|
||||
}
|
||||
|
||||
s.client.serviceAccountControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type serviceAccountClient struct {
|
||||
client *Client
|
||||
ns string
|
||||
objectClient *objectclient.ObjectClient
|
||||
controller ServiceAccountController
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) ObjectClient() *objectclient.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) Create(o *v1.ServiceAccount) (*v1.ServiceAccount, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*v1.ServiceAccount), err
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) Get(name string, opts metav1.GetOptions) (*v1.ServiceAccount, error) {
|
||||
obj, err := s.objectClient.Get(name, opts)
|
||||
return obj.(*v1.ServiceAccount), err
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ServiceAccount, error) {
|
||||
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
|
||||
return obj.(*v1.ServiceAccount), err
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) Update(o *v1.ServiceAccount) (*v1.ServiceAccount, error) {
|
||||
obj, err := s.objectClient.Update(o.Name, o)
|
||||
return obj.(*v1.ServiceAccount), err
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.Delete(name, options)
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) List(opts metav1.ListOptions) (*ServiceAccountList, error) {
|
||||
obj, err := s.objectClient.List(opts)
|
||||
return obj.(*ServiceAccountList), err
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return s.objectClient.Watch(opts)
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched deployment.
|
||||
func (s *serviceAccountClient) Patch(o *v1.ServiceAccount, patchType types.PatchType, data []byte, subresources ...string) (*v1.ServiceAccount, error) {
|
||||
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
|
||||
return obj.(*v1.ServiceAccount), err
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) AddHandler(ctx context.Context, name string, sync ServiceAccountHandlerFunc) {
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) AddLifecycle(ctx context.Context, name string, lifecycle ServiceAccountLifecycle) {
|
||||
sync := NewServiceAccountLifecycleAdapter(name, false, s, lifecycle)
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ServiceAccountHandlerFunc) {
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
func (s *serviceAccountClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ServiceAccountLifecycle) {
|
||||
sync := NewServiceAccountLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
type ServiceAccountIndexer func(obj *v1.ServiceAccount) ([]string, error)
|
||||
|
||||
type ServiceAccountClientCache interface {
|
||||
Get(namespace, name string) (*v1.ServiceAccount, error)
|
||||
List(namespace string, selector labels.Selector) ([]*v1.ServiceAccount, error)
|
||||
|
||||
Index(name string, indexer ServiceAccountIndexer)
|
||||
GetIndexed(name, key string) ([]*v1.ServiceAccount, error)
|
||||
}
|
||||
|
||||
type ServiceAccountClient interface {
|
||||
Create(*v1.ServiceAccount) (*v1.ServiceAccount, error)
|
||||
Get(namespace, name string, opts metav1.GetOptions) (*v1.ServiceAccount, error)
|
||||
Update(*v1.ServiceAccount) (*v1.ServiceAccount, error)
|
||||
Delete(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(namespace string, opts metav1.ListOptions) (*ServiceAccountList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
|
||||
Cache() ServiceAccountClientCache
|
||||
|
||||
OnCreate(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc)
|
||||
OnChange(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc)
|
||||
OnRemove(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
|
||||
Generic() controller.GenericController
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Interface() ServiceAccountInterface
|
||||
}
|
||||
|
||||
type serviceAccountClientCache struct {
|
||||
client *serviceAccountClient2
|
||||
}
|
||||
|
||||
type serviceAccountClient2 struct {
|
||||
iface ServiceAccountInterface
|
||||
controller ServiceAccountController
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) Interface() ServiceAccountInterface {
|
||||
return n.iface
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) Generic() controller.GenericController {
|
||||
return n.iface.Controller().Generic()
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) ObjectClient() *objectclient.ObjectClient {
|
||||
return n.Interface().ObjectClient()
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) Enqueue(namespace, name string) {
|
||||
n.iface.Controller().Enqueue(namespace, name)
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) Create(obj *v1.ServiceAccount) (*v1.ServiceAccount, error) {
|
||||
return n.iface.Create(obj)
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.ServiceAccount, error) {
|
||||
return n.iface.GetNamespaced(namespace, name, opts)
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) Update(obj *v1.ServiceAccount) (*v1.ServiceAccount, error) {
|
||||
return n.iface.Update(obj)
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return n.iface.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) List(namespace string, opts metav1.ListOptions) (*ServiceAccountList, error) {
|
||||
return n.iface.List(opts)
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return n.iface.Watch(opts)
|
||||
}
|
||||
|
||||
func (n *serviceAccountClientCache) Get(namespace, name string) (*v1.ServiceAccount, error) {
|
||||
return n.client.controller.Lister().Get(namespace, name)
|
||||
}
|
||||
|
||||
func (n *serviceAccountClientCache) List(namespace string, selector labels.Selector) ([]*v1.ServiceAccount, error) {
|
||||
return n.client.controller.Lister().List(namespace, selector)
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) Cache() ServiceAccountClientCache {
|
||||
n.loadController()
|
||||
return &serviceAccountClientCache{
|
||||
client: n,
|
||||
}
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) OnCreate(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-create", &serviceAccountLifecycleDelegate{create: sync})
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) OnChange(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-change", &serviceAccountLifecycleDelegate{update: sync})
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) OnRemove(ctx context.Context, name string, sync ServiceAccountChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name, &serviceAccountLifecycleDelegate{remove: sync})
|
||||
}
|
||||
|
||||
func (n *serviceAccountClientCache) Index(name string, indexer ServiceAccountIndexer) {
|
||||
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
|
||||
name: func(obj interface{}) ([]string, error) {
|
||||
if v, ok := obj.(*v1.ServiceAccount); ok {
|
||||
return indexer(v)
|
||||
}
|
||||
return nil, nil
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *serviceAccountClientCache) GetIndexed(name, key string) ([]*v1.ServiceAccount, error) {
|
||||
var result []*v1.ServiceAccount
|
||||
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.ServiceAccount); ok {
|
||||
result = append(result, v)
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (n *serviceAccountClient2) loadController() {
|
||||
if n.controller == nil {
|
||||
n.controller = n.iface.Controller()
|
||||
}
|
||||
}
|
||||
|
||||
type serviceAccountLifecycleDelegate struct {
|
||||
create ServiceAccountChangeHandlerFunc
|
||||
update ServiceAccountChangeHandlerFunc
|
||||
remove ServiceAccountChangeHandlerFunc
|
||||
}
|
||||
|
||||
func (n *serviceAccountLifecycleDelegate) HasCreate() bool {
|
||||
return n.create != nil
|
||||
}
|
||||
|
||||
func (n *serviceAccountLifecycleDelegate) Create(obj *v1.ServiceAccount) (runtime.Object, error) {
|
||||
if n.create == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.create(obj)
|
||||
}
|
||||
|
||||
func (n *serviceAccountLifecycleDelegate) HasFinalize() bool {
|
||||
return n.remove != nil
|
||||
}
|
||||
|
||||
func (n *serviceAccountLifecycleDelegate) Remove(obj *v1.ServiceAccount) (runtime.Object, error) {
|
||||
if n.remove == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.remove(obj)
|
||||
}
|
||||
|
||||
func (n *serviceAccountLifecycleDelegate) Updated(obj *v1.ServiceAccount) (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/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type ServiceAccountLifecycle interface {
|
||||
Create(obj *v1.ServiceAccount) (runtime.Object, error)
|
||||
Remove(obj *v1.ServiceAccount) (runtime.Object, error)
|
||||
Updated(obj *v1.ServiceAccount) (runtime.Object, error)
|
||||
}
|
||||
|
||||
type serviceAccountLifecycleAdapter struct {
|
||||
lifecycle ServiceAccountLifecycle
|
||||
}
|
||||
|
||||
func (w *serviceAccountLifecycleAdapter) HasCreate() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasCreate()
|
||||
}
|
||||
|
||||
func (w *serviceAccountLifecycleAdapter) HasFinalize() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasFinalize()
|
||||
}
|
||||
|
||||
func (w *serviceAccountLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Create(obj.(*v1.ServiceAccount))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *serviceAccountLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Remove(obj.(*v1.ServiceAccount))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *serviceAccountLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Updated(obj.(*v1.ServiceAccount))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func NewServiceAccountLifecycleAdapter(name string, clusterScoped bool, client ServiceAccountInterface, l ServiceAccountLifecycle) ServiceAccountHandlerFunc {
|
||||
adapter := &serviceAccountLifecycleAdapter{lifecycle: l}
|
||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
|
||||
return func(key string, obj *v1.ServiceAccount) (runtime.Object, error) {
|
||||
newObj, err := syncFn(key, obj)
|
||||
if o, ok := newObj.(runtime.Object); ok {
|
||||
return o, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package v1
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
intstr "k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
@ -104,6 +105,107 @@ func (in *AddonStatus) DeepCopy() *AddonStatus {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmChart) DeepCopyInto(out *HelmChart) {
|
||||
*out = *in
|
||||
out.Namespaced = in.Namespaced
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
out.Status = in.Status
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChart.
|
||||
func (in *HelmChart) DeepCopy() *HelmChart {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmChart)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmChart) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmChartList) DeepCopyInto(out *HelmChartList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]HelmChart, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartList.
|
||||
func (in *HelmChartList) DeepCopy() *HelmChartList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmChartList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *HelmChartList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmChartSpec) DeepCopyInto(out *HelmChartSpec) {
|
||||
*out = *in
|
||||
if in.Set != nil {
|
||||
in, out := &in.Set, &out.Set
|
||||
*out = make(map[string]intstr.IntOrString, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartSpec.
|
||||
func (in *HelmChartSpec) DeepCopy() *HelmChartSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmChartSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *HelmChartStatus) DeepCopyInto(out *HelmChartStatus) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartStatus.
|
||||
func (in *HelmChartStatus) DeepCopy() *HelmChartStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(HelmChartStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ListenerConfig) DeepCopyInto(out *ListenerConfig) {
|
||||
*out = *in
|
||||
|
@ -0,0 +1,440 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"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 (
|
||||
HelmChartGroupVersionKind = schema.GroupVersionKind{
|
||||
Version: Version,
|
||||
Group: GroupName,
|
||||
Kind: "HelmChart",
|
||||
}
|
||||
HelmChartResource = metav1.APIResource{
|
||||
Name: "helmcharts",
|
||||
SingularName: "helmchart",
|
||||
Namespaced: true,
|
||||
|
||||
Kind: HelmChartGroupVersionKind.Kind,
|
||||
}
|
||||
)
|
||||
|
||||
func NewHelmChart(namespace, name string, obj HelmChart) *HelmChart {
|
||||
obj.APIVersion, obj.Kind = HelmChartGroupVersionKind.ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
type HelmChartList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []HelmChart
|
||||
}
|
||||
|
||||
type HelmChartHandlerFunc func(key string, obj *HelmChart) (runtime.Object, error)
|
||||
|
||||
type HelmChartChangeHandlerFunc func(obj *HelmChart) (runtime.Object, error)
|
||||
|
||||
type HelmChartLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*HelmChart, err error)
|
||||
Get(namespace, name string) (*HelmChart, error)
|
||||
}
|
||||
|
||||
type HelmChartController interface {
|
||||
Generic() controller.GenericController
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() HelmChartLister
|
||||
AddHandler(ctx context.Context, name string, handler HelmChartHandlerFunc)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler HelmChartHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type HelmChartInterface interface {
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Create(*HelmChart) (*HelmChart, error)
|
||||
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*HelmChart, error)
|
||||
Get(name string, opts metav1.GetOptions) (*HelmChart, error)
|
||||
Update(*HelmChart) (*HelmChart, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*HelmChartList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() HelmChartController
|
||||
AddHandler(ctx context.Context, name string, sync HelmChartHandlerFunc)
|
||||
AddLifecycle(ctx context.Context, name string, lifecycle HelmChartLifecycle)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync HelmChartHandlerFunc)
|
||||
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle HelmChartLifecycle)
|
||||
}
|
||||
|
||||
type helmChartLister struct {
|
||||
controller *helmChartController
|
||||
}
|
||||
|
||||
func (l *helmChartLister) List(namespace string, selector labels.Selector) (ret []*HelmChart, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*HelmChart))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *helmChartLister) Get(namespace, name string) (*HelmChart, 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: HelmChartGroupVersionKind.Group,
|
||||
Resource: "helmChart",
|
||||
}, key)
|
||||
}
|
||||
return obj.(*HelmChart), nil
|
||||
}
|
||||
|
||||
type helmChartController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *helmChartController) Generic() controller.GenericController {
|
||||
return c.GenericController
|
||||
}
|
||||
|
||||
func (c *helmChartController) Lister() HelmChartLister {
|
||||
return &helmChartLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *helmChartController) AddHandler(ctx context.Context, name string, handler HelmChartHandlerFunc) {
|
||||
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
|
||||
if obj == nil {
|
||||
return handler(key, nil)
|
||||
} else if v, ok := obj.(*HelmChart); ok {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (c *helmChartController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler HelmChartHandlerFunc) {
|
||||
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
|
||||
if obj == nil {
|
||||
return handler(key, nil)
|
||||
} else if v, ok := obj.(*HelmChart); ok && controller.ObjectInCluster(cluster, obj) {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type helmChartFactory struct {
|
||||
}
|
||||
|
||||
func (c helmChartFactory) Object() runtime.Object {
|
||||
return &HelmChart{}
|
||||
}
|
||||
|
||||
func (c helmChartFactory) List() runtime.Object {
|
||||
return &HelmChartList{}
|
||||
}
|
||||
|
||||
func (s *helmChartClient) Controller() HelmChartController {
|
||||
s.client.Lock()
|
||||
defer s.client.Unlock()
|
||||
|
||||
c, ok := s.client.helmChartControllers[s.ns]
|
||||
if ok {
|
||||
return c
|
||||
}
|
||||
|
||||
genericController := controller.NewGenericController(HelmChartGroupVersionKind.Kind+"Controller",
|
||||
s.objectClient)
|
||||
|
||||
c = &helmChartController{
|
||||
GenericController: genericController,
|
||||
}
|
||||
|
||||
s.client.helmChartControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type helmChartClient struct {
|
||||
client *Client
|
||||
ns string
|
||||
objectClient *objectclient.ObjectClient
|
||||
controller HelmChartController
|
||||
}
|
||||
|
||||
func (s *helmChartClient) ObjectClient() *objectclient.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *helmChartClient) Create(o *HelmChart) (*HelmChart, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*HelmChart), err
|
||||
}
|
||||
|
||||
func (s *helmChartClient) Get(name string, opts metav1.GetOptions) (*HelmChart, error) {
|
||||
obj, err := s.objectClient.Get(name, opts)
|
||||
return obj.(*HelmChart), err
|
||||
}
|
||||
|
||||
func (s *helmChartClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*HelmChart, error) {
|
||||
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
|
||||
return obj.(*HelmChart), err
|
||||
}
|
||||
|
||||
func (s *helmChartClient) Update(o *HelmChart) (*HelmChart, error) {
|
||||
obj, err := s.objectClient.Update(o.Name, o)
|
||||
return obj.(*HelmChart), err
|
||||
}
|
||||
|
||||
func (s *helmChartClient) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.Delete(name, options)
|
||||
}
|
||||
|
||||
func (s *helmChartClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (s *helmChartClient) List(opts metav1.ListOptions) (*HelmChartList, error) {
|
||||
obj, err := s.objectClient.List(opts)
|
||||
return obj.(*HelmChartList), err
|
||||
}
|
||||
|
||||
func (s *helmChartClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return s.objectClient.Watch(opts)
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched deployment.
|
||||
func (s *helmChartClient) Patch(o *HelmChart, patchType types.PatchType, data []byte, subresources ...string) (*HelmChart, error) {
|
||||
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
|
||||
return obj.(*HelmChart), err
|
||||
}
|
||||
|
||||
func (s *helmChartClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
||||
}
|
||||
|
||||
func (s *helmChartClient) AddHandler(ctx context.Context, name string, sync HelmChartHandlerFunc) {
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *helmChartClient) AddLifecycle(ctx context.Context, name string, lifecycle HelmChartLifecycle) {
|
||||
sync := NewHelmChartLifecycleAdapter(name, false, s, lifecycle)
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *helmChartClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync HelmChartHandlerFunc) {
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
func (s *helmChartClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle HelmChartLifecycle) {
|
||||
sync := NewHelmChartLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
type HelmChartIndexer func(obj *HelmChart) ([]string, error)
|
||||
|
||||
type HelmChartClientCache interface {
|
||||
Get(namespace, name string) (*HelmChart, error)
|
||||
List(namespace string, selector labels.Selector) ([]*HelmChart, error)
|
||||
|
||||
Index(name string, indexer HelmChartIndexer)
|
||||
GetIndexed(name, key string) ([]*HelmChart, error)
|
||||
}
|
||||
|
||||
type HelmChartClient interface {
|
||||
Create(*HelmChart) (*HelmChart, error)
|
||||
Get(namespace, name string, opts metav1.GetOptions) (*HelmChart, error)
|
||||
Update(*HelmChart) (*HelmChart, error)
|
||||
Delete(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(namespace string, opts metav1.ListOptions) (*HelmChartList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
|
||||
Cache() HelmChartClientCache
|
||||
|
||||
OnCreate(ctx context.Context, name string, sync HelmChartChangeHandlerFunc)
|
||||
OnChange(ctx context.Context, name string, sync HelmChartChangeHandlerFunc)
|
||||
OnRemove(ctx context.Context, name string, sync HelmChartChangeHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
|
||||
Generic() controller.GenericController
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Interface() HelmChartInterface
|
||||
}
|
||||
|
||||
type helmChartClientCache struct {
|
||||
client *helmChartClient2
|
||||
}
|
||||
|
||||
type helmChartClient2 struct {
|
||||
iface HelmChartInterface
|
||||
controller HelmChartController
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) Interface() HelmChartInterface {
|
||||
return n.iface
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) Generic() controller.GenericController {
|
||||
return n.iface.Controller().Generic()
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) ObjectClient() *objectclient.ObjectClient {
|
||||
return n.Interface().ObjectClient()
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) Enqueue(namespace, name string) {
|
||||
n.iface.Controller().Enqueue(namespace, name)
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) Create(obj *HelmChart) (*HelmChart, error) {
|
||||
return n.iface.Create(obj)
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) Get(namespace, name string, opts metav1.GetOptions) (*HelmChart, error) {
|
||||
return n.iface.GetNamespaced(namespace, name, opts)
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) Update(obj *HelmChart) (*HelmChart, error) {
|
||||
return n.iface.Update(obj)
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return n.iface.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) List(namespace string, opts metav1.ListOptions) (*HelmChartList, error) {
|
||||
return n.iface.List(opts)
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return n.iface.Watch(opts)
|
||||
}
|
||||
|
||||
func (n *helmChartClientCache) Get(namespace, name string) (*HelmChart, error) {
|
||||
return n.client.controller.Lister().Get(namespace, name)
|
||||
}
|
||||
|
||||
func (n *helmChartClientCache) List(namespace string, selector labels.Selector) ([]*HelmChart, error) {
|
||||
return n.client.controller.Lister().List(namespace, selector)
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) Cache() HelmChartClientCache {
|
||||
n.loadController()
|
||||
return &helmChartClientCache{
|
||||
client: n,
|
||||
}
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) OnCreate(ctx context.Context, name string, sync HelmChartChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-create", &helmChartLifecycleDelegate{create: sync})
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) OnChange(ctx context.Context, name string, sync HelmChartChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-change", &helmChartLifecycleDelegate{update: sync})
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) OnRemove(ctx context.Context, name string, sync HelmChartChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name, &helmChartLifecycleDelegate{remove: sync})
|
||||
}
|
||||
|
||||
func (n *helmChartClientCache) Index(name string, indexer HelmChartIndexer) {
|
||||
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
|
||||
name: func(obj interface{}) ([]string, error) {
|
||||
if v, ok := obj.(*HelmChart); ok {
|
||||
return indexer(v)
|
||||
}
|
||||
return nil, nil
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *helmChartClientCache) GetIndexed(name, key string) ([]*HelmChart, error) {
|
||||
var result []*HelmChart
|
||||
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, obj := range objs {
|
||||
if v, ok := obj.(*HelmChart); ok {
|
||||
result = append(result, v)
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (n *helmChartClient2) loadController() {
|
||||
if n.controller == nil {
|
||||
n.controller = n.iface.Controller()
|
||||
}
|
||||
}
|
||||
|
||||
type helmChartLifecycleDelegate struct {
|
||||
create HelmChartChangeHandlerFunc
|
||||
update HelmChartChangeHandlerFunc
|
||||
remove HelmChartChangeHandlerFunc
|
||||
}
|
||||
|
||||
func (n *helmChartLifecycleDelegate) HasCreate() bool {
|
||||
return n.create != nil
|
||||
}
|
||||
|
||||
func (n *helmChartLifecycleDelegate) Create(obj *HelmChart) (runtime.Object, error) {
|
||||
if n.create == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.create(obj)
|
||||
}
|
||||
|
||||
func (n *helmChartLifecycleDelegate) HasFinalize() bool {
|
||||
return n.remove != nil
|
||||
}
|
||||
|
||||
func (n *helmChartLifecycleDelegate) Remove(obj *HelmChart) (runtime.Object, error) {
|
||||
if n.remove == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.remove(obj)
|
||||
}
|
||||
|
||||
func (n *helmChartLifecycleDelegate) Updated(obj *HelmChart) (runtime.Object, error) {
|
||||
if n.update == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.update(obj)
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type HelmChartLifecycle interface {
|
||||
Create(obj *HelmChart) (runtime.Object, error)
|
||||
Remove(obj *HelmChart) (runtime.Object, error)
|
||||
Updated(obj *HelmChart) (runtime.Object, error)
|
||||
}
|
||||
|
||||
type helmChartLifecycleAdapter struct {
|
||||
lifecycle HelmChartLifecycle
|
||||
}
|
||||
|
||||
func (w *helmChartLifecycleAdapter) HasCreate() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasCreate()
|
||||
}
|
||||
|
||||
func (w *helmChartLifecycleAdapter) HasFinalize() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasFinalize()
|
||||
}
|
||||
|
||||
func (w *helmChartLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Create(obj.(*HelmChart))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *helmChartLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Remove(obj.(*HelmChart))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *helmChartLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Updated(obj.(*HelmChart))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func NewHelmChartLifecycleAdapter(name string, clusterScoped bool, client HelmChartInterface, l HelmChartLifecycle) HelmChartHandlerFunc {
|
||||
adapter := &helmChartLifecycleAdapter{lifecycle: l}
|
||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
|
||||
return func(key string, obj *HelmChart) (runtime.Object, error) {
|
||||
newObj, err := syncFn(key, obj)
|
||||
if o, ok := newObj.(runtime.Object); ok {
|
||||
return o, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
}
|
@ -20,15 +20,17 @@ type Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
controller.Starter
|
||||
|
||||
ListenerConfigsGetter
|
||||
AddonsGetter
|
||||
HelmChartsGetter
|
||||
ListenerConfigsGetter
|
||||
}
|
||||
|
||||
type Clients struct {
|
||||
Interface Interface
|
||||
|
||||
ListenerConfig ListenerConfigClient
|
||||
Addon AddonClient
|
||||
HelmChart HelmChartClient
|
||||
ListenerConfig ListenerConfigClient
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
@ -36,8 +38,9 @@ type Client struct {
|
||||
restClient rest.Interface
|
||||
starters []controller.Starter
|
||||
|
||||
listenerConfigControllers map[string]ListenerConfigController
|
||||
addonControllers map[string]AddonController
|
||||
helmChartControllers map[string]HelmChartController
|
||||
listenerConfigControllers map[string]ListenerConfigController
|
||||
}
|
||||
|
||||
func Factory(ctx context.Context, config rest.Config) (context.Context, controller.Starter, error) {
|
||||
@ -73,12 +76,15 @@ func NewClientsFromInterface(iface Interface) *Clients {
|
||||
return &Clients{
|
||||
Interface: iface,
|
||||
|
||||
ListenerConfig: &listenerConfigClient2{
|
||||
iface: iface.ListenerConfigs(""),
|
||||
},
|
||||
Addon: &addonClient2{
|
||||
iface: iface.Addons(""),
|
||||
},
|
||||
HelmChart: &helmChartClient2{
|
||||
iface: iface.HelmCharts(""),
|
||||
},
|
||||
ListenerConfig: &listenerConfigClient2{
|
||||
iface: iface.ListenerConfigs(""),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,8 +101,9 @@ func NewForConfig(config rest.Config) (Interface, error) {
|
||||
return &Client{
|
||||
restClient: restClient,
|
||||
|
||||
listenerConfigControllers: map[string]ListenerConfigController{},
|
||||
addonControllers: map[string]AddonController{},
|
||||
helmChartControllers: map[string]HelmChartController{},
|
||||
listenerConfigControllers: map[string]ListenerConfigController{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -112,19 +119,6 @@ func (c *Client) Start(ctx context.Context, threadiness int) error {
|
||||
return controller.Start(ctx, threadiness, c.starters...)
|
||||
}
|
||||
|
||||
type ListenerConfigsGetter interface {
|
||||
ListenerConfigs(namespace string) ListenerConfigInterface
|
||||
}
|
||||
|
||||
func (c *Client) ListenerConfigs(namespace string) ListenerConfigInterface {
|
||||
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &ListenerConfigResource, ListenerConfigGroupVersionKind, listenerConfigFactory{})
|
||||
return &listenerConfigClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
||||
|
||||
type AddonsGetter interface {
|
||||
Addons(namespace string) AddonInterface
|
||||
}
|
||||
@ -137,3 +131,29 @@ func (c *Client) Addons(namespace string) AddonInterface {
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
||||
|
||||
type HelmChartsGetter interface {
|
||||
HelmCharts(namespace string) HelmChartInterface
|
||||
}
|
||||
|
||||
func (c *Client) HelmCharts(namespace string) HelmChartInterface {
|
||||
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &HelmChartResource, HelmChartGroupVersionKind, helmChartFactory{})
|
||||
return &helmChartClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
||||
|
||||
type ListenerConfigsGetter interface {
|
||||
ListenerConfigs(namespace string) ListenerConfigInterface
|
||||
}
|
||||
|
||||
func (c *Client) ListenerConfigs(namespace string) ListenerConfigInterface {
|
||||
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &ListenerConfigResource, ListenerConfigGroupVersionKind, listenerConfigFactory{})
|
||||
return &listenerConfigClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,12 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
// TODO this gets cleaned up when the types are fixed
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
|
||||
&ListenerConfig{},
|
||||
&ListenerConfigList{},
|
||||
&Addon{},
|
||||
&AddonList{},
|
||||
&HelmChart{},
|
||||
&HelmChartList{},
|
||||
&ListenerConfig{},
|
||||
&ListenerConfigList{},
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
@ -0,0 +1,440 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
v1 "k8s.io/api/rbac/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 (
|
||||
ClusterRoleBindingGroupVersionKind = schema.GroupVersionKind{
|
||||
Version: Version,
|
||||
Group: GroupName,
|
||||
Kind: "ClusterRoleBinding",
|
||||
}
|
||||
ClusterRoleBindingResource = metav1.APIResource{
|
||||
Name: "clusterrolebindings",
|
||||
SingularName: "clusterrolebinding",
|
||||
Namespaced: false,
|
||||
Kind: ClusterRoleBindingGroupVersionKind.Kind,
|
||||
}
|
||||
)
|
||||
|
||||
func NewClusterRoleBinding(namespace, name string, obj v1.ClusterRoleBinding) *v1.ClusterRoleBinding {
|
||||
obj.APIVersion, obj.Kind = ClusterRoleBindingGroupVersionKind.ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
type ClusterRoleBindingList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []v1.ClusterRoleBinding
|
||||
}
|
||||
|
||||
type ClusterRoleBindingHandlerFunc func(key string, obj *v1.ClusterRoleBinding) (runtime.Object, error)
|
||||
|
||||
type ClusterRoleBindingChangeHandlerFunc func(obj *v1.ClusterRoleBinding) (runtime.Object, error)
|
||||
|
||||
type ClusterRoleBindingLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*v1.ClusterRoleBinding, err error)
|
||||
Get(namespace, name string) (*v1.ClusterRoleBinding, error)
|
||||
}
|
||||
|
||||
type ClusterRoleBindingController interface {
|
||||
Generic() controller.GenericController
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() ClusterRoleBindingLister
|
||||
AddHandler(ctx context.Context, name string, handler ClusterRoleBindingHandlerFunc)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler ClusterRoleBindingHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type ClusterRoleBindingInterface interface {
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Create(*v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error)
|
||||
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ClusterRoleBinding, error)
|
||||
Get(name string, opts metav1.GetOptions) (*v1.ClusterRoleBinding, error)
|
||||
Update(*v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*ClusterRoleBindingList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() ClusterRoleBindingController
|
||||
AddHandler(ctx context.Context, name string, sync ClusterRoleBindingHandlerFunc)
|
||||
AddLifecycle(ctx context.Context, name string, lifecycle ClusterRoleBindingLifecycle)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ClusterRoleBindingHandlerFunc)
|
||||
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ClusterRoleBindingLifecycle)
|
||||
}
|
||||
|
||||
type clusterRoleBindingLister struct {
|
||||
controller *clusterRoleBindingController
|
||||
}
|
||||
|
||||
func (l *clusterRoleBindingLister) List(namespace string, selector labels.Selector) (ret []*v1.ClusterRoleBinding, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*v1.ClusterRoleBinding))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *clusterRoleBindingLister) Get(namespace, name string) (*v1.ClusterRoleBinding, 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: ClusterRoleBindingGroupVersionKind.Group,
|
||||
Resource: "clusterRoleBinding",
|
||||
}, key)
|
||||
}
|
||||
return obj.(*v1.ClusterRoleBinding), nil
|
||||
}
|
||||
|
||||
type clusterRoleBindingController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *clusterRoleBindingController) Generic() controller.GenericController {
|
||||
return c.GenericController
|
||||
}
|
||||
|
||||
func (c *clusterRoleBindingController) Lister() ClusterRoleBindingLister {
|
||||
return &clusterRoleBindingLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *clusterRoleBindingController) AddHandler(ctx context.Context, name string, handler ClusterRoleBindingHandlerFunc) {
|
||||
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.ClusterRoleBinding); ok {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (c *clusterRoleBindingController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler ClusterRoleBindingHandlerFunc) {
|
||||
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.ClusterRoleBinding); ok && controller.ObjectInCluster(cluster, obj) {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type clusterRoleBindingFactory struct {
|
||||
}
|
||||
|
||||
func (c clusterRoleBindingFactory) Object() runtime.Object {
|
||||
return &v1.ClusterRoleBinding{}
|
||||
}
|
||||
|
||||
func (c clusterRoleBindingFactory) List() runtime.Object {
|
||||
return &ClusterRoleBindingList{}
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) Controller() ClusterRoleBindingController {
|
||||
s.client.Lock()
|
||||
defer s.client.Unlock()
|
||||
|
||||
c, ok := s.client.clusterRoleBindingControllers[s.ns]
|
||||
if ok {
|
||||
return c
|
||||
}
|
||||
|
||||
genericController := controller.NewGenericController(ClusterRoleBindingGroupVersionKind.Kind+"Controller",
|
||||
s.objectClient)
|
||||
|
||||
c = &clusterRoleBindingController{
|
||||
GenericController: genericController,
|
||||
}
|
||||
|
||||
s.client.clusterRoleBindingControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type clusterRoleBindingClient struct {
|
||||
client *Client
|
||||
ns string
|
||||
objectClient *objectclient.ObjectClient
|
||||
controller ClusterRoleBindingController
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) ObjectClient() *objectclient.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) Create(o *v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*v1.ClusterRoleBinding), err
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) Get(name string, opts metav1.GetOptions) (*v1.ClusterRoleBinding, error) {
|
||||
obj, err := s.objectClient.Get(name, opts)
|
||||
return obj.(*v1.ClusterRoleBinding), err
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ClusterRoleBinding, error) {
|
||||
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
|
||||
return obj.(*v1.ClusterRoleBinding), err
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) Update(o *v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error) {
|
||||
obj, err := s.objectClient.Update(o.Name, o)
|
||||
return obj.(*v1.ClusterRoleBinding), err
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.Delete(name, options)
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) List(opts metav1.ListOptions) (*ClusterRoleBindingList, error) {
|
||||
obj, err := s.objectClient.List(opts)
|
||||
return obj.(*ClusterRoleBindingList), err
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return s.objectClient.Watch(opts)
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched deployment.
|
||||
func (s *clusterRoleBindingClient) Patch(o *v1.ClusterRoleBinding, patchType types.PatchType, data []byte, subresources ...string) (*v1.ClusterRoleBinding, error) {
|
||||
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
|
||||
return obj.(*v1.ClusterRoleBinding), err
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) AddHandler(ctx context.Context, name string, sync ClusterRoleBindingHandlerFunc) {
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) AddLifecycle(ctx context.Context, name string, lifecycle ClusterRoleBindingLifecycle) {
|
||||
sync := NewClusterRoleBindingLifecycleAdapter(name, false, s, lifecycle)
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync ClusterRoleBindingHandlerFunc) {
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
func (s *clusterRoleBindingClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle ClusterRoleBindingLifecycle) {
|
||||
sync := NewClusterRoleBindingLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
type ClusterRoleBindingIndexer func(obj *v1.ClusterRoleBinding) ([]string, error)
|
||||
|
||||
type ClusterRoleBindingClientCache interface {
|
||||
Get(namespace, name string) (*v1.ClusterRoleBinding, error)
|
||||
List(namespace string, selector labels.Selector) ([]*v1.ClusterRoleBinding, error)
|
||||
|
||||
Index(name string, indexer ClusterRoleBindingIndexer)
|
||||
GetIndexed(name, key string) ([]*v1.ClusterRoleBinding, error)
|
||||
}
|
||||
|
||||
type ClusterRoleBindingClient interface {
|
||||
Create(*v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error)
|
||||
Get(namespace, name string, opts metav1.GetOptions) (*v1.ClusterRoleBinding, error)
|
||||
Update(*v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error)
|
||||
Delete(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(namespace string, opts metav1.ListOptions) (*ClusterRoleBindingList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
|
||||
Cache() ClusterRoleBindingClientCache
|
||||
|
||||
OnCreate(ctx context.Context, name string, sync ClusterRoleBindingChangeHandlerFunc)
|
||||
OnChange(ctx context.Context, name string, sync ClusterRoleBindingChangeHandlerFunc)
|
||||
OnRemove(ctx context.Context, name string, sync ClusterRoleBindingChangeHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
|
||||
Generic() controller.GenericController
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Interface() ClusterRoleBindingInterface
|
||||
}
|
||||
|
||||
type clusterRoleBindingClientCache struct {
|
||||
client *clusterRoleBindingClient2
|
||||
}
|
||||
|
||||
type clusterRoleBindingClient2 struct {
|
||||
iface ClusterRoleBindingInterface
|
||||
controller ClusterRoleBindingController
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) Interface() ClusterRoleBindingInterface {
|
||||
return n.iface
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) Generic() controller.GenericController {
|
||||
return n.iface.Controller().Generic()
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) ObjectClient() *objectclient.ObjectClient {
|
||||
return n.Interface().ObjectClient()
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) Enqueue(namespace, name string) {
|
||||
n.iface.Controller().Enqueue(namespace, name)
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) Create(obj *v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error) {
|
||||
return n.iface.Create(obj)
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.ClusterRoleBinding, error) {
|
||||
return n.iface.GetNamespaced(namespace, name, opts)
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) Update(obj *v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error) {
|
||||
return n.iface.Update(obj)
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return n.iface.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) List(namespace string, opts metav1.ListOptions) (*ClusterRoleBindingList, error) {
|
||||
return n.iface.List(opts)
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return n.iface.Watch(opts)
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClientCache) Get(namespace, name string) (*v1.ClusterRoleBinding, error) {
|
||||
return n.client.controller.Lister().Get(namespace, name)
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClientCache) List(namespace string, selector labels.Selector) ([]*v1.ClusterRoleBinding, error) {
|
||||
return n.client.controller.Lister().List(namespace, selector)
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) Cache() ClusterRoleBindingClientCache {
|
||||
n.loadController()
|
||||
return &clusterRoleBindingClientCache{
|
||||
client: n,
|
||||
}
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) OnCreate(ctx context.Context, name string, sync ClusterRoleBindingChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-create", &clusterRoleBindingLifecycleDelegate{create: sync})
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) OnChange(ctx context.Context, name string, sync ClusterRoleBindingChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-change", &clusterRoleBindingLifecycleDelegate{update: sync})
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) OnRemove(ctx context.Context, name string, sync ClusterRoleBindingChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name, &clusterRoleBindingLifecycleDelegate{remove: sync})
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClientCache) Index(name string, indexer ClusterRoleBindingIndexer) {
|
||||
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
|
||||
name: func(obj interface{}) ([]string, error) {
|
||||
if v, ok := obj.(*v1.ClusterRoleBinding); ok {
|
||||
return indexer(v)
|
||||
}
|
||||
return nil, nil
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClientCache) GetIndexed(name, key string) ([]*v1.ClusterRoleBinding, error) {
|
||||
var result []*v1.ClusterRoleBinding
|
||||
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.ClusterRoleBinding); ok {
|
||||
result = append(result, v)
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingClient2) loadController() {
|
||||
if n.controller == nil {
|
||||
n.controller = n.iface.Controller()
|
||||
}
|
||||
}
|
||||
|
||||
type clusterRoleBindingLifecycleDelegate struct {
|
||||
create ClusterRoleBindingChangeHandlerFunc
|
||||
update ClusterRoleBindingChangeHandlerFunc
|
||||
remove ClusterRoleBindingChangeHandlerFunc
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingLifecycleDelegate) HasCreate() bool {
|
||||
return n.create != nil
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingLifecycleDelegate) Create(obj *v1.ClusterRoleBinding) (runtime.Object, error) {
|
||||
if n.create == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.create(obj)
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingLifecycleDelegate) HasFinalize() bool {
|
||||
return n.remove != nil
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingLifecycleDelegate) Remove(obj *v1.ClusterRoleBinding) (runtime.Object, error) {
|
||||
if n.remove == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.remove(obj)
|
||||
}
|
||||
|
||||
func (n *clusterRoleBindingLifecycleDelegate) Updated(obj *v1.ClusterRoleBinding) (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/rbac/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type ClusterRoleBindingLifecycle interface {
|
||||
Create(obj *v1.ClusterRoleBinding) (runtime.Object, error)
|
||||
Remove(obj *v1.ClusterRoleBinding) (runtime.Object, error)
|
||||
Updated(obj *v1.ClusterRoleBinding) (runtime.Object, error)
|
||||
}
|
||||
|
||||
type clusterRoleBindingLifecycleAdapter struct {
|
||||
lifecycle ClusterRoleBindingLifecycle
|
||||
}
|
||||
|
||||
func (w *clusterRoleBindingLifecycleAdapter) HasCreate() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasCreate()
|
||||
}
|
||||
|
||||
func (w *clusterRoleBindingLifecycleAdapter) HasFinalize() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasFinalize()
|
||||
}
|
||||
|
||||
func (w *clusterRoleBindingLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Create(obj.(*v1.ClusterRoleBinding))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *clusterRoleBindingLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Remove(obj.(*v1.ClusterRoleBinding))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *clusterRoleBindingLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Updated(obj.(*v1.ClusterRoleBinding))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func NewClusterRoleBindingLifecycleAdapter(name string, clusterScoped bool, client ClusterRoleBindingInterface, l ClusterRoleBindingLifecycle) ClusterRoleBindingHandlerFunc {
|
||||
adapter := &clusterRoleBindingLifecycleAdapter{lifecycle: l}
|
||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
|
||||
return func(key string, obj *v1.ClusterRoleBinding) (runtime.Object, error) {
|
||||
newObj, err := syncFn(key, obj)
|
||||
if o, ok := newObj.(runtime.Object); ok {
|
||||
return o, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
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 *ClusterRoleBindingList) DeepCopyInto(out *ClusterRoleBindingList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]rbacv1.ClusterRoleBinding, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterRoleBindingList.
|
||||
func (in *ClusterRoleBindingList) DeepCopy() *ClusterRoleBindingList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterRoleBindingList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ClusterRoleBindingList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
package v1
|
||||
|
||||
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
|
||||
|
||||
ClusterRoleBindingsGetter
|
||||
}
|
||||
|
||||
type Clients struct {
|
||||
Interface Interface
|
||||
|
||||
ClusterRoleBinding ClusterRoleBindingClient
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
sync.Mutex
|
||||
restClient rest.Interface
|
||||
starters []controller.Starter
|
||||
|
||||
clusterRoleBindingControllers map[string]ClusterRoleBindingController
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
ClusterRoleBinding: &clusterRoleBindingClient2{
|
||||
iface: iface.ClusterRoleBindings(""),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
clusterRoleBindingControllers: map[string]ClusterRoleBindingController{},
|
||||
}, 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 ClusterRoleBindingsGetter interface {
|
||||
ClusterRoleBindings(namespace string) ClusterRoleBindingInterface
|
||||
}
|
||||
|
||||
func (c *Client) ClusterRoleBindings(namespace string) ClusterRoleBindingInterface {
|
||||
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &ClusterRoleBindingResource, ClusterRoleBindingGroupVersionKind, clusterRoleBindingFactory{})
|
||||
return &clusterRoleBindingClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
GroupName = "rbac.authorization.k8s.io"
|
||||
Version = "v1"
|
||||
)
|
||||
|
||||
// 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,
|
||||
|
||||
&ClusterRoleBindingList{},
|
||||
)
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user