mirror of
https://github.com/rancher/types.git
synced 2025-08-01 04:57:05 +00:00
go generate
This commit is contained in:
parent
35112c6ee7
commit
01e479069c
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,505 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"github.com/rancher/norman/resource"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
APIServiceGroupVersionKind = schema.GroupVersionKind{
|
||||
Version: Version,
|
||||
Group: GroupName,
|
||||
Kind: "APIService",
|
||||
}
|
||||
APIServiceResource = metav1.APIResource{
|
||||
Name: "apiservices",
|
||||
SingularName: "apiservice",
|
||||
Namespaced: false,
|
||||
Kind: APIServiceGroupVersionKind.Kind,
|
||||
}
|
||||
|
||||
APIServiceGroupVersionResource = schema.GroupVersionResource{
|
||||
Group: GroupName,
|
||||
Version: Version,
|
||||
Resource: "apiservices",
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
resource.Put(APIServiceGroupVersionResource)
|
||||
}
|
||||
|
||||
func NewAPIService(namespace, name string, obj v1.APIService) *v1.APIService {
|
||||
obj.APIVersion, obj.Kind = APIServiceGroupVersionKind.ToAPIVersionAndKind()
|
||||
obj.Name = name
|
||||
obj.Namespace = namespace
|
||||
return &obj
|
||||
}
|
||||
|
||||
type APIServiceList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []v1.APIService `json:"items"`
|
||||
}
|
||||
|
||||
type APIServiceHandlerFunc func(key string, obj *v1.APIService) (runtime.Object, error)
|
||||
|
||||
type APIServiceChangeHandlerFunc func(obj *v1.APIService) (runtime.Object, error)
|
||||
|
||||
type APIServiceLister interface {
|
||||
List(namespace string, selector labels.Selector) (ret []*v1.APIService, err error)
|
||||
Get(namespace, name string) (*v1.APIService, error)
|
||||
}
|
||||
|
||||
type APIServiceController interface {
|
||||
Generic() controller.GenericController
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() APIServiceLister
|
||||
AddHandler(ctx context.Context, name string, handler APIServiceHandlerFunc)
|
||||
AddFeatureHandler(ctx context.Context, enabled func() bool, name string, sync APIServiceHandlerFunc)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, handler APIServiceHandlerFunc)
|
||||
AddClusterScopedFeatureHandler(ctx context.Context, enabled func() bool, name, clusterName string, handler APIServiceHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
Sync(ctx context.Context) error
|
||||
Start(ctx context.Context, threadiness int) error
|
||||
}
|
||||
|
||||
type APIServiceInterface interface {
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Create(*v1.APIService) (*v1.APIService, error)
|
||||
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.APIService, error)
|
||||
Get(name string, opts metav1.GetOptions) (*v1.APIService, error)
|
||||
Update(*v1.APIService) (*v1.APIService, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*APIServiceList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
||||
Controller() APIServiceController
|
||||
AddHandler(ctx context.Context, name string, sync APIServiceHandlerFunc)
|
||||
AddFeatureHandler(ctx context.Context, enabled func() bool, name string, sync APIServiceHandlerFunc)
|
||||
AddLifecycle(ctx context.Context, name string, lifecycle APIServiceLifecycle)
|
||||
AddFeatureLifecycle(ctx context.Context, enabled func() bool, name string, lifecycle APIServiceLifecycle)
|
||||
AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync APIServiceHandlerFunc)
|
||||
AddClusterScopedFeatureHandler(ctx context.Context, enabled func() bool, name, clusterName string, sync APIServiceHandlerFunc)
|
||||
AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle APIServiceLifecycle)
|
||||
AddClusterScopedFeatureLifecycle(ctx context.Context, enabled func() bool, name, clusterName string, lifecycle APIServiceLifecycle)
|
||||
}
|
||||
|
||||
type apiServiceLister struct {
|
||||
controller *apiServiceController
|
||||
}
|
||||
|
||||
func (l *apiServiceLister) List(namespace string, selector labels.Selector) (ret []*v1.APIService, err error) {
|
||||
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
|
||||
ret = append(ret, obj.(*v1.APIService))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (l *apiServiceLister) Get(namespace, name string) (*v1.APIService, error) {
|
||||
var key string
|
||||
if namespace != "" {
|
||||
key = namespace + "/" + name
|
||||
} else {
|
||||
key = name
|
||||
}
|
||||
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(schema.GroupResource{
|
||||
Group: APIServiceGroupVersionKind.Group,
|
||||
Resource: "apiService",
|
||||
}, key)
|
||||
}
|
||||
return obj.(*v1.APIService), nil
|
||||
}
|
||||
|
||||
type apiServiceController struct {
|
||||
controller.GenericController
|
||||
}
|
||||
|
||||
func (c *apiServiceController) Generic() controller.GenericController {
|
||||
return c.GenericController
|
||||
}
|
||||
|
||||
func (c *apiServiceController) Lister() APIServiceLister {
|
||||
return &apiServiceLister{
|
||||
controller: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *apiServiceController) AddHandler(ctx context.Context, name string, handler APIServiceHandlerFunc) {
|
||||
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
|
||||
if obj == nil {
|
||||
return handler(key, nil)
|
||||
} else if v, ok := obj.(*v1.APIService); ok {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (c *apiServiceController) AddFeatureHandler(ctx context.Context, enabled func() bool, name string, handler APIServiceHandlerFunc) {
|
||||
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
|
||||
if !enabled() {
|
||||
return nil, nil
|
||||
} else if obj == nil {
|
||||
return handler(key, nil)
|
||||
} else if v, ok := obj.(*v1.APIService); ok {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (c *apiServiceController) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler APIServiceHandlerFunc) {
|
||||
resource.PutClusterScoped(APIServiceGroupVersionResource)
|
||||
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
|
||||
if obj == nil {
|
||||
return handler(key, nil)
|
||||
} else if v, ok := obj.(*v1.APIService); ok && controller.ObjectInCluster(cluster, obj) {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (c *apiServiceController) AddClusterScopedFeatureHandler(ctx context.Context, enabled func() bool, name, cluster string, handler APIServiceHandlerFunc) {
|
||||
resource.PutClusterScoped(APIServiceGroupVersionResource)
|
||||
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
|
||||
if !enabled() {
|
||||
return nil, nil
|
||||
} else if obj == nil {
|
||||
return handler(key, nil)
|
||||
} else if v, ok := obj.(*v1.APIService); ok && controller.ObjectInCluster(cluster, obj) {
|
||||
return handler(key, v)
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type apiServiceFactory struct {
|
||||
}
|
||||
|
||||
func (c apiServiceFactory) Object() runtime.Object {
|
||||
return &v1.APIService{}
|
||||
}
|
||||
|
||||
func (c apiServiceFactory) List() runtime.Object {
|
||||
return &APIServiceList{}
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) Controller() APIServiceController {
|
||||
s.client.Lock()
|
||||
defer s.client.Unlock()
|
||||
|
||||
c, ok := s.client.apiServiceControllers[s.ns]
|
||||
if ok {
|
||||
return c
|
||||
}
|
||||
|
||||
genericController := controller.NewGenericController(APIServiceGroupVersionKind.Kind+"Controller",
|
||||
s.objectClient)
|
||||
|
||||
c = &apiServiceController{
|
||||
GenericController: genericController,
|
||||
}
|
||||
|
||||
s.client.apiServiceControllers[s.ns] = c
|
||||
s.client.starters = append(s.client.starters, c)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type apiServiceClient struct {
|
||||
client *Client
|
||||
ns string
|
||||
objectClient *objectclient.ObjectClient
|
||||
controller APIServiceController
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) ObjectClient() *objectclient.ObjectClient {
|
||||
return s.objectClient
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) Create(o *v1.APIService) (*v1.APIService, error) {
|
||||
obj, err := s.objectClient.Create(o)
|
||||
return obj.(*v1.APIService), err
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) Get(name string, opts metav1.GetOptions) (*v1.APIService, error) {
|
||||
obj, err := s.objectClient.Get(name, opts)
|
||||
return obj.(*v1.APIService), err
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.APIService, error) {
|
||||
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
|
||||
return obj.(*v1.APIService), err
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) Update(o *v1.APIService) (*v1.APIService, error) {
|
||||
obj, err := s.objectClient.Update(o.Name, o)
|
||||
return obj.(*v1.APIService), err
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) Delete(name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.Delete(name, options)
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return s.objectClient.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) List(opts metav1.ListOptions) (*APIServiceList, error) {
|
||||
obj, err := s.objectClient.List(opts)
|
||||
return obj.(*APIServiceList), err
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return s.objectClient.Watch(opts)
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched deployment.
|
||||
func (s *apiServiceClient) Patch(o *v1.APIService, patchType types.PatchType, data []byte, subresources ...string) (*v1.APIService, error) {
|
||||
obj, err := s.objectClient.Patch(o.Name, o, patchType, data, subresources...)
|
||||
return obj.(*v1.APIService), err
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) AddHandler(ctx context.Context, name string, sync APIServiceHandlerFunc) {
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) AddFeatureHandler(ctx context.Context, enabled func() bool, name string, sync APIServiceHandlerFunc) {
|
||||
s.Controller().AddFeatureHandler(ctx, enabled, name, sync)
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) AddLifecycle(ctx context.Context, name string, lifecycle APIServiceLifecycle) {
|
||||
sync := NewAPIServiceLifecycleAdapter(name, false, s, lifecycle)
|
||||
s.Controller().AddHandler(ctx, name, sync)
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) AddFeatureLifecycle(ctx context.Context, enabled func() bool, name string, lifecycle APIServiceLifecycle) {
|
||||
sync := NewAPIServiceLifecycleAdapter(name, false, s, lifecycle)
|
||||
s.Controller().AddFeatureHandler(ctx, enabled, name, sync)
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) AddClusterScopedHandler(ctx context.Context, name, clusterName string, sync APIServiceHandlerFunc) {
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) AddClusterScopedFeatureHandler(ctx context.Context, enabled func() bool, name, clusterName string, sync APIServiceHandlerFunc) {
|
||||
s.Controller().AddClusterScopedFeatureHandler(ctx, enabled, name, clusterName, sync)
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) AddClusterScopedLifecycle(ctx context.Context, name, clusterName string, lifecycle APIServiceLifecycle) {
|
||||
sync := NewAPIServiceLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
|
||||
s.Controller().AddClusterScopedHandler(ctx, name, clusterName, sync)
|
||||
}
|
||||
|
||||
func (s *apiServiceClient) AddClusterScopedFeatureLifecycle(ctx context.Context, enabled func() bool, name, clusterName string, lifecycle APIServiceLifecycle) {
|
||||
sync := NewAPIServiceLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
|
||||
s.Controller().AddClusterScopedFeatureHandler(ctx, enabled, name, clusterName, sync)
|
||||
}
|
||||
|
||||
type APIServiceIndexer func(obj *v1.APIService) ([]string, error)
|
||||
|
||||
type APIServiceClientCache interface {
|
||||
Get(namespace, name string) (*v1.APIService, error)
|
||||
List(namespace string, selector labels.Selector) ([]*v1.APIService, error)
|
||||
|
||||
Index(name string, indexer APIServiceIndexer)
|
||||
GetIndexed(name, key string) ([]*v1.APIService, error)
|
||||
}
|
||||
|
||||
type APIServiceClient interface {
|
||||
Create(*v1.APIService) (*v1.APIService, error)
|
||||
Get(namespace, name string, opts metav1.GetOptions) (*v1.APIService, error)
|
||||
Update(*v1.APIService) (*v1.APIService, error)
|
||||
Delete(namespace, name string, options *metav1.DeleteOptions) error
|
||||
List(namespace string, opts metav1.ListOptions) (*APIServiceList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
|
||||
Cache() APIServiceClientCache
|
||||
|
||||
OnCreate(ctx context.Context, name string, sync APIServiceChangeHandlerFunc)
|
||||
OnChange(ctx context.Context, name string, sync APIServiceChangeHandlerFunc)
|
||||
OnRemove(ctx context.Context, name string, sync APIServiceChangeHandlerFunc)
|
||||
Enqueue(namespace, name string)
|
||||
|
||||
Generic() controller.GenericController
|
||||
ObjectClient() *objectclient.ObjectClient
|
||||
Interface() APIServiceInterface
|
||||
}
|
||||
|
||||
type apiServiceClientCache struct {
|
||||
client *apiServiceClient2
|
||||
}
|
||||
|
||||
type apiServiceClient2 struct {
|
||||
iface APIServiceInterface
|
||||
controller APIServiceController
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) Interface() APIServiceInterface {
|
||||
return n.iface
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) Generic() controller.GenericController {
|
||||
return n.iface.Controller().Generic()
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) ObjectClient() *objectclient.ObjectClient {
|
||||
return n.Interface().ObjectClient()
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) Enqueue(namespace, name string) {
|
||||
n.iface.Controller().Enqueue(namespace, name)
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) Create(obj *v1.APIService) (*v1.APIService, error) {
|
||||
return n.iface.Create(obj)
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) Get(namespace, name string, opts metav1.GetOptions) (*v1.APIService, error) {
|
||||
return n.iface.GetNamespaced(namespace, name, opts)
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) Update(obj *v1.APIService) (*v1.APIService, error) {
|
||||
return n.iface.Update(obj)
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) Delete(namespace, name string, options *metav1.DeleteOptions) error {
|
||||
return n.iface.DeleteNamespaced(namespace, name, options)
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) List(namespace string, opts metav1.ListOptions) (*APIServiceList, error) {
|
||||
return n.iface.List(opts)
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return n.iface.Watch(opts)
|
||||
}
|
||||
|
||||
func (n *apiServiceClientCache) Get(namespace, name string) (*v1.APIService, error) {
|
||||
return n.client.controller.Lister().Get(namespace, name)
|
||||
}
|
||||
|
||||
func (n *apiServiceClientCache) List(namespace string, selector labels.Selector) ([]*v1.APIService, error) {
|
||||
return n.client.controller.Lister().List(namespace, selector)
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) Cache() APIServiceClientCache {
|
||||
n.loadController()
|
||||
return &apiServiceClientCache{
|
||||
client: n,
|
||||
}
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) OnCreate(ctx context.Context, name string, sync APIServiceChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-create", &apiServiceLifecycleDelegate{create: sync})
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) OnChange(ctx context.Context, name string, sync APIServiceChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name+"-change", &apiServiceLifecycleDelegate{update: sync})
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) OnRemove(ctx context.Context, name string, sync APIServiceChangeHandlerFunc) {
|
||||
n.loadController()
|
||||
n.iface.AddLifecycle(ctx, name, &apiServiceLifecycleDelegate{remove: sync})
|
||||
}
|
||||
|
||||
func (n *apiServiceClientCache) Index(name string, indexer APIServiceIndexer) {
|
||||
err := n.client.controller.Informer().GetIndexer().AddIndexers(map[string]cache.IndexFunc{
|
||||
name: func(obj interface{}) ([]string, error) {
|
||||
if v, ok := obj.(*v1.APIService); ok {
|
||||
return indexer(v)
|
||||
}
|
||||
return nil, nil
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *apiServiceClientCache) GetIndexed(name, key string) ([]*v1.APIService, error) {
|
||||
var result []*v1.APIService
|
||||
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.APIService); ok {
|
||||
result = append(result, v)
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (n *apiServiceClient2) loadController() {
|
||||
if n.controller == nil {
|
||||
n.controller = n.iface.Controller()
|
||||
}
|
||||
}
|
||||
|
||||
type apiServiceLifecycleDelegate struct {
|
||||
create APIServiceChangeHandlerFunc
|
||||
update APIServiceChangeHandlerFunc
|
||||
remove APIServiceChangeHandlerFunc
|
||||
}
|
||||
|
||||
func (n *apiServiceLifecycleDelegate) HasCreate() bool {
|
||||
return n.create != nil
|
||||
}
|
||||
|
||||
func (n *apiServiceLifecycleDelegate) Create(obj *v1.APIService) (runtime.Object, error) {
|
||||
if n.create == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.create(obj)
|
||||
}
|
||||
|
||||
func (n *apiServiceLifecycleDelegate) HasFinalize() bool {
|
||||
return n.remove != nil
|
||||
}
|
||||
|
||||
func (n *apiServiceLifecycleDelegate) Remove(obj *v1.APIService) (runtime.Object, error) {
|
||||
if n.remove == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.remove(obj)
|
||||
}
|
||||
|
||||
func (n *apiServiceLifecycleDelegate) Updated(obj *v1.APIService) (runtime.Object, error) {
|
||||
if n.update == nil {
|
||||
return obj, nil
|
||||
}
|
||||
return n.update(obj)
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||
)
|
||||
|
||||
type APIServiceLifecycle interface {
|
||||
Create(obj *v1.APIService) (runtime.Object, error)
|
||||
Remove(obj *v1.APIService) (runtime.Object, error)
|
||||
Updated(obj *v1.APIService) (runtime.Object, error)
|
||||
}
|
||||
|
||||
type apiServiceLifecycleAdapter struct {
|
||||
lifecycle APIServiceLifecycle
|
||||
}
|
||||
|
||||
func (w *apiServiceLifecycleAdapter) HasCreate() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasCreate()
|
||||
}
|
||||
|
||||
func (w *apiServiceLifecycleAdapter) HasFinalize() bool {
|
||||
o, ok := w.lifecycle.(lifecycle.ObjectLifecycleCondition)
|
||||
return !ok || o.HasFinalize()
|
||||
}
|
||||
|
||||
func (w *apiServiceLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Create(obj.(*v1.APIService))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *apiServiceLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Remove(obj.(*v1.APIService))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func (w *apiServiceLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
|
||||
o, err := w.lifecycle.Updated(obj.(*v1.APIService))
|
||||
if o == nil {
|
||||
return nil, err
|
||||
}
|
||||
return o, err
|
||||
}
|
||||
|
||||
func NewAPIServiceLifecycleAdapter(name string, clusterScoped bool, client APIServiceInterface, l APIServiceLifecycle) APIServiceHandlerFunc {
|
||||
adapter := &apiServiceLifecycleAdapter{lifecycle: l}
|
||||
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
|
||||
return func(key string, obj *v1.APIService) (runtime.Object, error) {
|
||||
newObj, err := syncFn(key, obj)
|
||||
if o, ok := newObj.(runtime.Object); ok {
|
||||
return o, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
}
|
39
apis/apiregistration.k8s.io/v1/zz_generated_deepcopy.go
Normal file
39
apis/apiregistration.k8s.io/v1/zz_generated_deepcopy.go
Normal file
@ -0,0 +1,39 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *APIServiceList) DeepCopyInto(out *APIServiceList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]apiregistrationv1.APIService, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceList.
|
||||
func (in *APIServiceList) DeepCopy() *APIServiceList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(APIServiceList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *APIServiceList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
119
apis/apiregistration.k8s.io/v1/zz_generated_k8s_client.go
Normal file
119
apis/apiregistration.k8s.io/v1/zz_generated_k8s_client.go
Normal file
@ -0,0 +1,119 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"github.com/rancher/norman/objectclient/dynamic"
|
||||
"github.com/rancher/norman/restwatch"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type (
|
||||
contextKeyType struct{}
|
||||
contextClientsKeyType struct{}
|
||||
)
|
||||
|
||||
type Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
controller.Starter
|
||||
|
||||
APIServicesGetter
|
||||
}
|
||||
|
||||
type Clients struct {
|
||||
Interface Interface
|
||||
|
||||
APIService APIServiceClient
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
sync.Mutex
|
||||
restClient rest.Interface
|
||||
starters []controller.Starter
|
||||
|
||||
apiServiceControllers map[string]APIServiceController
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
APIService: &apiServiceClient2{
|
||||
iface: iface.APIServices(""),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewForConfig(config rest.Config) (Interface, error) {
|
||||
if config.NegotiatedSerializer == nil {
|
||||
config.NegotiatedSerializer = dynamic.NegotiatedSerializer
|
||||
}
|
||||
|
||||
restClient, err := restwatch.UnversionedRESTClientFor(&config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Client{
|
||||
restClient: restClient,
|
||||
|
||||
apiServiceControllers: map[string]APIServiceController{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Client) RESTClient() rest.Interface {
|
||||
return c.restClient
|
||||
}
|
||||
|
||||
func (c *Client) Sync(ctx context.Context) error {
|
||||
return controller.Sync(ctx, c.starters...)
|
||||
}
|
||||
|
||||
func (c *Client) Start(ctx context.Context, threadiness int) error {
|
||||
return controller.Start(ctx, threadiness, c.starters...)
|
||||
}
|
||||
|
||||
type APIServicesGetter interface {
|
||||
APIServices(namespace string) APIServiceInterface
|
||||
}
|
||||
|
||||
func (c *Client) APIServices(namespace string) APIServiceInterface {
|
||||
objectClient := objectclient.NewObjectClient(namespace, c.restClient, &APIServiceResource, APIServiceGroupVersionKind, apiServiceFactory{})
|
||||
return &apiServiceClient{
|
||||
ns: namespace,
|
||||
client: c,
|
||||
objectClient: objectClient,
|
||||
}
|
||||
}
|
41
apis/apiregistration.k8s.io/v1/zz_generated_scheme.go
Normal file
41
apis/apiregistration.k8s.io/v1/zz_generated_scheme.go
Normal file
@ -0,0 +1,41 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
GroupName = "apiregistration.k8s.io"
|
||||
Version = "v1"
|
||||
)
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}
|
||||
|
||||
// Kind takes an unqualified kind and returns a Group qualified GroupKind
|
||||
func Kind(kind string) schema.GroupKind {
|
||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||
}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
var (
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to api.Scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
// TODO this gets cleaned up when the types are fixed
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
|
||||
&APIServiceList{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
}
|
121
client/cluster/v3/zz_generated_api_service.go
Normal file
121
client/cluster/v3/zz_generated_api_service.go
Normal file
@ -0,0 +1,121 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/types"
|
||||
)
|
||||
|
||||
const (
|
||||
APIServiceType = "apiService"
|
||||
APIServiceFieldAnnotations = "annotations"
|
||||
APIServiceFieldCABundle = "caBundle"
|
||||
APIServiceFieldConditions = "conditions"
|
||||
APIServiceFieldCreated = "created"
|
||||
APIServiceFieldCreatorID = "creatorId"
|
||||
APIServiceFieldGroup = "group"
|
||||
APIServiceFieldGroupPriorityMinimum = "groupPriorityMinimum"
|
||||
APIServiceFieldInsecureSkipTLSVerify = "insecureSkipTLSVerify"
|
||||
APIServiceFieldLabels = "labels"
|
||||
APIServiceFieldName = "name"
|
||||
APIServiceFieldOwnerReferences = "ownerReferences"
|
||||
APIServiceFieldRemoved = "removed"
|
||||
APIServiceFieldService = "service"
|
||||
APIServiceFieldState = "state"
|
||||
APIServiceFieldTransitioning = "transitioning"
|
||||
APIServiceFieldTransitioningMessage = "transitioningMessage"
|
||||
APIServiceFieldUUID = "uuid"
|
||||
APIServiceFieldVersion = "version"
|
||||
APIServiceFieldVersionPriority = "versionPriority"
|
||||
)
|
||||
|
||||
type APIService struct {
|
||||
types.Resource
|
||||
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
||||
CABundle string `json:"caBundle,omitempty" yaml:"caBundle,omitempty"`
|
||||
Conditions []APIServiceCondition `json:"conditions,omitempty" yaml:"conditions,omitempty"`
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
CreatorID string `json:"creatorId,omitempty" yaml:"creatorId,omitempty"`
|
||||
Group string `json:"group,omitempty" yaml:"group,omitempty"`
|
||||
GroupPriorityMinimum int64 `json:"groupPriorityMinimum,omitempty" yaml:"groupPriorityMinimum,omitempty"`
|
||||
InsecureSkipTLSVerify bool `json:"insecureSkipTLSVerify,omitempty" yaml:"insecureSkipTLSVerify,omitempty"`
|
||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty" yaml:"ownerReferences,omitempty"`
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
Service *ServiceReference `json:"service,omitempty" yaml:"service,omitempty"`
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioningMessage,omitempty"`
|
||||
UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
Version string `json:"version,omitempty" yaml:"version,omitempty"`
|
||||
VersionPriority int64 `json:"versionPriority,omitempty" yaml:"versionPriority,omitempty"`
|
||||
}
|
||||
|
||||
type APIServiceCollection struct {
|
||||
types.Collection
|
||||
Data []APIService `json:"data,omitempty"`
|
||||
client *APIServiceClient
|
||||
}
|
||||
|
||||
type APIServiceClient struct {
|
||||
apiClient *Client
|
||||
}
|
||||
|
||||
type APIServiceOperations interface {
|
||||
List(opts *types.ListOpts) (*APIServiceCollection, error)
|
||||
Create(opts *APIService) (*APIService, error)
|
||||
Update(existing *APIService, updates interface{}) (*APIService, error)
|
||||
Replace(existing *APIService) (*APIService, error)
|
||||
ByID(id string) (*APIService, error)
|
||||
Delete(container *APIService) error
|
||||
}
|
||||
|
||||
func newAPIServiceClient(apiClient *Client) *APIServiceClient {
|
||||
return &APIServiceClient{
|
||||
apiClient: apiClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *APIServiceClient) Create(container *APIService) (*APIService, error) {
|
||||
resp := &APIService{}
|
||||
err := c.apiClient.Ops.DoCreate(APIServiceType, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *APIServiceClient) Update(existing *APIService, updates interface{}) (*APIService, error) {
|
||||
resp := &APIService{}
|
||||
err := c.apiClient.Ops.DoUpdate(APIServiceType, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *APIServiceClient) Replace(obj *APIService) (*APIService, error) {
|
||||
resp := &APIService{}
|
||||
err := c.apiClient.Ops.DoReplace(APIServiceType, &obj.Resource, obj, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *APIServiceClient) List(opts *types.ListOpts) (*APIServiceCollection, error) {
|
||||
resp := &APIServiceCollection{}
|
||||
err := c.apiClient.Ops.DoList(APIServiceType, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *APIServiceCollection) Next() (*APIServiceCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &APIServiceCollection{}
|
||||
err := cc.client.apiClient.Ops.DoNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *APIServiceClient) ByID(id string) (*APIService, error) {
|
||||
resp := &APIService{}
|
||||
err := c.apiClient.Ops.DoByID(APIServiceType, id, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *APIServiceClient) Delete(container *APIService) error {
|
||||
return c.apiClient.Ops.DoResourceDelete(APIServiceType, &container.Resource)
|
||||
}
|
18
client/cluster/v3/zz_generated_api_service_condition.go
Normal file
18
client/cluster/v3/zz_generated_api_service_condition.go
Normal file
@ -0,0 +1,18 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
APIServiceConditionType = "apiServiceCondition"
|
||||
APIServiceConditionFieldLastTransitionTime = "lastTransitionTime"
|
||||
APIServiceConditionFieldMessage = "message"
|
||||
APIServiceConditionFieldReason = "reason"
|
||||
APIServiceConditionFieldStatus = "status"
|
||||
APIServiceConditionFieldType = "type"
|
||||
)
|
||||
|
||||
type APIServiceCondition struct {
|
||||
LastTransitionTime string `json:"lastTransitionTime,omitempty" yaml:"lastTransitionTime,omitempty"`
|
||||
Message string `json:"message,omitempty" yaml:"message,omitempty"`
|
||||
Reason string `json:"reason,omitempty" yaml:"reason,omitempty"`
|
||||
Status string `json:"status,omitempty" yaml:"status,omitempty"`
|
||||
Type string `json:"type,omitempty" yaml:"type,omitempty"`
|
||||
}
|
22
client/cluster/v3/zz_generated_api_service_spec.go
Normal file
22
client/cluster/v3/zz_generated_api_service_spec.go
Normal file
@ -0,0 +1,22 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
APIServiceSpecType = "apiServiceSpec"
|
||||
APIServiceSpecFieldCABundle = "caBundle"
|
||||
APIServiceSpecFieldGroup = "group"
|
||||
APIServiceSpecFieldGroupPriorityMinimum = "groupPriorityMinimum"
|
||||
APIServiceSpecFieldInsecureSkipTLSVerify = "insecureSkipTLSVerify"
|
||||
APIServiceSpecFieldService = "service"
|
||||
APIServiceSpecFieldVersion = "version"
|
||||
APIServiceSpecFieldVersionPriority = "versionPriority"
|
||||
)
|
||||
|
||||
type APIServiceSpec struct {
|
||||
CABundle string `json:"caBundle,omitempty" yaml:"caBundle,omitempty"`
|
||||
Group string `json:"group,omitempty" yaml:"group,omitempty"`
|
||||
GroupPriorityMinimum int64 `json:"groupPriorityMinimum,omitempty" yaml:"groupPriorityMinimum,omitempty"`
|
||||
InsecureSkipTLSVerify bool `json:"insecureSkipTLSVerify,omitempty" yaml:"insecureSkipTLSVerify,omitempty"`
|
||||
Service *ServiceReference `json:"service,omitempty" yaml:"service,omitempty"`
|
||||
Version string `json:"version,omitempty" yaml:"version,omitempty"`
|
||||
VersionPriority int64 `json:"versionPriority,omitempty" yaml:"versionPriority,omitempty"`
|
||||
}
|
10
client/cluster/v3/zz_generated_api_service_status.go
Normal file
10
client/cluster/v3/zz_generated_api_service_status.go
Normal file
@ -0,0 +1,10 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
APIServiceStatusType = "apiServiceStatus"
|
||||
APIServiceStatusFieldConditions = "conditions"
|
||||
)
|
||||
|
||||
type APIServiceStatus struct {
|
||||
Conditions []APIServiceCondition `json:"conditions,omitempty" yaml:"conditions,omitempty"`
|
||||
}
|
@ -10,6 +10,7 @@ type Client struct {
|
||||
Namespace NamespaceOperations
|
||||
PersistentVolume PersistentVolumeOperations
|
||||
StorageClass StorageClassOperations
|
||||
APIService APIServiceOperations
|
||||
}
|
||||
|
||||
func NewClient(opts *clientbase.ClientOpts) (*Client, error) {
|
||||
@ -25,6 +26,7 @@ func NewClient(opts *clientbase.ClientOpts) (*Client, error) {
|
||||
client.Namespace = newNamespaceClient(client)
|
||||
client.PersistentVolume = newPersistentVolumeClient(client)
|
||||
client.StorageClass = newStorageClassClient(client)
|
||||
client.APIService = newAPIServiceClient(client)
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
12
client/cluster/v3/zz_generated_service_reference.go
Normal file
12
client/cluster/v3/zz_generated_service_reference.go
Normal file
@ -0,0 +1,12 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ServiceReferenceType = "serviceReference"
|
||||
ServiceReferenceFieldName = "name"
|
||||
ServiceReferenceFieldNamespace = "namespace"
|
||||
)
|
||||
|
||||
type ServiceReference struct {
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||
}
|
@ -73,6 +73,7 @@ type Config struct {
|
||||
Namespaces map[string]clusterClient.Namespace `json:"namespaces,omitempty" yaml:"namespaces,omitempty"`
|
||||
PersistentVolumes map[string]clusterClient.PersistentVolume `json:"persistentVolumes,omitempty" yaml:"persistentVolumes,omitempty"`
|
||||
StorageClasss map[string]clusterClient.StorageClass `json:"storageClasses,omitempty" yaml:"storageClasses,omitempty"`
|
||||
APIServices map[string]clusterClient.APIService `json:"apiServices,omitempty" yaml:"apiServices,omitempty"`
|
||||
|
||||
// Project Client
|
||||
PersistentVolumeClaims map[string]projectClient.PersistentVolumeClaim `json:"persistentVolumeClaims,omitempty" yaml:"persistentVolumeClaims,omitempty"`
|
||||
|
Loading…
Reference in New Issue
Block a user