Initial commit

This commit is contained in:
Darren Shepherd
2019-08-04 10:41:32 -07:00
commit c0299c1506
2045 changed files with 724722 additions and 0 deletions

177
vendor/github.com/rancher/wrangler-api/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,177 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@@ -0,0 +1,107 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package apiextensions
import (
"context"
"time"
"github.com/rancher/wrangler/pkg/generic"
"github.com/rancher/wrangler/pkg/schemes"
clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
scheme "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme"
informers "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/rest"
)
func init() {
scheme.AddToScheme(schemes.All)
}
type Factory struct {
synced bool
informerFactory informers.SharedInformerFactory
clientset clientset.Interface
controllerManager *generic.ControllerManager
threadiness map[schema.GroupVersionKind]int
}
func NewFactoryFromConfigOrDie(config *rest.Config) *Factory {
f, err := NewFactoryFromConfig(config)
if err != nil {
panic(err)
}
return f
}
func NewFactoryFromConfig(config *rest.Config) (*Factory, error) {
cs, err := clientset.NewForConfig(config)
if err != nil {
return nil, err
}
informerFactory := informers.NewSharedInformerFactory(cs, 2*time.Hour)
return NewFactory(cs, informerFactory), nil
}
func NewFactoryFromConfigWithNamespace(config *rest.Config, namespace string) (*Factory, error) {
if namespace == "" {
return NewFactoryFromConfig(config)
}
cs, err := clientset.NewForConfig(config)
if err != nil {
return nil, err
}
informerFactory := informers.NewSharedInformerFactoryWithOptions(cs, 2*time.Hour, informers.WithNamespace(namespace))
return NewFactory(cs, informerFactory), nil
}
func NewFactory(clientset clientset.Interface, informerFactory informers.SharedInformerFactory) *Factory {
return &Factory{
threadiness: map[schema.GroupVersionKind]int{},
controllerManager: &generic.ControllerManager{},
clientset: clientset,
informerFactory: informerFactory,
}
}
func (c *Factory) SetThreadiness(gvk schema.GroupVersionKind, threadiness int) {
c.threadiness[gvk] = threadiness
}
func (c *Factory) Sync(ctx context.Context) error {
c.informerFactory.Start(ctx.Done())
c.informerFactory.WaitForCacheSync(ctx.Done())
return nil
}
func (c *Factory) Start(ctx context.Context, defaultThreadiness int) error {
if err := c.Sync(ctx); err != nil {
return err
}
return c.controllerManager.Start(ctx, defaultThreadiness, c.threadiness)
}
func (c *Factory) Apiextensions() Interface {
return New(c.controllerManager, c.informerFactory.Apiextensions(), c.clientset)
}

View File

@@ -0,0 +1,50 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package apiextensions
import (
v1beta1 "github.com/rancher/wrangler-api/pkg/generated/controllers/apiextensions.k8s.io/v1beta1"
"github.com/rancher/wrangler/pkg/generic"
clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
informers "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions"
)
type Interface interface {
V1beta1() v1beta1.Interface
}
type group struct {
controllerManager *generic.ControllerManager
informers informers.Interface
client clientset.Interface
}
// New returns a new Interface.
func New(controllerManager *generic.ControllerManager, informers informers.Interface,
client clientset.Interface) Interface {
return &group{
controllerManager: controllerManager,
informers: informers,
client: client,
}
}
func (g *group) V1beta1() v1beta1.Interface {
return v1beta1.New(g.controllerManager, g.client.ApiextensionsV1beta1(), g.informers.V1beta1())
}

View File

