diff --git a/apis/core/v1/zz_generated_component_status_controller.go b/apis/core/v1/zz_generated_component_status_controller.go new file mode 100644 index 00000000..5d7fd720 --- /dev/null +++ b/apis/core/v1/zz_generated_component_status_controller.go @@ -0,0 +1,188 @@ +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 ( + ComponentStatusGroupVersionKind = schema.GroupVersionKind{ + Version: "v1", + Group: "", + Kind: "ComponentStatus", + } + ComponentStatusResource = metav1.APIResource{ + Name: "componentstatuses", + SingularName: "componentstatus", + Namespaced: false, + Kind: ComponentStatusGroupVersionKind.Kind, + } +) + +type ComponentStatusList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []v1.ComponentStatus +} + +type ComponentStatusHandlerFunc func(key string, obj *v1.ComponentStatus) error + +type ComponentStatusLister interface { + List(namespace string, selector labels.Selector) (ret []*v1.ComponentStatus, err error) + Get(namespace, name string) (*v1.ComponentStatus, error) +} + +type ComponentStatusController interface { + Informer() cache.SharedIndexInformer + Lister() ComponentStatusLister + AddHandler(handler ComponentStatusHandlerFunc) + Enqueue(namespace, name string) + Sync(ctx context.Context) error + Start(ctx context.Context, threadiness int) error +} + +type ComponentStatusInterface interface { + ObjectClient() *clientbase.ObjectClient + Create(*v1.ComponentStatus) (*v1.ComponentStatus, error) + Get(name string, opts metav1.GetOptions) (*v1.ComponentStatus, error) + Update(*v1.ComponentStatus) (*v1.ComponentStatus, error) + Delete(name string, options *metav1.DeleteOptions) error + List(opts metav1.ListOptions) (*v1.ComponentStatusList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error + Controller() ComponentStatusController +} + +type componentStatusLister struct { + controller *componentStatusController +} + +func (l *componentStatusLister) List(namespace string, selector labels.Selector) (ret []*v1.ComponentStatus, err error) { + err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) { + ret = append(ret, obj.(*v1.ComponentStatus)) + }) + return +} + +func (l *componentStatusLister) Get(namespace, name string) (*v1.ComponentStatus, error) { + obj, exists, err := l.controller.Informer().GetIndexer().GetByKey(namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(schema.GroupResource{ + Group: ComponentStatusGroupVersionKind.Group, + Resource: "componentStatus", + }, name) + } + return obj.(*v1.ComponentStatus), nil +} + +type componentStatusController struct { + controller.GenericController +} + +func (c *componentStatusController) Lister() ComponentStatusLister { + return &componentStatusLister{ + controller: c, + } +} + +func (c *componentStatusController) AddHandler(handler ComponentStatusHandlerFunc) { + c.GenericController.AddHandler(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.ComponentStatus)) + }) +} + +type componentStatusFactory struct { +} + +func (c componentStatusFactory) Object() runtime.Object { + return &v1.ComponentStatus{} +} + +func (c componentStatusFactory) List() runtime.Object { + return &ComponentStatusList{} +} + +func (s *componentStatusClient) Controller() ComponentStatusController { + s.client.Lock() + defer s.client.Unlock() + + c, ok := s.client.componentStatusControllers[s.ns] + if ok { + return c + } + + genericController := controller.NewGenericController(ComponentStatusGroupVersionKind.Kind+"Controller", + s.objectClient) + + c = &componentStatusController{ + GenericController: genericController, + } + + s.client.componentStatusControllers[s.ns] = c + s.client.starters = append(s.client.starters, c) + + return c +} + +type componentStatusClient struct { + client *Client + ns string + objectClient *clientbase.ObjectClient + controller ComponentStatusController +} + +func (s *componentStatusClient) ObjectClient() *clientbase.ObjectClient { + return s.objectClient +} + +func (s *componentStatusClient) Create(o *v1.ComponentStatus) (*v1.ComponentStatus, error) { + obj, err := s.objectClient.Create(o) + return obj.(*v1.ComponentStatus), err +} + +func (s *componentStatusClient) Get(name string, opts metav1.GetOptions) (*v1.ComponentStatus, error) { + obj, err := s.objectClient.Get(name, opts) + return obj.(*v1.ComponentStatus), err +} + +func (s *componentStatusClient) Update(o *v1.ComponentStatus) (*v1.ComponentStatus, error) { + obj, err := s.objectClient.Update(o.Name, o) + return obj.(*v1.ComponentStatus), err +} + +func (s *componentStatusClient) Delete(name string, options *metav1.DeleteOptions) error { + return s.objectClient.Delete(name, options) +} + +func (s *componentStatusClient) List(opts metav1.ListOptions) (*v1.ComponentStatusList, error) { + obj, err := s.objectClient.List(opts) + return obj.(*v1.ComponentStatusList), err +} + +func (s *componentStatusClient) Watch(opts metav1.ListOptions) (watch.Interface, error) { + return s.objectClient.Watch(opts) +} + +func (s *componentStatusClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error { + return s.objectClient.DeleteCollection(deleteOpts, listOpts) +} diff --git a/apis/core/v1/zz_generated_deepcopy.go b/apis/core/v1/zz_generated_deepcopy.go index 43ef00f7..3d8bdbb4 100644 --- a/apis/core/v1/zz_generated_deepcopy.go +++ b/apis/core/v1/zz_generated_deepcopy.go @@ -5,6 +5,40 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ComponentStatusList) DeepCopyInto(out *ComponentStatusList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]core_v1.ComponentStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentStatusList. +func (in *ComponentStatusList) DeepCopy() *ComponentStatusList { + if in == nil { + return nil + } + out := new(ComponentStatusList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ComponentStatusList) 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 *NodeList) DeepCopyInto(out *NodeList) { *out = *in diff --git a/apis/core/v1/zz_generated_k8s_client.go b/apis/core/v1/zz_generated_k8s_client.go index bf8d8eec..3ec1b138 100644 --- a/apis/core/v1/zz_generated_k8s_client.go +++ b/apis/core/v1/zz_generated_k8s_client.go @@ -16,6 +16,7 @@ type Interface interface { PodsGetter NodesGetter + ComponentStatusesGetter } type Client struct { @@ -23,8 +24,9 @@ type Client struct { restClient rest.Interface starters []controller.Starter - podControllers map[string]PodController - nodeControllers map[string]NodeController + podControllers map[string]PodController + nodeControllers map[string]NodeController + componentStatusControllers map[string]ComponentStatusController } func NewForConfig(config rest.Config) (Interface, error) { @@ -41,8 +43,9 @@ func NewForConfig(config rest.Config) (Interface, error) { return &Client{ restClient: restClient, - podControllers: map[string]PodController{}, - nodeControllers: map[string]NodeController{}, + podControllers: map[string]PodController{}, + nodeControllers: map[string]NodeController{}, + componentStatusControllers: map[string]ComponentStatusController{}, }, nil } @@ -83,3 +86,16 @@ func (c *Client) Nodes(namespace string) NodeInterface { objectClient: objectClient, } } + +type ComponentStatusesGetter interface { + ComponentStatuses(namespace string) ComponentStatusInterface +} + +func (c *Client) ComponentStatuses(namespace string) ComponentStatusInterface { + objectClient := clientbase.NewObjectClient(namespace, c.restClient, &ComponentStatusResource, ComponentStatusGroupVersionKind, componentStatusFactory{}) + return &componentStatusClient{ + ns: namespace, + client: c, + objectClient: objectClient, + } +} diff --git a/main.go b/main.go index 3696ae2c..bcaabf2f 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,6 @@ func main() { generator.Generate(workloadSchema.Schemas) generator.Generate(authzSchema.Schemas) // Group by API group - generator.GenerateNativeTypes(v1.Pod{}, v1.Node{}) + generator.GenerateNativeTypes(v1.Pod{}, v1.Node{}, v1.ComponentStatus{}) generator.GenerateNativeTypes(v1beta2.Deployment{}) }