mirror of
https://github.com/rancher/types.git
synced 2025-08-31 21:00:16 +00:00
Update vendor
This commit is contained in:
1
vendor/github.com/konsorten/go-windows-terminal-sequences/README.md
generated
vendored
1
vendor/github.com/konsorten/go-windows-terminal-sequences/README.md
generated
vendored
@@ -26,6 +26,7 @@ The tool is sponsored by the [marvin + konsorten GmbH](http://www.konsorten.de).
|
||||
We thank all the authors who provided code to this library:
|
||||
|
||||
* Felix Kollmann
|
||||
* Nicolas Perraut
|
||||
|
||||
## License
|
||||
|
||||
|
11
vendor/github.com/konsorten/go-windows-terminal-sequences/sequences_dummy.go
generated
vendored
Normal file
11
vendor/github.com/konsorten/go-windows-terminal-sequences/sequences_dummy.go
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// +build linux darwin
|
||||
|
||||
package sequences
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func EnableVirtualTerminalProcessing(stream uintptr, enable bool) error {
|
||||
return fmt.Errorf("windows only package")
|
||||
}
|
177
vendor/github.com/rancher/wrangler-api/LICENSE
generated
vendored
Normal file
177
vendor/github.com/rancher/wrangler-api/LICENSE
generated
vendored
Normal 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
|
111
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/factory.go
generated
vendored
Normal file
111
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/factory.go
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
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) Controllers() map[schema.GroupVersionKind]*generic.Controller {
|
||||
return c.controllerManager.Controllers()
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
50
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/interface.go
generated
vendored
Normal file
50
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/interface.go
generated
vendored
Normal 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())
|
||||
}
|
234
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/clusterrole.go
generated
vendored
Normal file
234
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/clusterrole.go
generated
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
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"
|
||||
"time"
|
||||
|
||||
"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 {
|
||||
generic.ControllerMeta
|
||||
ClusterRoleClient
|
||||
|
||||
OnChange(ctx context.Context, name string, sync ClusterRoleHandler)
|
||||
OnRemove(ctx context.Context, name string, sync ClusterRoleHandler)
|
||||
Enqueue(name string)
|
||||
EnqueueAfter(name string, duration time.Duration)
|
||||
|
||||
Cache() ClusterRoleCache
|
||||
}
|
||||
|
||||
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 UpdateClusterRoleDeepCopyOnChange(client ClusterRoleClient, obj *v1.ClusterRole, handler func(obj *v1.ClusterRole) (*v1.ClusterRole, error)) (*v1.ClusterRole, error) {
|
||||
if obj == nil {
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
copyObj := obj.DeepCopy()
|
||||
newObj, err := handler(copyObj)
|
||||
if newObj != nil {
|
||||
copyObj = newObj
|
||||
}
|
||||
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
|
||||
return client.Update(copyObj)
|
||||
}
|
||||
|
||||
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) EnqueueAfter(name string, duration time.Duration) {
|
||||
c.controllerManager.EnqueueAfter(c.gvk, c.informer.Informer(), "", name, duration)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
result = make([]*v1.ClusterRole, 0, len(objs))
|
||||
for _, obj := range objs {
|
||||
result = append(result, obj.(*v1.ClusterRole))
|
||||
}
|
||||
return result, nil
|
||||
}
|
234
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/clusterrolebinding.go
generated
vendored
Normal file
234
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/clusterrolebinding.go
generated
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
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"
|
||||
"time"
|
||||
|
||||
"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 {
|
||||
generic.ControllerMeta
|
||||
ClusterRoleBindingClient
|
||||
|
||||
OnChange(ctx context.Context, name string, sync ClusterRoleBindingHandler)
|
||||
OnRemove(ctx context.Context, name string, sync ClusterRoleBindingHandler)
|
||||
Enqueue(name string)
|
||||
EnqueueAfter(name string, duration time.Duration)
|
||||
|
||||
Cache() ClusterRoleBindingCache
|
||||
}
|
||||
|
||||
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 UpdateClusterRoleBindingDeepCopyOnChange(client ClusterRoleBindingClient, obj *v1.ClusterRoleBinding, handler func(obj *v1.ClusterRoleBinding) (*v1.ClusterRoleBinding, error)) (*v1.ClusterRoleBinding, error) {
|
||||
if obj == nil {
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
copyObj := obj.DeepCopy()
|
||||
newObj, err := handler(copyObj)
|
||||
if newObj != nil {
|
||||
copyObj = newObj
|
||||
}
|
||||
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
|
||||
return client.Update(copyObj)
|
||||
}
|
||||
|
||||
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) EnqueueAfter(name string, duration time.Duration) {
|
||||
c.controllerManager.EnqueueAfter(c.gvk, c.informer.Informer(), "", name, duration)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
result = make([]*v1.ClusterRoleBinding, 0, len(objs))
|
||||
for _, obj := range objs {
|
||||
result = append(result, obj.(*v1.ClusterRoleBinding))
|
||||
}
|
||||
return result, nil
|
||||
}
|
61
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/interface.go
generated
vendored
Normal file
61
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/interface.go
generated
vendored
Normal 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())
|
||||
}
|
234
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/role.go
generated
vendored
Normal file
234
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/role.go
generated
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
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"
|
||||
"time"
|
||||
|
||||
"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 {
|
||||
generic.ControllerMeta
|
||||
RoleClient
|
||||
|
||||
OnChange(ctx context.Context, name string, sync RoleHandler)
|
||||
OnRemove(ctx context.Context, name string, sync RoleHandler)
|
||||
Enqueue(namespace, name string)
|
||||
EnqueueAfter(namespace, name string, duration time.Duration)
|
||||
|
||||
Cache() RoleCache
|
||||
}
|
||||
|
||||
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 UpdateRoleDeepCopyOnChange(client RoleClient, obj *v1.Role, handler func(obj *v1.Role) (*v1.Role, error)) (*v1.Role, error) {
|
||||
if obj == nil {
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
copyObj := obj.DeepCopy()
|
||||
newObj, err := handler(copyObj)
|
||||
if newObj != nil {
|
||||
copyObj = newObj
|
||||
}
|
||||
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
|
||||
return client.Update(copyObj)
|
||||
}
|
||||
|
||||
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) EnqueueAfter(namespace, name string, duration time.Duration) {
|
||||
c.controllerManager.EnqueueAfter(c.gvk, c.informer.Informer(), namespace, name, duration)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
result = make([]*v1.Role, 0, len(objs))
|
||||
for _, obj := range objs {
|
||||
result = append(result, obj.(*v1.Role))
|
||||
}
|
||||
return result, nil
|
||||
}
|
234
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/rolebinding.go
generated
vendored
Normal file
234
vendor/github.com/rancher/wrangler-api/pkg/generated/controllers/rbac/v1/rolebinding.go
generated
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
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"
|
||||
"time"
|
||||
|
||||
"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 {
|
||||
generic.ControllerMeta
|
||||
RoleBindingClient
|
||||
|
||||
OnChange(ctx context.Context, name string, sync RoleBindingHandler)
|
||||
OnRemove(ctx context.Context, name string, sync RoleBindingHandler)
|
||||
Enqueue(namespace, name string)
|
||||
EnqueueAfter(namespace, name string, duration time.Duration)
|
||||
|
||||
Cache() RoleBindingCache
|
||||
}
|
||||
|
||||
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 UpdateRoleBindingDeepCopyOnChange(client RoleBindingClient, obj *v1.RoleBinding, handler func(obj *v1.RoleBinding) (*v1.RoleBinding, error)) (*v1.RoleBinding, error) {
|
||||
if obj == nil {
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
copyObj := obj.DeepCopy()
|
||||
newObj, err := handler(copyObj)
|
||||
if newObj != nil {
|
||||
copyObj = newObj
|
||||
}
|
||||
if obj.ResourceVersion == copyObj.ResourceVersion && !equality.Semantic.DeepEqual(obj, copyObj) {
|
||||
return client.Update(copyObj)
|
||||
}
|
||||
|
||||
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) EnqueueAfter(namespace, name string, duration time.Duration) {
|
||||
c.controllerManager.EnqueueAfter(c.gvk, c.informer.Informer(), namespace, name, duration)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
result = make([]*v1.RoleBinding, 0, len(objs))
|
||||
for _, obj := range objs {
|
||||
result = append(result, obj.(*v1.RoleBinding))
|
||||
}
|
||||
return result, nil
|
||||
}
|
219
vendor/github.com/rancher/wrangler/pkg/generic/controller.go
generated
vendored
Normal file
219
vendor/github.com/rancher/wrangler/pkg/generic/controller.go
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
Copyright 2017 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.
|
||||
*/
|
||||
|
||||
package generic
|
||||
|
||||
import (
|
||||
"context"
|
||||
errors2 "errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
errors3 "github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
)
|
||||
|
||||
var ErrSkip = errors2.New("skip processing")
|
||||
|
||||
type Handler func(key string, obj runtime.Object) (runtime.Object, error)
|
||||
|
||||
// Controller is the controller implementation for Foo resources
|
||||
type Controller struct {
|
||||
name string
|
||||
workqueue workqueue.RateLimitingInterface
|
||||
informer cache.SharedIndexInformer
|
||||
handler Handler
|
||||
gvk schema.GroupVersionKind
|
||||
}
|
||||
|
||||
type ControllerMeta interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
GroupVersionKind() schema.GroupVersionKind
|
||||
|
||||
AddGenericHandler(ctx context.Context, name string, handler Handler)
|
||||
AddGenericRemoveHandler(ctx context.Context, name string, handler Handler)
|
||||
Updater() Updater
|
||||
}
|
||||
|
||||
// NewController returns a new sample controller
|
||||
func NewController(gvk schema.GroupVersionKind, informer cache.SharedIndexInformer, workqueue workqueue.RateLimitingInterface, handler Handler) *Controller {
|
||||
controller := &Controller{
|
||||
name: gvk.String(),
|
||||
handler: handler,
|
||||
informer: informer,
|
||||
workqueue: workqueue,
|
||||
}
|
||||
|
||||
informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: controller.handleObject,
|
||||
UpdateFunc: func(old, new interface{}) {
|
||||
newMeta, err := meta.Accessor(new)
|
||||
utilruntime.Must(err)
|
||||
oldMeta, err := meta.Accessor(old)
|
||||
utilruntime.Must(err)
|
||||
if newMeta.GetResourceVersion() == oldMeta.GetResourceVersion() {
|
||||
return
|
||||
}
|
||||
controller.handleObject(new)
|
||||
},
|
||||
DeleteFunc: controller.handleObject,
|
||||
})
|
||||
|
||||
return controller
|
||||
}
|
||||
|
||||
func (c *Controller) Informer() cache.SharedIndexInformer {
|
||||
return c.informer
|
||||
}
|
||||
|
||||
func (c *Controller) GroupVersionKind() schema.GroupVersionKind {
|
||||
return c.gvk
|
||||
}
|
||||
|
||||
func (c *Controller) run(threadiness int, stopCh <-chan struct{}) {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer c.workqueue.ShutDown()
|
||||
|
||||
// Start the informer factories to begin populating the informer caches
|
||||
logrus.Infof("Starting %s controller", c.name)
|
||||
|
||||
// Launch two workers to process Foo resources
|
||||
for i := 0; i < threadiness; i++ {
|
||||
go wait.Until(c.runWorker, time.Second, stopCh)
|
||||
}
|
||||
|
||||
<-stopCh
|
||||
logrus.Infof("Shutting down %s workers", c.name)
|
||||
}
|
||||
|
||||
func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {
|
||||
if ok := cache.WaitForCacheSync(stopCh, c.informer.HasSynced); !ok {
|
||||
c.workqueue.ShutDown()
|
||||
return fmt.Errorf("failed to wait for caches to sync")
|
||||
}
|
||||
|
||||
go c.run(threadiness, stopCh)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Controller) runWorker() {
|
||||
for c.processNextWorkItem() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Controller) processNextWorkItem() bool {
|
||||
obj, shutdown := c.workqueue.Get()
|
||||
|
||||
if shutdown {
|
||||
return false
|
||||
}
|
||||
|
||||
if err := c.processSingleItem(obj); err != nil {
|
||||
if !strings.Contains(err.Error(), "please apply your changes to the latest version and try again") {
|
||||
utilruntime.HandleError(err)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *Controller) processSingleItem(obj interface{}) error {
|
||||
var (
|
||||
key string
|
||||
ok bool
|
||||
)
|
||||
|
||||
defer c.workqueue.Done(obj)
|
||||
|
||||
if key, ok = obj.(string); !ok {
|
||||
c.workqueue.Forget(obj)
|
||||
utilruntime.HandleError(fmt.Errorf("expected string in workqueue but got %#v", obj))
|
||||
return nil
|
||||
}
|
||||
if err := c.syncHandler(key); err != nil && errors3.Cause(err) != ErrSkip {
|
||||
c.workqueue.AddRateLimited(key)
|
||||
return fmt.Errorf("error syncing '%s': %s, requeuing", key, err.Error())
|
||||
}
|
||||
|
||||
c.workqueue.Forget(obj)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Controller) syncHandler(key string) error {
|
||||
obj, exists, err := c.informer.GetStore().GetByKey(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
_, err := c.handler(key, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = c.handler(key, obj.(runtime.Object))
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Controller) Enqueue(namespace, name string) {
|
||||
if namespace == "" {
|
||||
c.workqueue.AddRateLimited(name)
|
||||
} else {
|
||||
c.workqueue.AddRateLimited(namespace + "/" + name)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Controller) EnqueueAfter(namespace, name string, duration time.Duration) {
|
||||
if namespace == "" {
|
||||
c.workqueue.AddAfter(name, duration)
|
||||
} else {
|
||||
c.workqueue.AddAfter(namespace+"/"+name, duration)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Controller) enqueue(obj interface{}) {
|
||||
var key string
|
||||
var err error
|
||||
if key, err = cache.MetaNamespaceKeyFunc(obj); err != nil {
|
||||
utilruntime.HandleError(err)
|
||||
return
|
||||
}
|
||||
c.workqueue.Add(key)
|
||||
}
|
||||
|
||||
func (c *Controller) handleObject(obj interface{}) {
|
||||
if _, ok := obj.(metav1.Object); !ok {
|
||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||
if !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("error decoding object, invalid type"))
|
||||
return
|
||||
}
|
||||
_, ok = tombstone.Obj.(metav1.Object)
|
||||
if !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("error decoding object tombstone, invalid type"))
|
||||
return
|
||||
}
|
||||
}
|
||||
c.enqueue(obj)
|
||||
}
|
195
vendor/github.com/rancher/wrangler/pkg/generic/controllerfactory.go
generated
vendored
Normal file
195
vendor/github.com/rancher/wrangler/pkg/generic/controllerfactory.go
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
package generic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
)
|
||||
|
||||
type ControllerManager struct {
|
||||
lock sync.Mutex
|
||||
generation int
|
||||
started map[schema.GroupVersionKind]bool
|
||||
controllers map[schema.GroupVersionKind]*Controller
|
||||
handlers map[schema.GroupVersionKind]*Handlers
|
||||
}
|
||||
|
||||
func (g *ControllerManager) Controllers() map[schema.GroupVersionKind]*Controller {
|
||||
return g.controllers
|
||||
}
|
||||
|
||||
func (g *ControllerManager) EnsureStart(ctx context.Context, gvk schema.GroupVersionKind, threadiness int) error {
|
||||
g.lock.Lock()
|
||||
defer g.lock.Unlock()
|
||||
|
||||
return g.startController(ctx, gvk, threadiness)
|
||||
}
|
||||
|
||||
func (g *ControllerManager) startController(ctx context.Context, gvk schema.GroupVersionKind, threadiness int) error {
|
||||
if g.started[gvk] {
|
||||
return nil
|
||||
}
|
||||
|
||||
controller, ok := g.controllers[gvk]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := controller.Run(threadiness, ctx.Done()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if g.started == nil {
|
||||
g.started = map[schema.GroupVersionKind]bool{}
|
||||
}
|
||||
g.started[gvk] = true
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
g.lock.Lock()
|
||||
defer g.lock.Unlock()
|
||||
|
||||
delete(g.started, gvk)
|
||||
delete(g.controllers, gvk)
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *ControllerManager) Start(ctx context.Context, defaultThreadiness int, threadiness map[schema.GroupVersionKind]int) error {
|
||||
g.lock.Lock()
|
||||
defer g.lock.Unlock()
|
||||
|
||||
for gvk := range g.controllers {
|
||||
threadiness, ok := threadiness[gvk]
|
||||
if !ok {
|
||||
threadiness = defaultThreadiness
|
||||
}
|
||||
if err := g.startController(ctx, gvk, threadiness); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *ControllerManager) Enqueue(gvk schema.GroupVersionKind, informer cache.SharedIndexInformer, namespace, name string) {
|
||||
_, controller, _ := g.getController(gvk, informer, true)
|
||||
|
||||
if namespace == "*" || name == "*" {
|
||||
for _, key := range informer.GetStore().ListKeys() {
|
||||
if namespace != "" && namespace != "*" && !strings.HasPrefix(key, namespace+"/") {
|
||||
continue
|
||||
}
|
||||
if name != "*" && !nameMatches(key, name) {
|
||||
continue
|
||||
}
|
||||
controller.workqueue.AddRateLimited(key)
|
||||
}
|
||||
} else {
|
||||
controller.Enqueue(namespace, name)
|
||||
}
|
||||
}
|
||||
|
||||
func nameMatches(key, name string) bool {
|
||||
return key == name || strings.HasSuffix(key, "/"+name)
|
||||
}
|
||||
|
||||
func (g *ControllerManager) EnqueueAfter(gvk schema.GroupVersionKind, informer cache.SharedIndexInformer, namespace, name string, duration time.Duration) {
|
||||
_, controller, _ := g.getController(gvk, informer, true)
|
||||
controller.EnqueueAfter(namespace, name, duration)
|
||||
}
|
||||
|
||||
func (g *ControllerManager) removeHandler(gvk schema.GroupVersionKind, generation int) {
|
||||
g.lock.Lock()
|
||||
defer g.lock.Unlock()
|
||||
|
||||
handlers, ok := g.handlers[gvk]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
var newHandlers []handlerEntry
|
||||
for _, h := range handlers.handlers {
|
||||
if h.generation == generation {
|
||||
continue
|
||||
}
|
||||
newHandlers = append(newHandlers, h)
|
||||
}
|
||||
|
||||
handlers.handlers = newHandlers
|
||||
}
|
||||
|
||||
func (g *ControllerManager) getController(gvk schema.GroupVersionKind, informer cache.SharedIndexInformer, lock bool) (*Handlers, *Controller, bool) {
|
||||
if lock {
|
||||
g.lock.Lock()
|
||||
defer g.lock.Unlock()
|
||||
}
|
||||
|
||||
if controller, ok := g.controllers[gvk]; ok {
|
||||
return g.handlers[gvk], controller, true
|
||||
}
|
||||
|
||||
handlers := &Handlers{}
|
||||
|
||||
queue := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), gvk.String())
|
||||
controller := NewController(gvk, informer, queue, handlers.Handle)
|
||||
|
||||
if g.handlers == nil {
|
||||
g.handlers = map[schema.GroupVersionKind]*Handlers{}
|
||||
}
|
||||
|
||||
if g.controllers == nil {
|
||||
g.controllers = map[schema.GroupVersionKind]*Controller{}
|
||||
}
|
||||
|
||||
g.handlers[gvk] = handlers
|
||||
g.controllers[gvk] = controller
|
||||
|
||||
return handlers, controller, false
|
||||
}
|
||||
|
||||
func (g *ControllerManager) AddHandler(ctx context.Context, gvk schema.GroupVersionKind, informer cache.SharedIndexInformer, name string, handler Handler) {
|
||||
t := getHandlerTransaction(ctx)
|
||||
if t == nil {
|
||||
g.addHandler(ctx, gvk, informer, name, handler)
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
if t.shouldContinue() {
|
||||
g.addHandler(ctx, gvk, informer, name, handler)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (g *ControllerManager) addHandler(ctx context.Context, gvk schema.GroupVersionKind, informer cache.SharedIndexInformer, name string, handler Handler) {
|
||||
g.lock.Lock()
|
||||
defer g.lock.Unlock()
|
||||
|
||||
g.generation++
|
||||
entry := handlerEntry{
|
||||
generation: g.generation,
|
||||
name: name,
|
||||
handler: handler,
|
||||
}
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
g.removeHandler(gvk, entry.generation)
|
||||
}()
|
||||
|
||||
handlers, controller, ok := g.getController(gvk, informer, false)
|
||||
handlers.handlers = append(handlers.handlers, entry)
|
||||
|
||||
if ok {
|
||||
for _, key := range controller.informer.GetStore().ListKeys() {
|
||||
controller.workqueue.Add(key)
|
||||
}
|
||||
}
|
||||
}
|
7
vendor/github.com/rancher/wrangler/pkg/generic/generating.go
generated
vendored
Normal file
7
vendor/github.com/rancher/wrangler/pkg/generic/generating.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package generic
|
||||
|
||||
type GeneratingHandlerOptions struct {
|
||||
AllowCrossNamespace bool
|
||||
AllowClusterScoped bool
|
||||
DynamicLookup bool
|
||||
}
|
95
vendor/github.com/rancher/wrangler/pkg/generic/handlers.go
generated
vendored
Normal file
95
vendor/github.com/rancher/wrangler/pkg/generic/handlers.go
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
package generic
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
type handlerEntry struct {
|
||||
generation int
|
||||
name string
|
||||
handler Handler
|
||||
}
|
||||
|
||||
type Handlers struct {
|
||||
handlers []handlerEntry
|
||||
}
|
||||
|
||||
func (h *Handlers) Handle(key string, obj runtime.Object) (runtime.Object, error) {
|
||||
var (
|
||||
errs errors
|
||||
)
|
||||
|
||||
for _, handler := range h.handlers {
|
||||
newObj, err := handler.handler(key, obj)
|
||||
if err != nil {
|
||||
errs = append(errs, &handlerError{
|
||||
HandlerName: handler.name,
|
||||
Err: err,
|
||||
})
|
||||
}
|
||||
if newObj != nil {
|
||||
obj = newObj
|
||||
}
|
||||
}
|
||||
|
||||
return obj, errs.ToErr()
|
||||
}
|
||||
|
||||
type errors []error
|
||||
|
||||
func (e errors) Error() string {
|
||||
buf := strings.Builder{}
|
||||
for _, err := range e {
|
||||
if buf.Len() > 0 {
|
||||
buf.WriteString(", ")
|
||||
}
|
||||
buf.WriteString(err.Error())
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (e errors) ToErr() error {
|
||||
switch len(e) {
|
||||
case 0:
|
||||
return nil
|
||||
case 1:
|
||||
return e[0]
|
||||
default:
|
||||
return e
|
||||
}
|
||||
}
|
||||
|
||||
func (e errors) Cause() error {
|
||||
if len(e) > 0 {
|
||||
return e[0]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type handlerError struct {
|
||||
HandlerName string
|
||||
Err error
|
||||
}
|
||||
|
||||
func (h handlerError) Error() string {
|
||||
return fmt.Sprintf("handler %s: %v", h.HandlerName, h.Err)
|
||||
}
|
||||
|
||||
func (h handlerError) Cause() error {
|
||||
return h.Err
|
||||
}
|
||||
|
||||
func ToName(h interface{}) string {
|
||||
if str, ok := h.(fmt.Stringer); ok {
|
||||
return str.String()
|
||||
}
|
||||
s := reflect.ValueOf(h).Type().String()
|
||||
if len(s) > 1 && s[0] == '*' {
|
||||
return s[1:]
|
||||
}
|
||||
return s
|
||||
}
|
119
vendor/github.com/rancher/wrangler/pkg/generic/remove.go
generated
vendored
Normal file
119
vendor/github.com/rancher/wrangler/pkg/generic/remove.go
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
package generic
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
var (
|
||||
finalizerKey = "wrangler.cattle.io/"
|
||||
)
|
||||
|
||||
type Updater func(runtime.Object) (runtime.Object, error)
|
||||
|
||||
type objectLifecycleAdapter struct {
|
||||
name string
|
||||
handler Handler
|
||||
updater Updater
|
||||
}
|
||||
|
||||
func NewRemoveHandler(name string, updater Updater, handler Handler) Handler {
|
||||
o := objectLifecycleAdapter{
|
||||
name: name,
|
||||
handler: handler,
|
||||
updater: updater,
|
||||
}
|
||||
return o.sync
|
||||
}
|
||||
|
||||
func (o *objectLifecycleAdapter) sync(key string, obj runtime.Object) (runtime.Object, error) {
|
||||
if obj == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
metadata, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
return obj, err
|
||||
}
|
||||
|
||||
if metadata.GetDeletionTimestamp() == nil {
|
||||
return o.addFinalizer(obj)
|
||||
}
|
||||
|
||||
if !o.hasFinalizer(obj) {
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
newObj, err := o.handler(key, obj)
|
||||
if err != nil {
|
||||
return newObj, err
|
||||
}
|
||||
|
||||
if newObj != nil {
|
||||
obj = newObj
|
||||
}
|
||||
|
||||
return o.removeFinalizer(obj)
|
||||
}
|
||||
|
||||
func (o *objectLifecycleAdapter) constructFinalizerKey() string {
|
||||
return finalizerKey + o.name
|
||||
}
|
||||
|
||||
func (o *objectLifecycleAdapter) hasFinalizer(obj runtime.Object) bool {
|
||||
metadata, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
finalizerKey := o.constructFinalizerKey()
|
||||
finalizers := metadata.GetFinalizers()
|
||||
for _, finalizer := range finalizers {
|
||||
if finalizer == finalizerKey {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (o *objectLifecycleAdapter) removeFinalizer(obj runtime.Object) (runtime.Object, error) {
|
||||
if !o.hasFinalizer(obj) {
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
obj = obj.DeepCopyObject()
|
||||
metadata, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
return obj, err
|
||||
}
|
||||
|
||||
finalizerKey := o.constructFinalizerKey()
|
||||
finalizers := metadata.GetFinalizers()
|
||||
|
||||
var newFinalizers []string
|
||||
for k, v := range finalizers {
|
||||
if v != finalizerKey {
|
||||
continue
|
||||
}
|
||||
newFinalizers = append(finalizers[:k], finalizers[k+1:]...)
|
||||
}
|
||||
|
||||
metadata.SetFinalizers(newFinalizers)
|
||||
return o.updater(obj)
|
||||
}
|
||||
|
||||
func (o *objectLifecycleAdapter) addFinalizer(obj runtime.Object) (runtime.Object, error) {
|
||||
if o.hasFinalizer(obj) {
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
obj = obj.DeepCopyObject()
|
||||
metadata, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
metadata.SetFinalizers(append(metadata.GetFinalizers(), o.constructFinalizerKey()))
|
||||
return o.updater(obj)
|
||||
}
|
47
vendor/github.com/rancher/wrangler/pkg/generic/transaction.go
generated
vendored
Normal file
47
vendor/github.com/rancher/wrangler/pkg/generic/transaction.go
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
package generic
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type hTransactionKey struct{}
|
||||
|
||||
type HandlerTransaction struct {
|
||||
context.Context
|
||||
parent context.Context
|
||||
done chan struct{}
|
||||
result bool
|
||||
}
|
||||
|
||||
func (h *HandlerTransaction) shouldContinue() bool {
|
||||
select {
|
||||
case <-h.parent.Done():
|
||||
return false
|
||||
case <-h.done:
|
||||
return h.result
|
||||
}
|
||||
}
|
||||
|
||||
func (h *HandlerTransaction) Commit() {
|
||||
h.result = true
|
||||
close(h.done)
|
||||
}
|
||||
|
||||
func (h *HandlerTransaction) Rollback() {
|
||||
close(h.done)
|
||||
}
|
||||
|
||||
func NewHandlerTransaction(ctx context.Context) *HandlerTransaction {
|
||||
ht := &HandlerTransaction{
|
||||
parent: ctx,
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
ctx = context.WithValue(ctx, hTransactionKey{}, ht)
|
||||
ht.Context = ctx
|
||||
return ht
|
||||
}
|
||||
|
||||
func getHandlerTransaction(ctx context.Context) *HandlerTransaction {
|
||||
v, _ := ctx.Value(hTransactionKey{}).(*HandlerTransaction)
|
||||
return v
|
||||
}
|
7
vendor/github.com/rancher/wrangler/pkg/schemes/all.go
generated
vendored
Normal file
7
vendor/github.com/rancher/wrangler/pkg/schemes/all.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package schemes
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
var All = runtime.NewScheme()
|
1
vendor/github.com/rancher/wrangler/pkg/summary/summarizers.go
generated
vendored
1
vendor/github.com/rancher/wrangler/pkg/summary/summarizers.go
generated
vendored
@@ -44,6 +44,7 @@ var (
|
||||
"Saved": "saving",
|
||||
"Updated": "updating",
|
||||
"Updating": "updating",
|
||||
"Upgraded": "upgrading",
|
||||
"Waiting": "waiting",
|
||||
"InitialRolesPopulated": "activating",
|
||||
"ScalingActive": "pending",
|
||||
|
3
vendor/github.com/rancher/wrangler/pkg/summary/summary.go
generated
vendored
3
vendor/github.com/rancher/wrangler/pkg/summary/summary.go
generated
vendored
@@ -1,6 +1,8 @@
|
||||
package summary
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/rancher/wrangler/pkg/data"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
)
|
||||
@@ -32,5 +34,6 @@ func Summarize(unstr *unstructured.Unstructured) Summary {
|
||||
summary.State = "active"
|
||||
}
|
||||
|
||||
summary.State = strings.ToLower(summary.State)
|
||||
return summary
|
||||
}
|
||||
|
Reference in New Issue
Block a user