1
0
mirror of https://github.com/rancher/types.git synced 2025-09-15 22:39:05 +00:00

add configmap generated files

This commit is contained in:
Aiwantaozi
2018-02-09 05:17:55 +08:00
committed by Darren Shepherd
parent 57f82204bd
commit 58becba975
5 changed files with 360 additions and 0 deletions

View File

@@ -0,0 +1,253 @@
package v1
import (
"context"
"github.com/rancher/norman/clientbase"
"github.com/rancher/norman/controller"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
var (
ConfigMapGroupVersionKind = schema.GroupVersionKind{
Version: Version,
Group: GroupName,
Kind: "ConfigMap",
}
ConfigMapResource = metav1.APIResource{
Name: "configmaps",
SingularName: "configmap",
Namespaced: true,
Kind: ConfigMapGroupVersionKind.Kind,
}
)
type ConfigMapList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []v1.ConfigMap
}
type ConfigMapHandlerFunc func(key string, obj *v1.ConfigMap) error
type ConfigMapLister interface {
List(namespace string, selector labels.Selector) (ret []*v1.ConfigMap, err error)
Get(namespace, name string) (*v1.ConfigMap, error)
}
type ConfigMapController interface {
Informer() cache.SharedIndexInformer
Lister() ConfigMapLister
AddHandler(name string, handler ConfigMapHandlerFunc)
AddClusterScopedHandler(name, clusterName string, handler ConfigMapHandlerFunc)
Enqueue(namespace, name string)
Sync(ctx context.Context) error
Start(ctx context.Context, threadiness int) error
}
type ConfigMapInterface interface {
ObjectClient() *clientbase.ObjectClient
Create(*v1.ConfigMap) (*v1.ConfigMap, error)
GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ConfigMap, error)
Get(name string, opts metav1.GetOptions) (*v1.ConfigMap, error)
Update(*v1.ConfigMap) (*v1.ConfigMap, error)
Delete(name string, options *metav1.DeleteOptions) error
DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error
List(opts metav1.ListOptions) (*ConfigMapList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error
Controller() ConfigMapController
AddHandler(name string, sync ConfigMapHandlerFunc)
AddLifecycle(name string, lifecycle ConfigMapLifecycle)
AddClusterScopedHandler(name, clusterName string, sync ConfigMapHandlerFunc)
AddClusterScopedLifecycle(name, clusterName string, lifecycle ConfigMapLifecycle)
}
type configMapLister struct {
controller *configMapController
}
func (l *configMapLister) List(namespace string, selector labels.Selector) (ret []*v1.ConfigMap, err error) {
err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) {
ret = append(ret, obj.(*v1.ConfigMap))
})
return
}
func (l *configMapLister) Get(namespace, name string) (*v1.ConfigMap, error) {
var key string
if namespace != "" {
key = namespace + "/" + name
} else {
key = name
}
obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(schema.GroupResource{
Group: ConfigMapGroupVersionKind.Group,
Resource: "configMap",
}, name)
}
return obj.(*v1.ConfigMap), nil
}
type configMapController struct {
controller.GenericController
}
func (c *configMapController) Lister() ConfigMapLister {
return &configMapLister{
controller: c,
}
}
func (c *configMapController) AddHandler(name string, handler ConfigMapHandlerFunc) {
c.GenericController.AddHandler(name, func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
if err != nil {
return err
}
if !exists {
return handler(key, nil)
}
return handler(key, obj.(*v1.ConfigMap))
})
}
func (c *configMapController) AddClusterScopedHandler(name, cluster string, handler ConfigMapHandlerFunc) {
c.GenericController.AddHandler(name, func(key string) error {
obj, exists, err := c.Informer().GetStore().GetByKey(key)
if err != nil {
return err
}
if !exists {
return handler(key, nil)
}
if !controller.ObjectInCluster(cluster, obj) {
return nil
}
return handler(key, obj.(*v1.ConfigMap))
})
}
type configMapFactory struct {
}
func (c configMapFactory) Object() runtime.Object {
return &v1.ConfigMap{}
}
func (c configMapFactory) List() runtime.Object {
return &ConfigMapList{}
}
func (s *configMapClient) Controller() ConfigMapController {
s.client.Lock()
defer s.client.Unlock()
c, ok := s.client.configMapControllers[s.ns]
if ok {
return c
}
genericController := controller.NewGenericController(ConfigMapGroupVersionKind.Kind+"Controller",
s.objectClient)
c = &configMapController{
GenericController: genericController,
}
s.client.configMapControllers[s.ns] = c
s.client.starters = append(s.client.starters, c)
return c
}
type configMapClient struct {
client *Client
ns string
objectClient *clientbase.ObjectClient
controller ConfigMapController
}
func (s *configMapClient) ObjectClient() *clientbase.ObjectClient {
return s.objectClient
}
func (s *configMapClient) Create(o *v1.ConfigMap) (*v1.ConfigMap, error) {
obj, err := s.objectClient.Create(o)
return obj.(*v1.ConfigMap), err
}
func (s *configMapClient) Get(name string, opts metav1.GetOptions) (*v1.ConfigMap, error) {
obj, err := s.objectClient.Get(name, opts)
return obj.(*v1.ConfigMap), err
}
func (s *configMapClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1.ConfigMap, error) {
obj, err := s.objectClient.GetNamespaced(namespace, name, opts)
return obj.(*v1.ConfigMap), err
}
func (s *configMapClient) Update(o *v1.ConfigMap) (*v1.ConfigMap, error) {
obj, err := s.objectClient.Update(o.Name, o)
return obj.(*v1.ConfigMap), err
}
func (s *configMapClient) Delete(name string, options *metav1.DeleteOptions) error {
return s.objectClient.Delete(name, options)
}
func (s *configMapClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error {
return s.objectClient.DeleteNamespaced(namespace, name, options)
}
func (s *configMapClient) List(opts metav1.ListOptions) (*ConfigMapList, error) {
obj, err := s.objectClient.List(opts)
return obj.(*ConfigMapList), err
}
func (s *configMapClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return s.objectClient.Watch(opts)
}
// Patch applies the patch and returns the patched deployment.
func (s *configMapClient) Patch(o *v1.ConfigMap, data []byte, subresources ...string) (*v1.ConfigMap, error) {
obj, err := s.objectClient.Patch(o.Name, o, data, subresources...)
return obj.(*v1.ConfigMap), err
}
func (s *configMapClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error {
return s.objectClient.DeleteCollection(deleteOpts, listOpts)
}
func (s *configMapClient) AddHandler(name string, sync ConfigMapHandlerFunc) {
s.Controller().AddHandler(name, sync)
}
func (s *configMapClient) AddLifecycle(name string, lifecycle ConfigMapLifecycle) {
sync := NewConfigMapLifecycleAdapter(name, false, s, lifecycle)
s.AddHandler(name, sync)
}
func (s *configMapClient) AddClusterScopedHandler(name, clusterName string, sync ConfigMapHandlerFunc) {
s.Controller().AddClusterScopedHandler(name, clusterName, sync)
}
func (s *configMapClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle ConfigMapLifecycle) {
sync := NewConfigMapLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle)
s.AddClusterScopedHandler(name, clusterName, sync)
}

View File

@@ -0,0 +1,52 @@
package v1
import (
"github.com/rancher/norman/lifecycle"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
type ConfigMapLifecycle interface {
Create(obj *v1.ConfigMap) (*v1.ConfigMap, error)
Remove(obj *v1.ConfigMap) (*v1.ConfigMap, error)
Updated(obj *v1.ConfigMap) (*v1.ConfigMap, error)
}
type configMapLifecycleAdapter struct {
lifecycle ConfigMapLifecycle
}
func (w *configMapLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Create(obj.(*v1.ConfigMap))
if o == nil {
return nil, err
}
return o, err
}
func (w *configMapLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Remove(obj.(*v1.ConfigMap))
if o == nil {
return nil, err
}
return o, err
}
func (w *configMapLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) {
o, err := w.lifecycle.Updated(obj.(*v1.ConfigMap))
if o == nil {
return nil, err
}
return o, err
}
func NewConfigMapLifecycleAdapter(name string, clusterScoped bool, client ConfigMapInterface, l ConfigMapLifecycle) ConfigMapHandlerFunc {
adapter := &configMapLifecycleAdapter{lifecycle: l}
syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient())
return func(key string, obj *v1.ConfigMap) error {
if obj == nil {
return syncFn(key, nil)
}
return syncFn(key, obj)
}
}

View File

@@ -22,6 +22,10 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
in.(*ComponentStatusList).DeepCopyInto(out.(*ComponentStatusList))
return nil
}, InType: reflect.TypeOf(&ComponentStatusList{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*ConfigMapList).DeepCopyInto(out.(*ConfigMapList))
return nil
}, InType: reflect.TypeOf(&ConfigMapList{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*EndpointsList).DeepCopyInto(out.(*EndpointsList))
return nil
@@ -87,6 +91,40 @@ func (in *ComponentStatusList) DeepCopyObject() runtime.Object {
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ConfigMapList) DeepCopyInto(out *ConfigMapList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]core_v1.ConfigMap, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigMapList.
func (in *ConfigMapList) DeepCopy() *ConfigMapList {
if in == nil {
return nil
}
out := new(ConfigMapList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ConfigMapList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
} else {
return nil
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *EndpointsList) DeepCopyInto(out *EndpointsList) {
*out = *in

View File

@@ -22,6 +22,7 @@ type Interface interface {
PodsGetter
ServicesGetter
SecretsGetter
ConfigMapsGetter
}
type Client struct {
@@ -37,6 +38,7 @@ type Client struct {
podControllers map[string]PodController
serviceControllers map[string]ServiceController
secretControllers map[string]SecretController
configMapControllers map[string]ConfigMapController
}
func NewForConfig(config rest.Config) (Interface, error) {
@@ -61,6 +63,7 @@ func NewForConfig(config rest.Config) (Interface, error) {
podControllers: map[string]PodController{},
serviceControllers: map[string]ServiceController{},
secretControllers: map[string]SecretController{},
configMapControllers: map[string]ConfigMapController{},
}, nil
}
@@ -179,3 +182,16 @@ func (c *Client) Secrets(namespace string) SecretInterface {
objectClient: objectClient,
}
}
type ConfigMapsGetter interface {
ConfigMaps(namespace string) ConfigMapInterface
}
func (c *Client) ConfigMaps(namespace string) ConfigMapInterface {
objectClient := clientbase.NewObjectClient(namespace, c.restClient, &ConfigMapResource, ConfigMapGroupVersionKind, configMapFactory{})
return &configMapClient{
ns: namespace,
client: c,
objectClient: objectClient,
}
}

View File

@@ -41,6 +41,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&PodList{},
&ServiceList{},
&SecretList{},
&ConfigMapList{},
)
return nil
}