@@ -0,0 +1,242 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1beta1
import (
"context"
"github.com/rancher/wrangler/pkg/generic"
v1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1"
informers "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1"
listers "k8s.io/apiextensions-apiserver/pkg/client/listers/apiextensions/v1beta1"
"k8s.io/apimachinery/pkg/api/equality"
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"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
type CustomResourceDefinitionHandler func(string, *v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error)
type CustomResourceDefinitionController interface {
CustomResourceDefinitionClient
OnChange(ctx context.Context, name string, sync CustomResourceDefinitionHandler)
OnRemove(ctx context.Context, name string, sync CustomResourceDefinitionHandler)
Enqueue(name string)
Cache() CustomResourceDefinitionCache
Informer() cache.SharedIndexInformer
GroupVersionKind() schema.GroupVersionKind
AddGenericHandler(ctx context.Context, name string, handler generic.Handler)
AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler)
Updater() generic.Updater
}
type CustomResourceDefinitionClient interface {
Create(*v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error)
Update(*v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error)
UpdateStatus(*v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error)
Delete(name string, options *metav1.DeleteOptions) error
Get(name string, options metav1.GetOptions) (*v1beta1.CustomResourceDefinition, error)
List(opts metav1.ListOptions) (*v1beta1.CustomResourceDefinitionList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.CustomResourceDefinition, err error)
}
type CustomResourceDefinitionCache interface {
Get(name string) (*v1beta1.CustomResourceDefinition, error)
List(selector labels.Selector) ([]*v1beta1.CustomResourceDefinition, error)
AddIndexer(indexName string, indexer CustomResourceDefinitionIndexer)
GetByIndex(indexName, key string) ([]*v1beta1.CustomResourceDefinition, error)
}
type CustomResourceDefinitionIndexer func(obj *v1beta1.CustomResourceDefinition) ([]string, error)
type customResourceDefinitionController struct {
controllerManager *generic.ControllerManager
clientGetter clientset.CustomResourceDefinitionsGetter
informer informers.CustomResourceDefinitionInformer
gvk schema.GroupVersionKind
}
func NewCustomResourceDefinitionController(gvk schema.GroupVersionKind, controllerManager *generic.ControllerManager, clientGetter clientset.CustomResourceDefinitionsGetter, informer informers.CustomResourceDefinitionInformer) CustomResourceDefinitionController {
return &customResourceDefinitionController{
controllerManager: controllerManager,
clientGetter: clientGetter,
informer: informer,
gvk: gvk,
}
}
func FromCustomResourceDefinitionHandlerToHandler(sync CustomResourceDefinitionHandler) generic.Handler {
return func(key string, obj runtime.Object) (ret runtime.Object, err error) {
var v *v1beta1.CustomResourceDefinition
if obj == nil {
v, err = sync(key, nil)
} else {
v, err = sync(key, obj.(*v1beta1.CustomResourceDefinition))
}
if v == nil {
return nil, err
}
return v, err
}
}
func (c *customResourceDefinitionController) Updater() generic.Updater {
return func(obj runtime.Object) (runtime.Object, error) {
newObj, err := c.Update(obj.(*v1beta1.CustomResourceDefinition))
if newObj == nil {
return nil, err
}
return newObj, err
}
}
func UpdateCustomResourceDefinitionOnChange(updater generic.Updater, handler CustomResourceDefinitionHandler) CustomResourceDefinitionHandler {
return func(key string, obj *v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error) {
if obj == nil {
return handler(key, nil)
}
copyObj := obj.DeepCopy()
newObj, err := handler(key, copyObj)
if newObj != nil {
copyObj = newObj
}
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
newObj, err := updater(copyObj)
if newObj != nil && err == nil {
copyObj = newObj.(*v1beta1.CustomResourceDefinition)
}
}
return copyObj, err
}
}
func (c *customResourceDefinitionController) AddGenericHandler(ctx context.Context, name string, handler generic.Handler) {
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, handler)
}
func (c *customResourceDefinitionController) AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), handler)
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, removeHandler)
}
func (c *customResourceDefinitionController) OnChange(ctx context.Context, name string, sync CustomResourceDefinitionHandler) {
c.AddGenericHandler(ctx, name, FromCustomResourceDefinitionHandlerToHandler(sync))
}
func (c *customResourceDefinitionController) OnRemove(ctx context.Context, name string, sync CustomResourceDefinitionHandler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), FromCustomResourceDefinitionHandlerToHandler(sync))
c.AddGenericHandler(ctx, name, removeHandler)
}
func (c *customResourceDefinitionController) Enqueue(name string) {
c.controllerManager.Enqueue(c.gvk, c.informer.Informer(), "", name)
}
func (c *customResourceDefinitionController) Informer() cache.SharedIndexInformer {
return c.informer.Informer()
}
func (c *customResourceDefinitionController) GroupVersionKind() schema.GroupVersionKind {
return c.gvk
}
func (c *customResourceDefinitionController) Cache() CustomResourceDefinitionCache {
return &customResourceDefinitionCache{
lister: c.informer.Lister(),
indexer: c.informer.Informer().GetIndexer(),
}
}
func (c *customResourceDefinitionController) Create(obj *v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error) {
return c.clientGetter.CustomResourceDefinitions().Create(obj)
}
func (c *customResourceDefinitionController) Update(obj *v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error) {
return c.clientGetter.CustomResourceDefinitions().Update(obj)
}
func (c *customResourceDefinitionController) UpdateStatus(obj *v1beta1.CustomResourceDefinition) (*v1beta1.CustomResourceDefinition, error) {
return c.clientGetter.CustomResourceDefinitions().UpdateStatus(obj)
}
func (c *customResourceDefinitionController) Delete(name string, options *metav1.DeleteOptions) error {
return c.clientGetter.CustomResourceDefinitions().Delete(name, options)
}
func (c *customResourceDefinitionController) Get(name string, options metav1.GetOptions) (*v1beta1.CustomResourceDefinition, error) {
return c.clientGetter.CustomResourceDefinitions().Get(name, options)
}
func (c *customResourceDefinitionController) List(opts metav1.ListOptions) (*v1beta1.CustomResourceDefinitionList, error) {
return c.clientGetter.CustomResourceDefinitions().List(opts)
}
func (c *customResourceDefinitionController) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return c.clientGetter.CustomResourceDefinitions().Watch(opts)
}
func (c *customResourceDefinitionController) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.CustomResourceDefinition, err error) {
return c.clientGetter.CustomResourceDefinitions().Patch(name, pt, data, subresources...)
}
type customResourceDefinitionCache struct {
lister listers.CustomResourceDefinitionLister
indexer cache.Indexer
}
func (c *customResourceDefinitionCache) Get(name string) (*v1beta1.CustomResourceDefinition, error) {
return c.lister.Get(name)
}
func (c *customResourceDefinitionCache) List(selector labels.Selector) ([]*v1beta1.CustomResourceDefinition, error) {
return c.lister.List(selector)
}
func (c *customResourceDefinitionCache) AddIndexer(indexName string, indexer CustomResourceDefinitionIndexer) {
utilruntime.Must(c.indexer.AddIndexers(map[string]cache.IndexFunc{
indexName: func(obj interface{}) (strings []string, e error) {
return indexer(obj.(*v1beta1.CustomResourceDefinition))
},
}))
}
func (c *customResourceDefinitionCache) GetByIndex(indexName, key string) (result []*v1beta1.CustomResourceDefinition, err error) {
objs, err := c.indexer.ByIndex(indexName, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
result = append(result, obj.(*v1beta1.CustomResourceDefinition))
}
return result, nil
}

View File

@@ -0,0 +1,49 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1beta1
import (
"github.com/rancher/wrangler/pkg/generic"
v1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
clientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1"
informers "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1"
)
type Interface interface {
CustomResourceDefinition() CustomResourceDefinitionController
}
func New(controllerManager *generic.ControllerManager, client clientset.ApiextensionsV1beta1Interface,
informers informers.Interface) Interface {
return &version{
controllerManager: controllerManager,
client: client,
informers: informers,
}
}
type version struct {
controllerManager *generic.ControllerManager
informers informers.Interface
client clientset.ApiextensionsV1beta1Interface
}
func (c *version) CustomResourceDefinition() CustomResourceDefinitionController {
return NewCustomResourceDefinitionController(v1beta1.SchemeGroupVersion.WithKind("CustomResourceDefinition"), c.controllerManager, c.client, c.informers.CustomResourceDefinitions())
}

View File

@@ -0,0 +1,107 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package apiregistration
import (
"context"
"time"
"github.com/rancher/wrangler/pkg/generic"
"github.com/rancher/wrangler/pkg/schemes"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/rest"
clientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset"
scheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
informers "k8s.io/kube-aggregator/pkg/client/informers/externalversions"
)
func init() {
scheme.AddToScheme(schemes.All)
}
type Factory struct {
synced bool
informerFactory informers.SharedInformerFactory
clientset clientset.Interface
controllerManager *generic.ControllerManager
threadiness map[schema.GroupVersionKind]int
}
func NewFactoryFromConfigOrDie(config *rest.Config) *Factory {
f, err := NewFactoryFromConfig(config)
if err != nil {
panic(err)
}
return f
}
func NewFactoryFromConfig(config *rest.Config) (*Factory, error) {
cs, err := clientset.NewForConfig(config)
if err != nil {
return nil, err
}
informerFactory := informers.NewSharedInformerFactory(cs, 2*time.Hour)
return NewFactory(cs, informerFactory), nil
}
func NewFactoryFromConfigWithNamespace(config *rest.Config, namespace string) (*Factory, error) {
if namespace == "" {
return NewFactoryFromConfig(config)
}
cs, err := clientset.NewForConfig(config)
if err != nil {
return nil, err
}
informerFactory := informers.NewSharedInformerFactoryWithOptions(cs, 2*time.Hour, informers.WithNamespace(namespace))
return NewFactory(cs, informerFactory), nil
}
func NewFactory(clientset clientset.Interface, informerFactory informers.SharedInformerFactory) *Factory {
return &Factory{
threadiness: map[schema.GroupVersionKind]int{},
controllerManager: &generic.ControllerManager{},
clientset: clientset,
informerFactory: informerFactory,
}
}
func (c *Factory) SetThreadiness(gvk schema.GroupVersionKind, threadiness int) {
c.threadiness[gvk] = threadiness
}
func (c *Factory) Sync(ctx context.Context) error {
c.informerFactory.Start(ctx.Done())
c.informerFactory.WaitForCacheSync(ctx.Done())
return nil
}
func (c *Factory) Start(ctx context.Context, defaultThreadiness int) error {
if err := c.Sync(ctx); err != nil {
return err
}
return c.controllerManager.Start(ctx, defaultThreadiness, c.threadiness)
}
func (c *Factory) Apiregistration() Interface {
return New(c.controllerManager, c.informerFactory.Apiregistration(), c.clientset)
}

