1
0
mirror of https://github.com/rancher/types.git synced 2025-09-18 07:52:41 +00:00

Update generated code

This commit is contained in:
Darren Shepherd
2020-02-05 21:30:28 -07:00
parent f4b4600445
commit 6348c45560
261 changed files with 7076 additions and 23145 deletions

View File

@@ -6,6 +6,7 @@ package fakes
import (
context "context"
sync "sync"
time "time"
controller "github.com/rancher/norman/controller"
objectclient "github.com/rancher/norman/objectclient"
@@ -146,6 +147,7 @@ var (
lockJobControllerMockAddFeatureHandler sync.RWMutex
lockJobControllerMockAddHandler sync.RWMutex
lockJobControllerMockEnqueue sync.RWMutex
lockJobControllerMockEnqueueAfter sync.RWMutex
lockJobControllerMockGeneric sync.RWMutex
lockJobControllerMockInformer sync.RWMutex
lockJobControllerMockLister sync.RWMutex
@@ -178,6 +180,9 @@ var _ v1a.JobController = &JobControllerMock{}
// EnqueueFunc: func(namespace string, name string) {
// panic("mock out the Enqueue method")
// },
// EnqueueAfterFunc: func(namespace string, name string, after time.Duration) {
// panic("mock out the EnqueueAfter method")
// },
// GenericFunc: func() controller.GenericController {
// panic("mock out the Generic method")
// },
@@ -215,6 +220,9 @@ type JobControllerMock struct {
// EnqueueFunc mocks the Enqueue method.
EnqueueFunc func(namespace string, name string)
// EnqueueAfterFunc mocks the EnqueueAfter method.
EnqueueAfterFunc func(namespace string, name string, after time.Duration)
// GenericFunc mocks the Generic method.
GenericFunc func() controller.GenericController
@@ -283,6 +291,15 @@ type JobControllerMock struct {
// Name is the name argument value.
Name string
}
// EnqueueAfter holds details about calls to the EnqueueAfter method.
EnqueueAfter []struct {
// Namespace is the namespace argument value.
Namespace string
// Name is the name argument value.
Name string
// After is the after argument value.
After time.Duration
}
// Generic holds details about calls to the Generic method.
Generic []struct {
}
@@ -514,6 +531,45 @@ func (mock *JobControllerMock) EnqueueCalls() []struct {
return calls
}
// EnqueueAfter calls EnqueueAfterFunc.
func (mock *JobControllerMock) EnqueueAfter(namespace string, name string, after time.Duration) {
if mock.EnqueueAfterFunc == nil {
panic("JobControllerMock.EnqueueAfterFunc: method is nil but JobController.EnqueueAfter was just called")
}
callInfo := struct {
Namespace string
Name string
After time.Duration
}{
Namespace: namespace,
Name: name,
After: after,
}
lockJobControllerMockEnqueueAfter.Lock()
mock.calls.EnqueueAfter = append(mock.calls.EnqueueAfter, callInfo)
lockJobControllerMockEnqueueAfter.Unlock()
mock.EnqueueAfterFunc(namespace, name, after)
}
// EnqueueAfterCalls gets all the calls that were made to EnqueueAfter.
// Check the length with:
// len(mockedJobController.EnqueueAfterCalls())
func (mock *JobControllerMock) EnqueueAfterCalls() []struct {
Namespace string
Name string
After time.Duration
} {
var calls []struct {
Namespace string
Name string
After time.Duration
}
lockJobControllerMockEnqueueAfter.RLock()
calls = mock.calls.EnqueueAfter
lockJobControllerMockEnqueueAfter.RUnlock()
return calls
}
// Generic calls GenericFunc.
func (mock *JobControllerMock) Generic() controller.GenericController {
if mock.GenericFunc == nil {

View File

@@ -2,6 +2,7 @@ package v1
import (
"context"
"time"
"github.com/rancher/norman/controller"
"github.com/rancher/norman/objectclient"
@@ -73,6 +74,7 @@ type JobController interface {
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler JobHandlerFunc)
AddClusterScopedFeatureHandler(ctx context.Context, enabled func() bool, name, clusterName string, handler JobHandlerFunc)
Enqueue(namespace, name string)
EnqueueAfter(namespace, name string, after time.Duration)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
@@ -328,183 +330,3 @@ func (s *jobClient) AddClusterScopedFeatureLifecycle(ctx context.Context, enable
sync := NewJobLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.Controller().AddClusterScopedFeatureHandler(ctx, enabled, name, clusterName, sync)
}
type JobIndexer func(obj *v1.Job) ([]string, error)
type JobClientCache interface {
Get(namespace, name string) (*v1.Job, error)
List(namespace string, selector labels.Selector) ([]*v1.Job, error)
Index(name string, indexer JobIndexer)
GetIndexed(name, key string) ([]*v1.Job, error)
}
type JobClient interface {
Create(*v1.Job) (*v1.Job, error)
Get(namespace, name string, opts metav1.GetOptions) (*v1.Job, error)
Update(*v1.Job) (*v1.Job, error)
Delete(namespace, name string, options *metav1.DeleteOptions) error
List(namespace string, opts metav1.ListOptions) (*JobList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Cache() JobClientCache
OnCreate(ctx context.Context, name string, sync JobChangeHandlerFunc)
OnChange(ctx context.Context, name string, sync JobChangeHandlerFunc)
OnRemove(ctx context.Context, name string, sync JobChangeHandlerFunc)
Enqueue(namespace, name string)
Generic() controller.GenericController
ObjectClient() *objectclient.ObjectClient
Interface() JobInterface
}
type jobClientCache struct {
client *jobClient2
}
type jobClient2 struct {
iface JobInterface
controller JobController
}
func (n *jobClient2) Interface() JobInterface {
return n.iface
}
func (n *jobClient2) Generic() controller.GenericController {
return n.iface.Controller().Generic()
}
func (n *jobClient2) ObjectClient() *objectclient.ObjectClient {
return n.Interface().ObjectClient()
}
func (n *jobClient2) Enqueue(namespace, name string) {
n.iface.Controller().Enqueue(namespace, name)
}
func (n *jobClient2) Create(obj *v1.Job) (*v1.Job, error) {
return n.iface.Create(obj)
}
func (n *jobClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.Job, error) {
return n.iface.GetNamespaced(namespace, name, opts)
}
func (n *jobClient2) Update(obj *v1.Job) (*v1.Job, error) {
return n.iface.Update(obj)
}
func (n *jobClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
return n.iface.DeleteNamespaced(namespace, name, options)
}
func (n *jobClient2) List(namespace string, opts metav1.ListOptions) (*JobList, error) {
return n.iface.List(opts)
}
func (n *jobClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return n.iface.Watch(opts)
}
func (n *jobClientCache) Get(namespace, name string) (*v1.Job, error) {
return n.client.controller.Lister().Get(namespace, name)
}
func (n *jobClientCache) List(namespace string, selector labels.Selector) ([]*v1.Job, error) {
return n.client.controller.Lister().List(namespace, selector)
}
func (n *jobClient2) Cache() JobClientCache {
n.loadController()
return &jobClientCache{
client: n,
}
}
func (n *jobClient2) OnCreate(ctx context.Context, name string, sync JobChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-create", &jobLifecycleDelegate{create: sync})
}
func (n *jobClient2) OnChange(ctx context.Context, name string, sync JobChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name+"-change", &jobLifecycleDelegate{update: sync})
}
func (n *jobClient2) OnRemove(ctx context.Context, name string, sync JobChangeHandlerFunc) {
n.loadController()
n.iface.AddLifecycle(ctx, name, &jobLifecycleDelegate{remove: sync})
}
func (n *jobClientCache) Index(name string, indexer JobIndexer) {
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
name: func(obj interface{}) ([]string, error) {
if v, ok := obj.(*v1.Job); ok {
return indexer(v)
}
return nil, nil
},
})
if err != nil {
panic(err)
}
}
func (n *jobClientCache) GetIndexed(name, key string) ([]*v1.Job, error) {
var result []*v1.Job
objs, err := n.client.controller.Informer().GetIndexer().ByIndex(name, key)
if err != nil {
return nil, err
}
for _, obj := range objs {
if v, ok := obj.(*v1.Job); ok {
result = append(result, v)
}
}
return result, nil
}
func (n *jobClient2) loadController() {
if n.controller == nil {
n.controller = n.iface.Controller()
}
}
type jobLifecycleDelegate struct {
create JobChangeHandlerFunc
update JobChangeHandlerFunc
remove JobChangeHandlerFunc
}
func (n *jobLifecycleDelegate) HasCreate() bool {
return n.create != nil
}
func (n *jobLifecycleDelegate) Create(obj *v1.Job) (runtime.Object, error) {
if n.create == nil {
return obj, nil
}
return n.create(obj)
}
func (n *jobLifecycleDelegate) HasFinalize() bool {
return n.remove != nil
}
func (n *jobLifecycleDelegate) Remove(obj *v1.Job) (runtime.Object, error) {
if n.remove == nil {
return obj, nil
}
return n.remove(obj)
}
func (n *jobLifecycleDelegate) Updated(obj *v1.Job) (runtime.Object, error) {
if n.update == nil {
return obj, nil
}
return n.update(obj)
}

View File

@@ -23,12 +23,6 @@ type Interface interface {
JobsGetter
}
type Clients struct {
Interface Interface
Job JobClient
}
type Client struct {
sync.Mutex
restClient rest.Interface
@@ -37,45 +31,6 @@ type Client struct {
jobControllers map[string]JobController
}
func Factory(ctx context.Context, config rest.Config) (context.Context, controller.Starter, error) {
c, err := NewForConfig(config)
if err != nil {
return ctx, nil, err
}
cs := NewClientsFromInterface(c)
ctx = context.WithValue(ctx, contextKeyType{}, c)
ctx = context.WithValue(ctx, contextClientsKeyType{}, cs)
return ctx, c, nil
}
func ClientsFrom(ctx context.Context) *Clients {
return ctx.Value(contextClientsKeyType{}).(*Clients)
}
func From(ctx context.Context) Interface {
return ctx.Value(contextKeyType{}).(Interface)
}
func NewClients(config rest.Config) (*Clients, error) {
iface, err := NewForConfig(config)
if err != nil {
return nil, err
}
return NewClientsFromInterface(iface), nil
}
func NewClientsFromInterface(iface Interface) *Clients {
return &Clients{
Interface: iface,
Job: &jobClient2{
iface: iface.Jobs(""),
},
}
}
func NewForConfig(config rest.Config) (Interface, error) {
if config.NegotiatedSerializer == nil {
config.NegotiatedSerializer = dynamic.NegotiatedSerializer