View File

@@ -0,0 +1,50 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package apiregistration
import (
v1 "github.com/rancher/wrangler-api/pkg/generated/controllers/apiregistration.k8s.io/v1"
"github.com/rancher/wrangler/pkg/generic"
clientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset"
informers "k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration"
)
type Interface interface {
V1() v1.Interface
}
type group struct {
controllerManager *generic.ControllerManager
informers informers.Interface
client clientset.Interface
}
// New returns a new Interface.
func New(controllerManager *generic.ControllerManager, informers informers.Interface,
client clientset.Interface) Interface {
return &group{
controllerManager: controllerManager,
informers: informers,
client: client,
}
}
func (g *group) V1() v1.Interface {
return v1.New(g.controllerManager, g.client.ApiregistrationV1(), g.informers.V1())
}

View File

@@ -0,0 +1,242 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
"context"
"github.com/rancher/wrangler/pkg/generic"
"k8s.io/apimachinery/pkg/api/equality"
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"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
clientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1"
informers "k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1"
listers "k8s.io/kube-aggregator/pkg/client/listers/apiregistration/v1"
)
type APIServiceHandler func(string, *v1.APIService) (*v1.APIService, error)
type APIServiceController interface {
APIServiceClient
OnChange(ctx context.Context, name string, sync APIServiceHandler)
OnRemove(ctx context.Context, name string, sync APIServiceHandler)
Enqueue(name string)
Cache() APIServiceCache
Informer() cache.SharedIndexInformer
GroupVersionKind() schema.GroupVersionKind
AddGenericHandler(ctx context.Context, name string, handler generic.Handler)
AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler)
Updater() generic.Updater
}
type APIServiceClient interface {
Create(*v1.APIService) (*v1.APIService, error)
Update(*v1.APIService) (*v1.APIService, error)
UpdateStatus(*v1.APIService) (*v1.APIService, error)
Delete(name string, options *metav1.DeleteOptions) error
Get(name string, options metav1.GetOptions) (*v1.APIService, error)
List(opts metav1.ListOptions) (*v1.APIServiceList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.APIService, err error)
}
type APIServiceCache interface {
Get(name string) (*v1.APIService, error)
List(selector labels.Selector) ([]*v1.APIService, error)
AddIndexer(indexName string, indexer APIServiceIndexer)
GetByIndex(indexName, key string) ([]*v1.APIService, error)
}
type APIServiceIndexer func(obj *v1.APIService) ([]string, error)
type aPIServiceController struct {
controllerManager *generic.ControllerManager
clientGetter clientset.APIServicesGetter
informer informers.APIServiceInformer
gvk schema.GroupVersionKind
}
func NewAPIServiceController(gvk schema.GroupVersionKind, controllerManager *generic.ControllerManager, clientGetter clientset.APIServicesGetter, informer informers.APIServiceInformer) APIServiceController {
return &aPIServiceController{
controllerManager: controllerManager,
clientGetter: clientGetter,
informer: informer,
gvk: gvk,
}
}
func FromAPIServiceHandlerToHandler(sync APIServiceHandler) generic.Handler {
return func(key string, obj runtime.Object) (ret runtime.Object, err error) {
var v *v1.APIService
if obj == nil {
v, err = sync(key, nil)
} else {
v, err = sync(key, obj.(*v1.APIService))
}
if v == nil {
return nil, err
}
return v, err
}
}
func (c *aPIServiceController) Updater() generic.Updater {
return func(obj runtime.Object) (runtime.Object, error) {
newObj, err := c.Update(obj.(*v1.APIService))
if newObj == nil {
return nil, err
}
return newObj, err
}
}
func UpdateAPIServiceOnChange(updater generic.Updater, handler APIServiceHandler) APIServiceHandler {
return func(key string, obj *v1.APIService) (*v1.APIService, error) {
if obj == nil {
return handler(key, nil)
}
copyObj := obj.DeepCopy()
newObj, err := handler(key, copyObj)
if newObj != nil {
copyObj = newObj
}
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
newObj, err := updater(copyObj)
if newObj != nil && err == nil {
copyObj = newObj.(*v1.APIService)
}
}
return copyObj, err
}
}
func (c *aPIServiceController) AddGenericHandler(ctx context.Context, name string, handler generic.Handler) {
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, handler)
}
func (c *aPIServiceController) AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), handler)
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, removeHandler)
}
func (c *aPIServiceController) OnChange(ctx context.Context, name string, sync APIServiceHandler) {
c.AddGenericHandler(ctx, name, FromAPIServiceHandlerToHandler(sync))
}
func (c *aPIServiceController) OnRemove(ctx context.Context, name string, sync APIServiceHandler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), FromAPIServiceHandlerToHandler(sync))
c.AddGenericHandler(ctx, name, removeHandler)
}
func (c *aPIServiceController) Enqueue(name string) {
c.controllerManager.Enqueue(c.gvk, c.informer.Informer(), "", name)
}
func (c *aPIServiceController) Informer() cache.SharedIndexInformer {
return c.informer.Informer()
}
func (c *aPIServiceController) GroupVersionKind() schema.GroupVersionKind {
return c.gvk
}
func (c *aPIServiceController) Cache() APIServiceCache {
return &aPIServiceCache{
lister: c.informer.Lister(),
indexer: c.informer.Informer().GetIndexer(),
}
}
func (c *aPIServiceController) Create(obj *v1.APIService) (*v1.APIService, error) {
return c.clientGetter.APIServices().Create(obj)
}
func (c *aPIServiceController) Update(obj *v1.APIService) (*v1.APIService, error) {
return c.clientGetter.APIServices().Update(obj)
}
func (c *aPIServiceController) UpdateStatus(obj *v1.APIService) (*v1.APIService, error) {
return c.clientGetter.APIServices().UpdateStatus(obj)
}
func (c *aPIServiceController) Delete(name string, options *metav1.DeleteOptions) error {
return c.clientGetter.APIServices().Delete(name, options)
}
func (c *aPIServiceController) Get(name string, options metav1.GetOptions) (*v1.APIService, error) {
return c.clientGetter.APIServices().Get(name, options)
}
func (c *aPIServiceController) List(opts metav1.ListOptions) (*v1.APIServiceList, error) {
return c.clientGetter.APIServices().List(opts)
}
func (c *aPIServiceController) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return c.clientGetter.APIServices().Watch(opts)
}
func (c *aPIServiceController) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.APIService, err error) {
return c.clientGetter.APIServices().Patch(name, pt, data, subresources...)
}
type aPIServiceCache struct {
lister listers.APIServiceLister
indexer cache.Indexer
}
func (c *aPIServiceCache) Get(name string) (*v1.APIService, error) {
return c.lister.Get(name)
}
func (c *aPIServiceCache) List(selector labels.Selector) ([]*v1.APIService, error) {
return c.lister.List(selector)
}
func (c *aPIServiceCache) AddIndexer(indexName string, indexer APIServiceIndexer) {
utilruntime.Must(c.indexer.AddIndexers(map[string]cache.IndexFunc{
indexName: func(obj interface{}) (strings []string, e error) {
return indexer(obj.(*v1.APIService))
},
}))
}
func (c *aPIServiceCache) GetByIndex(indexName, key string) (result []*v1.APIService, err error) {
objs, err := c.indexer.ByIndex(indexName, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
result = append(result, obj.(*v1.APIService))
}
return result, nil
}

View File

@@ -0,0 +1,49 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
"github.com/rancher/wrangler/pkg/generic"
v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
clientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1"
informers "k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1"
)
type Interface interface {
APIService() APIServiceController
}
func New(controllerManager *generic.ControllerManager, client clientset.ApiregistrationV1Interface,
informers informers.Interface) Interface {
return &version{
controllerManager: controllerManager,
client: client,
informers: informers,
}
}
type version struct {
controllerManager *generic.ControllerManager
informers informers.Interface
client clientset.ApiregistrationV1Interface
}
func (c *version) APIService() APIServiceController {
return NewAPIServiceController(v1.SchemeGroupVersion.WithKind("APIService"), c.controllerManager, c.client, c.informers.APIServices())
}

View File

@@ -0,0 +1,107 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package rbac
import (
"context"
"time"
"github.com/rancher/wrangler/pkg/generic"
"github.com/rancher/wrangler/pkg/schemes"
"k8s.io/apimachinery/pkg/runtime/schema"
informers "k8s.io/client-go/informers"
clientset "k8s.io/client-go/kubernetes"
scheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
)
func init() {
scheme.AddToScheme(schemes.All)
}
type Factory struct {
synced bool
informerFactory informers.SharedInformerFactory
clientset clientset.Interface
controllerManager *generic.ControllerManager
threadiness map[schema.GroupVersionKind]int
}
func NewFactoryFromConfigOrDie(config *rest.Config) *Factory {
f, err := NewFactoryFromConfig(config)
if err != nil {
panic(err)
}
return f
}
func NewFactoryFromConfig(config *rest.Config) (*Factory, error) {
cs, err := clientset.NewForConfig(config)
if err != nil {
return nil, err
}
informerFactory := informers.NewSharedInformerFactory(cs, 2*time.Hour)
return NewFactory(cs, informerFactory), nil
}
func NewFactoryFromConfigWithNamespace(config *rest.Config, namespace string) (*Factory, error) {
if namespace == "" {
return NewFactoryFromConfig(config)
}
cs, err := clientset.NewForConfig(config)
if err != nil {
return nil, err
}
informerFactory := informers.NewSharedInformerFactoryWithOptions(cs, 2*time.Hour, informers.WithNamespace(namespace))
return NewFactory(cs, informerFactory), nil
}
func NewFactory(clientset clientset.Interface, informerFactory informers.SharedInformerFactory) *Factory {
return &Factory{
threadiness: map[schema.GroupVersionKind]int{},
controllerManager: &generic.ControllerManager{},
clientset: clientset,
informerFactory: informerFactory,
}
}
func (c *Factory) SetThreadiness(gvk schema.GroupVersionKind, threadiness int) {
c.threadiness[gvk] = threadiness
}
func (c *Factory) Sync(ctx context.Context) error {
c.informerFactory.Start(ctx.Done())
c.informerFactory.WaitForCacheSync(ctx.Done())
return nil
}
func (c *Factory) Start(ctx context.Context, defaultThreadiness int) error {
if err := c.Sync(ctx); err != nil {
return err
}
return c.controllerManager.Start(ctx, defaultThreadiness, c.threadiness)
}
func (c *Factory) Rbac() Interface {
return New(c.controllerManager, c.informerFactory.Rbac(), c.clientset)
}

View File

@@ -0,0 +1,50 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package rbac
import (
v1 "github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1"
"github.com/rancher/wrangler/pkg/generic"
informers "k8s.io/client-go/informers/rbac"
clientset "k8s.io/client-go/kubernetes"
)
type Interface interface {
V1() v1.Interface
}
type group struct {
controllerManager *generic.ControllerManager
informers informers.Interface
client clientset.Interface
}
// New returns a new Interface.
func New(controllerManager *generic.ControllerManager, informers informers.Interface,
client clientset.Interface) Interface {
return &group{
controllerManager: controllerManager,
informers: informers,
client: client,
}
}
func (g *group) V1() v1.Interface {
return v1.New(g.controllerManager, g.client.RbacV1(), g.informers.V1())
}

View File

@@ -0,0 +1,238 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
"context"
"github.com/rancher/wrangler/pkg/generic"
v1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/equality"
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"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/watch"
informers "k8s.io/client-go/informers/rbac/v1"
clientset "k8s.io/client-go/kubernetes/typed/rbac/v1"
listers "k8s.io/client-go/listers/rbac/v1"
"k8s.io/client-go/tools/cache"
)
type ClusterRoleHandler func(string, *v1.ClusterRole) (*v1.ClusterRole, error)
type ClusterRoleController interface {
ClusterRoleClient
OnChange(ctx context.Context, name string, sync ClusterRoleHandler)
OnRemove(ctx context.Context, name string, sync ClusterRoleHandler)
Enqueue(name string)
Cache() ClusterRoleCache
Informer() cache.SharedIndexInformer
GroupVersionKind() schema.GroupVersionKind
AddGenericHandler(ctx context.Context, name string, handler generic.Handler)
AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler)
Updater() generic.Updater
}
type ClusterRoleClient interface {
Create(*v1.ClusterRole) (*v1.ClusterRole, error)
Update(*v1.ClusterRole) (*v1.ClusterRole, error)
Delete(name string, options *metav1.DeleteOptions) error
Get(name string, options metav1.GetOptions) (*v1.ClusterRole, error)
List(opts metav1.ListOptions) (*v1.ClusterRoleList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ClusterRole, err error)
}
type ClusterRoleCache interface {
Get(name string) (*v1.ClusterRole, error)
List(selector labels.Selector) ([]*v1.ClusterRole, error)
AddIndexer(indexName string, indexer ClusterRoleIndexer)
GetByIndex(indexName, key string) ([]*v1.ClusterRole, error)
}
type ClusterRoleIndexer func(obj *v1.ClusterRole) ([]string, error)
type clusterRoleController struct {
controllerManager *generic.ControllerManager
clientGetter clientset.ClusterRolesGetter
informer informers.ClusterRoleInformer
gvk schema.GroupVersionKind
}
func NewClusterRoleController(gvk schema.GroupVersionKind, controllerManager *generic.ControllerManager, clientGetter clientset.ClusterRolesGetter, informer informers.ClusterRoleInformer) ClusterRoleController {
return &clusterRoleController{
controllerManager: controllerManager,
clientGetter: clientGetter,
informer: informer,
gvk: gvk,
}
}
func FromClusterRoleHandlerToHandler(sync ClusterRoleHandler) generic.Handler {
return func(key string, obj runtime.Object) (ret runtime.Object, err error) {
var v *v1.ClusterRole
if obj == nil {
v, err = sync(key, nil)
} else {
v, err = sync(key, obj.(*v1.ClusterRole))
}
if v == nil {
return nil, err
}
return v, err
}
}
func (c *clusterRoleController) Updater() generic.Updater {
return func(obj runtime.Object) (runtime.Object, error) {
newObj, err := c.Update(obj.(*v1.ClusterRole))
if newObj == nil {
return nil, err
}
return newObj, err
}
}
func UpdateClusterRoleOnChange(updater generic.Updater, handler ClusterRoleHandler) ClusterRoleHandler {
return func(key string, obj *v1.ClusterRole) (*v1.ClusterRole, error) {
if obj == nil {
return handler(key, nil)
}
copyObj := obj.DeepCopy()
newObj, err := handler(key, copyObj)
if newObj != nil {
copyObj = newObj
}
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
newObj, err := updater(copyObj)
if newObj != nil && err == nil {
copyObj = newObj.(*v1.ClusterRole)
}
}
return copyObj, err
}
}
func (c *clusterRoleController) AddGenericHandler(ctx context.Context, name string, handler generic.Handler) {
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, handler)
}
func (c *clusterRoleController) AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), handler)
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, removeHandler)
}
func (c *clusterRoleController) OnChange(ctx context.Context, name string, sync ClusterRoleHandler) {
c.AddGenericHandler(ctx, name, FromClusterRoleHandlerToHandler(sync))
}
func (c *clusterRoleController) OnRemove(ctx context.Context, name string, sync ClusterRoleHandler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), FromClusterRoleHandlerToHandler(sync))
c.AddGenericHandler(ctx, name, removeHandler)
}
func (c *clusterRoleController) Enqueue(name string) {
c.controllerManager.Enqueue(c.gvk, c.informer.Informer(), "", name)
}
func (c *clusterRoleController) Informer() cache.SharedIndexInformer {
return c.informer.Informer()
}
func (c *clusterRoleController) GroupVersionKind() schema.GroupVersionKind {
return c.gvk
}
func (c *clusterRoleController) Cache() ClusterRoleCache {
return &clusterRoleCache{
lister: c.informer.Lister(),
indexer: c.informer.Informer().GetIndexer(),
}
}
func (c *clusterRoleController) Create(obj *v1.ClusterRole) (*v1.ClusterRole, error) {
return c.clientGetter.ClusterRoles().Create(obj)
}
func (c *clusterRoleController) Update(obj *v1.ClusterRole) (*v1.ClusterRole, error) {
return c.clientGetter.ClusterRoles().Update(obj)
}
func (c *clusterRoleController) Delete(name string, options *metav1.DeleteOptions) error {
return c.clientGetter.ClusterRoles().Delete(name, options)
}
func (c *clusterRoleController) Get(name string, options metav1.GetOptions) (*v1.ClusterRole, error) {
return c.clientGetter.ClusterRoles().Get(name, options)
}
func (c *clusterRoleController) List(opts metav1.ListOptions) (*v1.ClusterRoleList, error) {
return c.clientGetter.ClusterRoles().List(opts)
}
func (c *clusterRoleController) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return c.clientGetter.ClusterRoles().Watch(opts)
}
func (c *clusterRoleController) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ClusterRole, err error) {
return c.clientGetter.ClusterRoles().Patch(name, pt, data, subresources...)
}
type clusterRoleCache struct {
lister listers.ClusterRoleLister
indexer cache.Indexer
}
func (c *clusterRoleCache) Get(name string) (*v1.ClusterRole, error) {
return c.lister.Get(name)
}
func (c *clusterRoleCache) List(selector labels.Selector) ([]*v1.ClusterRole, error) {
return c.lister.List(selector)
}
func (c *clusterRoleCache) AddIndexer(indexName string, indexer ClusterRoleIndexer) {
utilruntime.Must(c.indexer.AddIndexers(map[string]cache.IndexFunc{
indexName: func(obj interface{}) (strings []string, e error) {
return indexer(obj.(*v1.ClusterRole))
},
}))
}
func (c *clusterRoleCache) GetByIndex(indexName, key string) (result []*v1.ClusterRole, err error) {
objs, err := c.indexer.ByIndex(indexName, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
result = append(result, obj.(*v1.ClusterRole))
}
return result, nil
}

View File

@@ -0,0 +1,238 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
"context"
"github.com/rancher/wrangler/pkg/generic"
v1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/equality"
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"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/watch"
informers "k8s.io/client-go/informers/rbac/v1"
clientset "k8s.io/client-go/kubernetes/typed/rbac/v1"
listers "k8s.io/client-go/listers/rbac/v1"
"k8s.io/client-go/tools/cache"
)
type ClusterRoleBindingHandler func(string, *v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error)
type ClusterRoleBindingController interface {
ClusterRoleBindingClient
OnChange(ctx context.Context, name string, sync ClusterRoleBindingHandler)
OnRemove(ctx context.Context, name string, sync ClusterRoleBindingHandler)
Enqueue(name string)
Cache() ClusterRoleBindingCache
Informer() cache.SharedIndexInformer
GroupVersionKind() schema.GroupVersionKind
AddGenericHandler(ctx context.Context, name string, handler generic.Handler)
AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler)
Updater() generic.Updater
}
type ClusterRoleBindingClient interface {
Create(*v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error)
Update(*v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error)
Delete(name string, options *metav1.DeleteOptions) error
Get(name string, options metav1.GetOptions) (*v1.ClusterRoleBinding, error)
List(opts metav1.ListOptions) (*v1.ClusterRoleBindingList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ClusterRoleBinding, err error)
}
type ClusterRoleBindingCache interface {
Get(name string) (*v1.ClusterRoleBinding, error)
List(selector labels.Selector) ([]*v1.ClusterRoleBinding, error)
AddIndexer(indexName string, indexer ClusterRoleBindingIndexer)
GetByIndex(indexName, key string) ([]*v1.ClusterRoleBinding, error)
}
type ClusterRoleBindingIndexer func(obj *v1.ClusterRoleBinding) ([]string, error)
type clusterRoleBindingController struct {
controllerManager *generic.ControllerManager
clientGetter clientset.ClusterRoleBindingsGetter
informer informers.ClusterRoleBindingInformer
gvk schema.GroupVersionKind
}
func NewClusterRoleBindingController(gvk schema.GroupVersionKind, controllerManager *generic.ControllerManager, clientGetter clientset.ClusterRoleBindingsGetter, informer informers.ClusterRoleBindingInformer) ClusterRoleBindingController {
return &clusterRoleBindingController{
controllerManager: controllerManager,
clientGetter: clientGetter,
informer: informer,
gvk: gvk,
}
}
func FromClusterRoleBindingHandlerToHandler(sync ClusterRoleBindingHandler) generic.Handler {
return func(key string, obj runtime.Object) (ret runtime.Object, err error) {
var v *v1.ClusterRoleBinding
if obj == nil {
v, err = sync(key, nil)
} else {
v, err = sync(key, obj.(*v1.ClusterRoleBinding))
}
if v == nil {
return nil, err
}
return v, err
}
}
func (c *clusterRoleBindingController) Updater() generic.Updater {
return func(obj runtime.Object) (runtime.Object, error) {
newObj, err := c.Update(obj.(*v1.ClusterRoleBinding))
if newObj == nil {
return nil, err
}
return newObj, err
}
}
func UpdateClusterRoleBindingOnChange(updater generic.Updater, handler ClusterRoleBindingHandler) ClusterRoleBindingHandler {
return func(key string, obj *v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error) {
if obj == nil {
return handler(key, nil)
}
copyObj := obj.DeepCopy()
newObj, err := handler(key, copyObj)
if newObj != nil {
copyObj = newObj
}
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
newObj, err := updater(copyObj)
if newObj != nil && err == nil {
copyObj = newObj.(*v1.ClusterRoleBinding)
}
}
return copyObj, err
}
}
func (c *clusterRoleBindingController) AddGenericHandler(ctx context.Context, name string, handler generic.Handler) {
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, handler)
}
func (c *clusterRoleBindingController) AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), handler)
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, removeHandler)
}
func (c *clusterRoleBindingController) OnChange(ctx context.Context, name string, sync ClusterRoleBindingHandler) {
c.AddGenericHandler(ctx, name, FromClusterRoleBindingHandlerToHandler(sync))
}
func (c *clusterRoleBindingController) OnRemove(ctx context.Context, name string, sync ClusterRoleBindingHandler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), FromClusterRoleBindingHandlerToHandler(sync))
c.AddGenericHandler(ctx, name, removeHandler)
}
func (c *clusterRoleBindingController) Enqueue(name string) {
c.controllerManager.Enqueue(c.gvk, c.informer.Informer(), "", name)
}
func (c *clusterRoleBindingController) Informer() cache.SharedIndexInformer {
return c.informer.Informer()
}
func (c *clusterRoleBindingController) GroupVersionKind() schema.GroupVersionKind {
return c.gvk
}
func (c *clusterRoleBindingController) Cache() ClusterRoleBindingCache {
return &clusterRoleBindingCache{
lister: c.informer.Lister(),
indexer: c.informer.Informer().GetIndexer(),
}
}
func (c *clusterRoleBindingController) Create(obj *v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error) {
return c.clientGetter.ClusterRoleBindings().Create(obj)
}
func (c *clusterRoleBindingController) Update(obj *v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error) {
return c.clientGetter.ClusterRoleBindings().Update(obj)
}
func (c *clusterRoleBindingController) Delete(name string, options *metav1.DeleteOptions) error {
return c.clientGetter.ClusterRoleBindings().Delete(name, options)
}
func (c *clusterRoleBindingController) Get(name string, options metav1.GetOptions) (*v1.ClusterRoleBinding, error) {
return c.clientGetter.ClusterRoleBindings().Get(name, options)
}
func (c *clusterRoleBindingController) List(opts metav1.ListOptions) (*v1.ClusterRoleBindingList, error) {
return c.clientGetter.ClusterRoleBindings().List(opts)
}
func (c *clusterRoleBindingController) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return c.clientGetter.ClusterRoleBindings().Watch(opts)
}
func (c *clusterRoleBindingController) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ClusterRoleBinding, err error) {
return c.clientGetter.ClusterRoleBindings().Patch(name, pt, data, subresources...)
}
type clusterRoleBindingCache struct {
lister listers.ClusterRoleBindingLister
indexer cache.Indexer
}
func (c *clusterRoleBindingCache) Get(name string) (*v1.ClusterRoleBinding, error) {
return c.lister.Get(name)
}
func (c *clusterRoleBindingCache) List(selector labels.Selector) ([]*v1.ClusterRoleBinding, error) {
return c.lister.List(selector)
}
func (c *clusterRoleBindingCache) AddIndexer(indexName string, indexer ClusterRoleBindingIndexer) {
utilruntime.Must(c.indexer.AddIndexers(map[string]cache.IndexFunc{
indexName: func(obj interface{}) (strings []string, e error) {
return indexer(obj.(*v1.ClusterRoleBinding))
},
}))
}
func (c *clusterRoleBindingCache) GetByIndex(indexName, key string) (result []*v1.ClusterRoleBinding, err error) {
objs, err := c.indexer.ByIndex(indexName, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
result = append(result, obj.(*v1.ClusterRoleBinding))
}
return result, nil
}

View File

@@ -0,0 +1,61 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
"github.com/rancher/wrangler/pkg/generic"
v1 "k8s.io/api/rbac/v1"
informers "k8s.io/client-go/informers/rbac/v1"
clientset "k8s.io/client-go/kubernetes/typed/rbac/v1"
)
type Interface interface {
ClusterRole() ClusterRoleController
ClusterRoleBinding() ClusterRoleBindingController
Role() RoleController
RoleBinding() RoleBindingController
}
func New(controllerManager *generic.ControllerManager, client clientset.RbacV1Interface,
informers informers.Interface) Interface {
return &version{
controllerManager: controllerManager,
client: client,
informers: informers,
}
}
type version struct {
controllerManager *generic.ControllerManager
informers informers.Interface
client clientset.RbacV1Interface
}
func (c *version) ClusterRole() ClusterRoleController {
return NewClusterRoleController(v1.SchemeGroupVersion.WithKind("ClusterRole"), c.controllerManager, c.client, c.informers.ClusterRoles())
}
func (c *version) ClusterRoleBinding() ClusterRoleBindingController {
return NewClusterRoleBindingController(v1.SchemeGroupVersion.WithKind("ClusterRoleBinding"), c.controllerManager, c.client, c.informers.ClusterRoleBindings())
}
func (c *version) Role() RoleController {
return NewRoleController(v1.SchemeGroupVersion.WithKind("Role"), c.controllerManager, c.client, c.informers.Roles())
}
func (c *version) RoleBinding() RoleBindingController {
return NewRoleBindingController(v1.SchemeGroupVersion.WithKind("RoleBinding"), c.controllerManager, c.client, c.informers.RoleBindings())
}

View File

@@ -0,0 +1,238 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
"context"
"github.com/rancher/wrangler/pkg/generic"
v1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/equality"
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"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/watch"
informers "k8s.io/client-go/informers/rbac/v1"
clientset "k8s.io/client-go/kubernetes/typed/rbac/v1"
listers "k8s.io/client-go/listers/rbac/v1"
"k8s.io/client-go/tools/cache"
)
type RoleHandler func(string, *v1.Role) (*v1.Role, error)
type RoleController interface {
RoleClient
OnChange(ctx context.Context, name string, sync RoleHandler)
OnRemove(ctx context.Context, name string, sync RoleHandler)
Enqueue(namespace, name string)
Cache() RoleCache
Informer() cache.SharedIndexInformer
GroupVersionKind() schema.GroupVersionKind
AddGenericHandler(ctx context.Context, name string, handler generic.Handler)
AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler)
Updater() generic.Updater
}
type RoleClient interface {
Create(*v1.Role) (*v1.Role, error)
Update(*v1.Role) (*v1.Role, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
Get(namespace, name string, options metav1.GetOptions) (*v1.Role, error)
List(namespace string, opts metav1.ListOptions) (*v1.RoleList, error)
Watch(namespace string, opts metav1.ListOptions) (watch.Interface, error)
Patch(namespace, name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Role, err error)
}
type RoleCache interface {
Get(namespace, name string) (*v1.Role, error)
List(namespace string, selector labels.Selector) ([]*v1.Role, error)
AddIndexer(indexName string, indexer RoleIndexer)
GetByIndex(indexName, key string) ([]*v1.Role, error)
}
type RoleIndexer func(obj *v1.Role) ([]string, error)
type roleController struct {
controllerManager *generic.ControllerManager
clientGetter clientset.RolesGetter
informer informers.RoleInformer
gvk schema.GroupVersionKind
}
func NewRoleController(gvk schema.GroupVersionKind, controllerManager *generic.ControllerManager, clientGetter clientset.RolesGetter, informer informers.RoleInformer) RoleController {
return &roleController{
controllerManager: controllerManager,
clientGetter: clientGetter,
informer: informer,
gvk: gvk,
}
}
func FromRoleHandlerToHandler(sync RoleHandler) generic.Handler {
return func(key string, obj runtime.Object) (ret runtime.Object, err error) {
var v *v1.Role
if obj == nil {
v, err = sync(key, nil)
} else {
v, err = sync(key, obj.(*v1.Role))
}
if v == nil {
return nil, err
}
return v, err
}
}
func (c *roleController) Updater() generic.Updater {
return func(obj runtime.Object) (runtime.Object, error) {
newObj, err := c.Update(obj.(*v1.Role))
if newObj == nil {
return nil, err
}
return newObj, err
}
}
func UpdateRoleOnChange(updater generic.Updater, handler RoleHandler) RoleHandler {
return func(key string, obj *v1.Role) (*v1.Role, error) {
if obj == nil {
return handler(key, nil)
}
copyObj := obj.DeepCopy()
newObj, err := handler(key, copyObj)
if newObj != nil {
copyObj = newObj
}
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
newObj, err := updater(copyObj)
if newObj != nil && err == nil {
copyObj = newObj.(*v1.Role)
}
}
return copyObj, err
}
}
func (c *roleController) AddGenericHandler(ctx context.Context, name string, handler generic.Handler) {
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, handler)
}
func (c *roleController) AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), handler)
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, removeHandler)
}
func (c *roleController) OnChange(ctx context.Context, name string, sync RoleHandler) {
c.AddGenericHandler(ctx, name, FromRoleHandlerToHandler(sync))
}
func (c *roleController) OnRemove(ctx context.Context, name string, sync RoleHandler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), FromRoleHandlerToHandler(sync))
c.AddGenericHandler(ctx, name, removeHandler)
}
func (c *roleController) Enqueue(namespace, name string) {
c.controllerManager.Enqueue(c.gvk, c.informer.Informer(), namespace, name)
}
func (c *roleController) Informer() cache.SharedIndexInformer {
return c.informer.Informer()
}
func (c *roleController) GroupVersionKind() schema.GroupVersionKind {
return c.gvk
}
func (c *roleController) Cache() RoleCache {
return &roleCache{
lister: c.informer.Lister(),
indexer: c.informer.Informer().GetIndexer(),
}
}
func (c *roleController) Create(obj *v1.Role) (*v1.Role, error) {
return c.clientGetter.Roles(obj.Namespace).Create(obj)
}
func (c *roleController) Update(obj *v1.Role) (*v1.Role, error) {
return c.clientGetter.Roles(obj.Namespace).Update(obj)
}
func (c *roleController) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return c.clientGetter.Roles(namespace).Delete(name, options)
}
func (c *roleController) Get(namespace, name string, options metav1.GetOptions) (*v1.Role, error) {
return c.clientGetter.Roles(namespace).Get(name, options)
}
func (c *roleController) List(namespace string, opts metav1.ListOptions) (*v1.RoleList, error) {
return c.clientGetter.Roles(namespace).List(opts)
}
func (c *roleController) Watch(namespace string, opts metav1.ListOptions) (watch.Interface, error) {
return c.clientGetter.Roles(namespace).Watch(opts)
}
func (c *roleController) Patch(namespace, name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Role, err error) {
return c.clientGetter.Roles(namespace).Patch(name, pt, data, subresources...)
}
type roleCache struct {
lister listers.RoleLister
indexer cache.Indexer
}
func (c *roleCache) Get(namespace, name string) (*v1.Role, error) {
return c.lister.Roles(namespace).Get(name)
}
func (c *roleCache) List(namespace string, selector labels.Selector) ([]*v1.Role, error) {
return c.lister.Roles(namespace).List(selector)
}
func (c *roleCache) AddIndexer(indexName string, indexer RoleIndexer) {
utilruntime.Must(c.indexer.AddIndexers(map[string]cache.IndexFunc{
indexName: func(obj interface{}) (strings []string, e error) {
return indexer(obj.(*v1.Role))
},
}))
}
func (c *roleCache) GetByIndex(indexName, key string) (result []*v1.Role, err error) {
objs, err := c.indexer.ByIndex(indexName, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
result = append(result, obj.(*v1.Role))
}
return result, nil
}

View File

@@ -0,0 +1,238 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by main. DO NOT EDIT.
package v1
import (
"context"
"github.com/rancher/wrangler/pkg/generic"
v1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/equality"
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"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/watch"
informers "k8s.io/client-go/informers/rbac/v1"
clientset "k8s.io/client-go/kubernetes/typed/rbac/v1"
listers "k8s.io/client-go/listers/rbac/v1"
"k8s.io/client-go/tools/cache"
)
type RoleBindingHandler func(string, *v1.RoleBinding) (*v1.RoleBinding, error)
type RoleBindingController interface {
RoleBindingClient
OnChange(ctx context.Context, name string, sync RoleBindingHandler)
OnRemove(ctx context.Context, name string, sync RoleBindingHandler)
Enqueue(namespace, name string)
Cache() RoleBindingCache
Informer() cache.SharedIndexInformer
GroupVersionKind() schema.GroupVersionKind
AddGenericHandler(ctx context.Context, name string, handler generic.Handler)
AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler)
Updater() generic.Updater
}
type RoleBindingClient interface {
Create(*v1.RoleBinding) (*v1.RoleBinding, error)
Update(*v1.RoleBinding) (*v1.RoleBinding, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
Get(namespace, name string, options metav1.GetOptions) (*v1.RoleBinding, error)
List(namespace string, opts metav1.ListOptions) (*v1.RoleBindingList, error)
Watch(namespace string, opts metav1.ListOptions) (watch.Interface, error)
Patch(namespace, name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.RoleBinding, err error)
}
type RoleBindingCache interface {
Get(namespace, name string) (*v1.RoleBinding, error)
List(namespace string, selector labels.Selector) ([]*v1.RoleBinding, error)
AddIndexer(indexName string, indexer RoleBindingIndexer)
GetByIndex(indexName, key string) ([]*v1.RoleBinding, error)
}
type RoleBindingIndexer func(obj *v1.RoleBinding) ([]string, error)
type roleBindingController struct {
controllerManager *generic.ControllerManager
clientGetter clientset.RoleBindingsGetter
informer informers.RoleBindingInformer
gvk schema.GroupVersionKind
}
func NewRoleBindingController(gvk schema.GroupVersionKind, controllerManager *generic.ControllerManager, clientGetter clientset.RoleBindingsGetter, informer informers.RoleBindingInformer) RoleBindingController {
return &roleBindingController{
controllerManager: controllerManager,
clientGetter: clientGetter,
informer: informer,
gvk: gvk,
}
}
func FromRoleBindingHandlerToHandler(sync RoleBindingHandler) generic.Handler {
return func(key string, obj runtime.Object) (ret runtime.Object, err error) {
var v *v1.RoleBinding
if obj == nil {
v, err = sync(key, nil)
} else {
v, err = sync(key, obj.(*v1.RoleBinding))
}
if v == nil {
return nil, err
}
return v, err
}
}
func (c *roleBindingController) Updater() generic.Updater {
return func(obj runtime.Object) (runtime.Object, error) {
newObj, err := c.Update(obj.(*v1.RoleBinding))
if newObj == nil {
return nil, err
}
return newObj, err
}
}
func UpdateRoleBindingOnChange(updater generic.Updater, handler RoleBindingHandler) RoleBindingHandler {
return func(key string, obj *v1.RoleBinding) (*v1.RoleBinding, error) {
if obj == nil {
return handler(key, nil)
}
copyObj := obj.DeepCopy()
newObj, err := handler(key, copyObj)
if newObj != nil {
copyObj = newObj
}
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
newObj, err := updater(copyObj)
if newObj != nil && err == nil {
copyObj = newObj.(*v1.RoleBinding)
}
}
return copyObj, err
}
}
func (c *roleBindingController) AddGenericHandler(ctx context.Context, name string, handler generic.Handler) {
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, handler)
}
func (c *roleBindingController) AddGenericRemoveHandler(ctx context.Context, name string, handler generic.Handler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), handler)
c.controllerManager.AddHandler(ctx, c.gvk, c.informer.Informer(), name, removeHandler)
}
func (c *roleBindingController) OnChange(ctx context.Context, name string, sync RoleBindingHandler) {
c.AddGenericHandler(ctx, name, FromRoleBindingHandlerToHandler(sync))
}
func (c *roleBindingController) OnRemove(ctx context.Context, name string, sync RoleBindingHandler) {
removeHandler := generic.NewRemoveHandler(name, c.Updater(), FromRoleBindingHandlerToHandler(sync))
c.AddGenericHandler(ctx, name, removeHandler)
}
func (c *roleBindingController) Enqueue(namespace, name string) {
c.controllerManager.Enqueue(c.gvk, c.informer.Informer(), namespace, name)
}
func (c *roleBindingController) Informer() cache.SharedIndexInformer {
return c.informer.Informer()
}
func (c *roleBindingController) GroupVersionKind() schema.GroupVersionKind {
return c.gvk
}
func (c *roleBindingController) Cache() RoleBindingCache {
return &roleBindingCache{
lister: c.informer.Lister(),
indexer: c.informer.Informer().GetIndexer(),
}
}
func (c *roleBindingController) Create(obj *v1.RoleBinding) (*v1.RoleBinding, error) {
return c.clientGetter.RoleBindings(obj.Namespace).Create(obj)
}
func (c *roleBindingController) Update(obj *v1.RoleBinding) (*v1.RoleBinding, error) {
return c.clientGetter.RoleBindings(obj.Namespace).Update(obj)
}
func (c *roleBindingController) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return c.clientGetter.RoleBindings(namespace).Delete(name, options)
}
func (c *roleBindingController) Get(namespace, name string, options metav1.GetOptions) (*v1.RoleBinding, error) {
return c.clientGetter.RoleBindings(namespace).Get(name, options)
}
func (c *roleBindingController) List(namespace string, opts metav1.ListOptions) (*v1.RoleBindingList, error) {
return c.clientGetter.RoleBindings(namespace).List(opts)
}
func (c *roleBindingController) Watch(namespace string, opts metav1.ListOptions) (watch.Interface, error) {
return c.clientGetter.RoleBindings(namespace).Watch(opts)
}
func (c *roleBindingController) Patch(namespace, name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.RoleBinding, err error) {
return c.clientGetter.RoleBindings(namespace).Patch(name, pt, data, subresources...)
}
type roleBindingCache struct {
lister listers.RoleBindingLister
indexer cache.Indexer
}
func (c *roleBindingCache) Get(namespace, name string) (*v1.RoleBinding, error) {
return c.lister.RoleBindings(namespace).Get(name)
}
func (c *roleBindingCache) List(namespace string, selector labels.Selector) ([]*v1.RoleBinding, error) {
return c.lister.RoleBindings(namespace).List(selector)
}
func (c *roleBindingCache) AddIndexer(indexName string, indexer RoleBindingIndexer) {
utilruntime.Must(c.indexer.AddIndexers(map[string]cache.IndexFunc{
indexName: func(obj interface{}) (strings []string, e error) {
return indexer(obj.(*v1.RoleBinding))
},
}))
}
func (c *roleBindingCache) GetByIndex(indexName, key string) (result []*v1.RoleBinding, err error) {
objs, err := c.indexer.ByIndex(indexName, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
result = append(result, obj.(*v1.RoleBinding))
}
return result, nil
}