From 5d21399158a5eeb35cf2a8a86de7a5b18a05e30f Mon Sep 17 00:00:00 2001 From: zionwu Date: Sun, 11 Feb 2018 10:30:06 +0800 Subject: [PATCH] update generated code for alerting --- apis/apps/v1beta2/zz_generated_deepcopy.go | 38 + apis/apps/v1beta2/zz_generated_k8s_client.go | 24 +- apis/apps/v1beta2/zz_generated_scheme.go | 1 + .../zz_generated_stateful_set_controller.go | 253 +++++++ ...enerated_stateful_set_lifecycle_adapter.go | 52 ++ .../zz_generated_cluster_alert_controller.go | 252 +++++++ ...nerated_cluster_alert_lifecycle_adapter.go | 51 ++ .../v3/zz_generated_deepcopy.go | 654 ++++++++++++++++++ .../v3/zz_generated_k8s_client.go | 48 ++ .../v3/zz_generated_notifier_controller.go | 252 +++++++ ...zz_generated_notifier_lifecycle_adapter.go | 51 ++ .../zz_generated_project_alert_controller.go | 252 +++++++ ...nerated_project_alert_lifecycle_adapter.go | 51 ++ .../v3/zz_generated_scheme.go | 6 + .../v3/zz_generated_alert_status.go | 10 + client/management/v3/zz_generated_client.go | 6 + .../v3/zz_generated_cluster_alert.go | 121 ++++ .../v3/zz_generated_cluster_alert_spec.go | 28 + .../v3/zz_generated_notification.go | 18 + client/management/v3/zz_generated_notifier.go | 115 +++ .../v3/zz_generated_notifier_spec.go | 22 + .../v3/zz_generated_notifier_status.go | 8 + .../v3/zz_generated_pagerduty_config.go | 10 + .../v3/zz_generated_project_alert.go | 119 ++++ .../v3/zz_generated_project_alert_spec.go | 26 + .../management/v3/zz_generated_recipient.go | 14 + .../v3/zz_generated_slack_config.go | 12 + .../management/v3/zz_generated_smtp_config.go | 20 + .../v3/zz_generated_target_event.go | 12 + .../management/v3/zz_generated_target_node.go | 18 + .../management/v3/zz_generated_target_pod.go | 16 + .../v3/zz_generated_target_system_service.go | 10 + .../v3/zz_generated_target_workload.go | 16 + .../v3/zz_generated_webhook_config.go | 10 + 34 files changed, 2592 insertions(+), 4 deletions(-) create mode 100644 apis/apps/v1beta2/zz_generated_stateful_set_controller.go create mode 100644 apis/apps/v1beta2/zz_generated_stateful_set_lifecycle_adapter.go create mode 100644 apis/management.cattle.io/v3/zz_generated_cluster_alert_controller.go create mode 100644 apis/management.cattle.io/v3/zz_generated_cluster_alert_lifecycle_adapter.go create mode 100644 apis/management.cattle.io/v3/zz_generated_notifier_controller.go create mode 100644 apis/management.cattle.io/v3/zz_generated_notifier_lifecycle_adapter.go create mode 100644 apis/management.cattle.io/v3/zz_generated_project_alert_controller.go create mode 100644 apis/management.cattle.io/v3/zz_generated_project_alert_lifecycle_adapter.go create mode 100644 client/management/v3/zz_generated_alert_status.go create mode 100644 client/management/v3/zz_generated_cluster_alert.go create mode 100644 client/management/v3/zz_generated_cluster_alert_spec.go create mode 100644 client/management/v3/zz_generated_notification.go create mode 100644 client/management/v3/zz_generated_notifier.go create mode 100644 client/management/v3/zz_generated_notifier_spec.go create mode 100644 client/management/v3/zz_generated_notifier_status.go create mode 100644 client/management/v3/zz_generated_pagerduty_config.go create mode 100644 client/management/v3/zz_generated_project_alert.go create mode 100644 client/management/v3/zz_generated_project_alert_spec.go create mode 100644 client/management/v3/zz_generated_recipient.go create mode 100644 client/management/v3/zz_generated_slack_config.go create mode 100644 client/management/v3/zz_generated_smtp_config.go create mode 100644 client/management/v3/zz_generated_target_event.go create mode 100644 client/management/v3/zz_generated_target_node.go create mode 100644 client/management/v3/zz_generated_target_pod.go create mode 100644 client/management/v3/zz_generated_target_system_service.go create mode 100644 client/management/v3/zz_generated_target_workload.go create mode 100644 client/management/v3/zz_generated_webhook_config.go diff --git a/apis/apps/v1beta2/zz_generated_deepcopy.go b/apis/apps/v1beta2/zz_generated_deepcopy.go index 87375288..609baa60 100644 --- a/apis/apps/v1beta2/zz_generated_deepcopy.go +++ b/apis/apps/v1beta2/zz_generated_deepcopy.go @@ -26,6 +26,10 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*DeploymentList).DeepCopyInto(out.(*DeploymentList)) return nil }, InType: reflect.TypeOf(&DeploymentList{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*StatefulSetList).DeepCopyInto(out.(*StatefulSetList)) + return nil + }, InType: reflect.TypeOf(&StatefulSetList{})}, ) } @@ -96,3 +100,37 @@ func (in *DeploymentList) DeepCopyObject() runtime.Object { return nil } } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StatefulSetList) DeepCopyInto(out *StatefulSetList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]apps_v1beta2.StatefulSet, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatefulSetList. +func (in *StatefulSetList) DeepCopy() *StatefulSetList { + if in == nil { + return nil + } + out := new(StatefulSetList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StatefulSetList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } else { + return nil + } +} diff --git a/apis/apps/v1beta2/zz_generated_k8s_client.go b/apis/apps/v1beta2/zz_generated_k8s_client.go index 6eb1cb43..43ccadf5 100644 --- a/apis/apps/v1beta2/zz_generated_k8s_client.go +++ b/apis/apps/v1beta2/zz_generated_k8s_client.go @@ -16,6 +16,7 @@ type Interface interface { DeploymentsGetter DaemonSetsGetter + StatefulSetsGetter } type Client struct { @@ -23,8 +24,9 @@ type Client struct { restClient rest.Interface starters []controller.Starter - deploymentControllers map[string]DeploymentController - daemonSetControllers map[string]DaemonSetController + deploymentControllers map[string]DeploymentController + daemonSetControllers map[string]DaemonSetController + statefulSetControllers map[string]StatefulSetController } func NewForConfig(config rest.Config) (Interface, error) { @@ -41,8 +43,9 @@ func NewForConfig(config rest.Config) (Interface, error) { return &Client{ restClient: restClient, - deploymentControllers: map[string]DeploymentController{}, - daemonSetControllers: map[string]DaemonSetController{}, + deploymentControllers: map[string]DeploymentController{}, + daemonSetControllers: map[string]DaemonSetController{}, + statefulSetControllers: map[string]StatefulSetController{}, }, nil } @@ -83,3 +86,16 @@ func (c *Client) DaemonSets(namespace string) DaemonSetInterface { objectClient: objectClient, } } + +type StatefulSetsGetter interface { + StatefulSets(namespace string) StatefulSetInterface +} + +func (c *Client) StatefulSets(namespace string) StatefulSetInterface { + objectClient := clientbase.NewObjectClient(namespace, c.restClient, &StatefulSetResource, StatefulSetGroupVersionKind, statefulSetFactory{}) + return &statefulSetClient{ + ns: namespace, + client: c, + objectClient: objectClient, + } +} diff --git a/apis/apps/v1beta2/zz_generated_scheme.go b/apis/apps/v1beta2/zz_generated_scheme.go index 73001627..b425547d 100644 --- a/apis/apps/v1beta2/zz_generated_scheme.go +++ b/apis/apps/v1beta2/zz_generated_scheme.go @@ -35,6 +35,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { &DeploymentList{}, &DaemonSetList{}, + &StatefulSetList{}, ) return nil } diff --git a/apis/apps/v1beta2/zz_generated_stateful_set_controller.go b/apis/apps/v1beta2/zz_generated_stateful_set_controller.go new file mode 100644 index 00000000..307add8b --- /dev/null +++ b/apis/apps/v1beta2/zz_generated_stateful_set_controller.go @@ -0,0 +1,253 @@ +package v1beta2 + +import ( + "context" + + "github.com/rancher/norman/clientbase" + "github.com/rancher/norman/controller" + "k8s.io/api/apps/v1beta2" + "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 ( + StatefulSetGroupVersionKind = schema.GroupVersionKind{ + Version: Version, + Group: GroupName, + Kind: "StatefulSet", + } + StatefulSetResource = metav1.APIResource{ + Name: "statefulsets", + SingularName: "statefulset", + Namespaced: true, + + Kind: StatefulSetGroupVersionKind.Kind, + } +) + +type StatefulSetList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []v1beta2.StatefulSet +} + +type StatefulSetHandlerFunc func(key string, obj *v1beta2.StatefulSet) error + +type StatefulSetLister interface { + List(namespace string, selector labels.Selector) (ret []*v1beta2.StatefulSet, err error) + Get(namespace, name string) (*v1beta2.StatefulSet, error) +} + +type StatefulSetController interface { + Informer() cache.SharedIndexInformer + Lister() StatefulSetLister + AddHandler(name string, handler StatefulSetHandlerFunc) + AddClusterScopedHandler(name, clusterName string, handler StatefulSetHandlerFunc) + Enqueue(namespace, name string) + Sync(ctx context.Context) error + Start(ctx context.Context, threadiness int) error +} + +type StatefulSetInterface interface { + ObjectClient() *clientbase.ObjectClient + Create(*v1beta2.StatefulSet) (*v1beta2.StatefulSet, error) + GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1beta2.StatefulSet, error) + Get(name string, opts metav1.GetOptions) (*v1beta2.StatefulSet, error) + Update(*v1beta2.StatefulSet) (*v1beta2.StatefulSet, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error + List(opts metav1.ListOptions) (*StatefulSetList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error + Controller() StatefulSetController + AddHandler(name string, sync StatefulSetHandlerFunc) + AddLifecycle(name string, lifecycle StatefulSetLifecycle) + AddClusterScopedHandler(name, clusterName string, sync StatefulSetHandlerFunc) + AddClusterScopedLifecycle(name, clusterName string, lifecycle StatefulSetLifecycle) +} + +type statefulSetLister struct { + controller *statefulSetController +} + +func (l *statefulSetLister) List(namespace string, selector labels.Selector) (ret []*v1beta2.StatefulSet, err error) { + err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) { + ret = append(ret, obj.(*v1beta2.StatefulSet)) + }) + return +} + +func (l *statefulSetLister) Get(namespace, name string) (*v1beta2.StatefulSet, 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: StatefulSetGroupVersionKind.Group, + Resource: "statefulSet", + }, name) + } + return obj.(*v1beta2.StatefulSet), nil +} + +type statefulSetController struct { + controller.GenericController +} + +func (c *statefulSetController) Lister() StatefulSetLister { + return &statefulSetLister{ + controller: c, + } +} + +func (c *statefulSetController) AddHandler(name string, handler StatefulSetHandlerFunc) { + 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.(*v1beta2.StatefulSet)) + }) +} + +func (c *statefulSetController) AddClusterScopedHandler(name, cluster string, handler StatefulSetHandlerFunc) { + 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.(*v1beta2.StatefulSet)) + }) +} + +type statefulSetFactory struct { +} + +func (c statefulSetFactory) Object() runtime.Object { + return &v1beta2.StatefulSet{} +} + +func (c statefulSetFactory) List() runtime.Object { + return &StatefulSetList{} +} + +func (s *statefulSetClient) Controller() StatefulSetController { + s.client.Lock() + defer s.client.Unlock() + + c, ok := s.client.statefulSetControllers[s.ns] + if ok { + return c + } + + genericController := controller.NewGenericController(StatefulSetGroupVersionKind.Kind+"Controller", + s.objectClient) + + c = &statefulSetController{ + GenericController: genericController, + } + + s.client.statefulSetControllers[s.ns] = c + s.client.starters = append(s.client.starters, c) + + return c +} + +type statefulSetClient struct { + client *Client + ns string + objectClient *clientbase.ObjectClient + controller StatefulSetController +} + +func (s *statefulSetClient) ObjectClient() *clientbase.ObjectClient { + return s.objectClient +} + +func (s *statefulSetClient) Create(o *v1beta2.StatefulSet) (*v1beta2.StatefulSet, error) { + obj, err := s.objectClient.Create(o) + return obj.(*v1beta2.StatefulSet), err +} + +func (s *statefulSetClient) Get(name string, opts metav1.GetOptions) (*v1beta2.StatefulSet, error) { + obj, err := s.objectClient.Get(name, opts) + return obj.(*v1beta2.StatefulSet), err +} + +func (s *statefulSetClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*v1beta2.StatefulSet, error) { + obj, err := s.objectClient.GetNamespaced(namespace, name, opts) + return obj.(*v1beta2.StatefulSet), err +} + +func (s *statefulSetClient) Update(o *v1beta2.StatefulSet) (*v1beta2.StatefulSet, error) { + obj, err := s.objectClient.Update(o.Name, o) + return obj.(*v1beta2.StatefulSet), err +} + +func (s *statefulSetClient) Delete(name string, options *metav1.DeleteOptions) error { + return s.objectClient.Delete(name, options) +} + +func (s *statefulSetClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error { + return s.objectClient.DeleteNamespaced(namespace, name, options) +} + +func (s *statefulSetClient) List(opts metav1.ListOptions) (*StatefulSetList, error) { + obj, err := s.objectClient.List(opts) + return obj.(*StatefulSetList), err +} + +func (s *statefulSetClient) Watch(opts metav1.ListOptions) (watch.Interface, error) { + return s.objectClient.Watch(opts) +} + +// Patch applies the patch and returns the patched deployment. +func (s *statefulSetClient) Patch(o *v1beta2.StatefulSet, data []byte, subresources ...string) (*v1beta2.StatefulSet, error) { + obj, err := s.objectClient.Patch(o.Name, o, data, subresources...) + return obj.(*v1beta2.StatefulSet), err +} + +func (s *statefulSetClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error { + return s.objectClient.DeleteCollection(deleteOpts, listOpts) +} + +func (s *statefulSetClient) AddHandler(name string, sync StatefulSetHandlerFunc) { + s.Controller().AddHandler(name, sync) +} + +func (s *statefulSetClient) AddLifecycle(name string, lifecycle StatefulSetLifecycle) { + sync := NewStatefulSetLifecycleAdapter(name, false, s, lifecycle) + s.AddHandler(name, sync) +} + +func (s *statefulSetClient) AddClusterScopedHandler(name, clusterName string, sync StatefulSetHandlerFunc) { + s.Controller().AddClusterScopedHandler(name, clusterName, sync) +} + +func (s *statefulSetClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle StatefulSetLifecycle) { + sync := NewStatefulSetLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle) + s.AddClusterScopedHandler(name, clusterName, sync) +} diff --git a/apis/apps/v1beta2/zz_generated_stateful_set_lifecycle_adapter.go b/apis/apps/v1beta2/zz_generated_stateful_set_lifecycle_adapter.go new file mode 100644 index 00000000..340e6977 --- /dev/null +++ b/apis/apps/v1beta2/zz_generated_stateful_set_lifecycle_adapter.go @@ -0,0 +1,52 @@ +package v1beta2 + +import ( + "github.com/rancher/norman/lifecycle" + "k8s.io/api/apps/v1beta2" + "k8s.io/apimachinery/pkg/runtime" +) + +type StatefulSetLifecycle interface { + Create(obj *v1beta2.StatefulSet) (*v1beta2.StatefulSet, error) + Remove(obj *v1beta2.StatefulSet) (*v1beta2.StatefulSet, error) + Updated(obj *v1beta2.StatefulSet) (*v1beta2.StatefulSet, error) +} + +type statefulSetLifecycleAdapter struct { + lifecycle StatefulSetLifecycle +} + +func (w *statefulSetLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Create(obj.(*v1beta2.StatefulSet)) + if o == nil { + return nil, err + } + return o, err +} + +func (w *statefulSetLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Remove(obj.(*v1beta2.StatefulSet)) + if o == nil { + return nil, err + } + return o, err +} + +func (w *statefulSetLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Updated(obj.(*v1beta2.StatefulSet)) + if o == nil { + return nil, err + } + return o, err +} + +func NewStatefulSetLifecycleAdapter(name string, clusterScoped bool, client StatefulSetInterface, l StatefulSetLifecycle) StatefulSetHandlerFunc { + adapter := &statefulSetLifecycleAdapter{lifecycle: l} + syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient()) + return func(key string, obj *v1beta2.StatefulSet) error { + if obj == nil { + return syncFn(key, nil) + } + return syncFn(key, obj) + } +} diff --git a/apis/management.cattle.io/v3/zz_generated_cluster_alert_controller.go b/apis/management.cattle.io/v3/zz_generated_cluster_alert_controller.go new file mode 100644 index 00000000..b81aa40e --- /dev/null +++ b/apis/management.cattle.io/v3/zz_generated_cluster_alert_controller.go @@ -0,0 +1,252 @@ +package v3 + +import ( + "context" + + "github.com/rancher/norman/clientbase" + "github.com/rancher/norman/controller" + "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 ( + ClusterAlertGroupVersionKind = schema.GroupVersionKind{ + Version: Version, + Group: GroupName, + Kind: "ClusterAlert", + } + ClusterAlertResource = metav1.APIResource{ + Name: "clusteralerts", + SingularName: "clusteralert", + Namespaced: true, + + Kind: ClusterAlertGroupVersionKind.Kind, + } +) + +type ClusterAlertList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ClusterAlert +} + +type ClusterAlertHandlerFunc func(key string, obj *ClusterAlert) error + +type ClusterAlertLister interface { + List(namespace string, selector labels.Selector) (ret []*ClusterAlert, err error) + Get(namespace, name string) (*ClusterAlert, error) +} + +type ClusterAlertController interface { + Informer() cache.SharedIndexInformer + Lister() ClusterAlertLister + AddHandler(name string, handler ClusterAlertHandlerFunc) + AddClusterScopedHandler(name, clusterName string, handler ClusterAlertHandlerFunc) + Enqueue(namespace, name string) + Sync(ctx context.Context) error + Start(ctx context.Context, threadiness int) error +} + +type ClusterAlertInterface interface { + ObjectClient() *clientbase.ObjectClient + Create(*ClusterAlert) (*ClusterAlert, error) + GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ClusterAlert, error) + Get(name string, opts metav1.GetOptions) (*ClusterAlert, error) + Update(*ClusterAlert) (*ClusterAlert, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error + List(opts metav1.ListOptions) (*ClusterAlertList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error + Controller() ClusterAlertController + AddHandler(name string, sync ClusterAlertHandlerFunc) + AddLifecycle(name string, lifecycle ClusterAlertLifecycle) + AddClusterScopedHandler(name, clusterName string, sync ClusterAlertHandlerFunc) + AddClusterScopedLifecycle(name, clusterName string, lifecycle ClusterAlertLifecycle) +} + +type clusterAlertLister struct { + controller *clusterAlertController +} + +func (l *clusterAlertLister) List(namespace string, selector labels.Selector) (ret []*ClusterAlert, err error) { + err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) { + ret = append(ret, obj.(*ClusterAlert)) + }) + return +} + +func (l *clusterAlertLister) Get(namespace, name string) (*ClusterAlert, 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: ClusterAlertGroupVersionKind.Group, + Resource: "clusterAlert", + }, name) + } + return obj.(*ClusterAlert), nil +} + +type clusterAlertController struct { + controller.GenericController +} + +func (c *clusterAlertController) Lister() ClusterAlertLister { + return &clusterAlertLister{ + controller: c, + } +} + +func (c *clusterAlertController) AddHandler(name string, handler ClusterAlertHandlerFunc) { + 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.(*ClusterAlert)) + }) +} + +func (c *clusterAlertController) AddClusterScopedHandler(name, cluster string, handler ClusterAlertHandlerFunc) { + 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.(*ClusterAlert)) + }) +} + +type clusterAlertFactory struct { +} + +func (c clusterAlertFactory) Object() runtime.Object { + return &ClusterAlert{} +} + +func (c clusterAlertFactory) List() runtime.Object { + return &ClusterAlertList{} +} + +func (s *clusterAlertClient) Controller() ClusterAlertController { + s.client.Lock() + defer s.client.Unlock() + + c, ok := s.client.clusterAlertControllers[s.ns] + if ok { + return c + } + + genericController := controller.NewGenericController(ClusterAlertGroupVersionKind.Kind+"Controller", + s.objectClient) + + c = &clusterAlertController{ + GenericController: genericController, + } + + s.client.clusterAlertControllers[s.ns] = c + s.client.starters = append(s.client.starters, c) + + return c +} + +type clusterAlertClient struct { + client *Client + ns string + objectClient *clientbase.ObjectClient + controller ClusterAlertController +} + +func (s *clusterAlertClient) ObjectClient() *clientbase.ObjectClient { + return s.objectClient +} + +func (s *clusterAlertClient) Create(o *ClusterAlert) (*ClusterAlert, error) { + obj, err := s.objectClient.Create(o) + return obj.(*ClusterAlert), err +} + +func (s *clusterAlertClient) Get(name string, opts metav1.GetOptions) (*ClusterAlert, error) { + obj, err := s.objectClient.Get(name, opts) + return obj.(*ClusterAlert), err +} + +func (s *clusterAlertClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ClusterAlert, error) { + obj, err := s.objectClient.GetNamespaced(namespace, name, opts) + return obj.(*ClusterAlert), err +} + +func (s *clusterAlertClient) Update(o *ClusterAlert) (*ClusterAlert, error) { + obj, err := s.objectClient.Update(o.Name, o) + return obj.(*ClusterAlert), err +} + +func (s *clusterAlertClient) Delete(name string, options *metav1.DeleteOptions) error { + return s.objectClient.Delete(name, options) +} + +func (s *clusterAlertClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error { + return s.objectClient.DeleteNamespaced(namespace, name, options) +} + +func (s *clusterAlertClient) List(opts metav1.ListOptions) (*ClusterAlertList, error) { + obj, err := s.objectClient.List(opts) + return obj.(*ClusterAlertList), err +} + +func (s *clusterAlertClient) Watch(opts metav1.ListOptions) (watch.Interface, error) { + return s.objectClient.Watch(opts) +} + +// Patch applies the patch and returns the patched deployment. +func (s *clusterAlertClient) Patch(o *ClusterAlert, data []byte, subresources ...string) (*ClusterAlert, error) { + obj, err := s.objectClient.Patch(o.Name, o, data, subresources...) + return obj.(*ClusterAlert), err +} + +func (s *clusterAlertClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error { + return s.objectClient.DeleteCollection(deleteOpts, listOpts) +} + +func (s *clusterAlertClient) AddHandler(name string, sync ClusterAlertHandlerFunc) { + s.Controller().AddHandler(name, sync) +} + +func (s *clusterAlertClient) AddLifecycle(name string, lifecycle ClusterAlertLifecycle) { + sync := NewClusterAlertLifecycleAdapter(name, false, s, lifecycle) + s.AddHandler(name, sync) +} + +func (s *clusterAlertClient) AddClusterScopedHandler(name, clusterName string, sync ClusterAlertHandlerFunc) { + s.Controller().AddClusterScopedHandler(name, clusterName, sync) +} + +func (s *clusterAlertClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle ClusterAlertLifecycle) { + sync := NewClusterAlertLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle) + s.AddClusterScopedHandler(name, clusterName, sync) +} diff --git a/apis/management.cattle.io/v3/zz_generated_cluster_alert_lifecycle_adapter.go b/apis/management.cattle.io/v3/zz_generated_cluster_alert_lifecycle_adapter.go new file mode 100644 index 00000000..4d44fb31 --- /dev/null +++ b/apis/management.cattle.io/v3/zz_generated_cluster_alert_lifecycle_adapter.go @@ -0,0 +1,51 @@ +package v3 + +import ( + "github.com/rancher/norman/lifecycle" + "k8s.io/apimachinery/pkg/runtime" +) + +type ClusterAlertLifecycle interface { + Create(obj *ClusterAlert) (*ClusterAlert, error) + Remove(obj *ClusterAlert) (*ClusterAlert, error) + Updated(obj *ClusterAlert) (*ClusterAlert, error) +} + +type clusterAlertLifecycleAdapter struct { + lifecycle ClusterAlertLifecycle +} + +func (w *clusterAlertLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Create(obj.(*ClusterAlert)) + if o == nil { + return nil, err + } + return o, err +} + +func (w *clusterAlertLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Remove(obj.(*ClusterAlert)) + if o == nil { + return nil, err + } + return o, err +} + +func (w *clusterAlertLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Updated(obj.(*ClusterAlert)) + if o == nil { + return nil, err + } + return o, err +} + +func NewClusterAlertLifecycleAdapter(name string, clusterScoped bool, client ClusterAlertInterface, l ClusterAlertLifecycle) ClusterAlertHandlerFunc { + adapter := &clusterAlertLifecycleAdapter{lifecycle: l} + syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient()) + return func(key string, obj *ClusterAlert) error { + if obj == nil { + return syncFn(key, nil) + } + return syncFn(key, obj) + } +} diff --git a/apis/management.cattle.io/v3/zz_generated_deepcopy.go b/apis/management.cattle.io/v3/zz_generated_deepcopy.go index 84b8b772..328a7f27 100644 --- a/apis/management.cattle.io/v3/zz_generated_deepcopy.go +++ b/apis/management.cattle.io/v3/zz_generated_deepcopy.go @@ -23,6 +23,14 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*Action).DeepCopyInto(out.(*Action)) return nil }, InType: reflect.TypeOf(&Action{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*AlertCommonSpec).DeepCopyInto(out.(*AlertCommonSpec)) + return nil + }, InType: reflect.TypeOf(&AlertCommonSpec{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*AlertStatus).DeepCopyInto(out.(*AlertStatus)) + return nil + }, InType: reflect.TypeOf(&AlertStatus{})}, conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { in.(*AuthConfig).DeepCopyInto(out.(*AuthConfig)) return nil @@ -71,6 +79,18 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*Cluster).DeepCopyInto(out.(*Cluster)) return nil }, InType: reflect.TypeOf(&Cluster{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*ClusterAlert).DeepCopyInto(out.(*ClusterAlert)) + return nil + }, InType: reflect.TypeOf(&ClusterAlert{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*ClusterAlertList).DeepCopyInto(out.(*ClusterAlertList)) + return nil + }, InType: reflect.TypeOf(&ClusterAlertList{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*ClusterAlertSpec).DeepCopyInto(out.(*ClusterAlertSpec)) + return nil + }, InType: reflect.TypeOf(&ClusterAlertSpec{})}, conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { in.(*ClusterComponentStatus).DeepCopyInto(out.(*ClusterComponentStatus)) return nil @@ -359,6 +379,30 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*NetworkConfig).DeepCopyInto(out.(*NetworkConfig)) return nil }, InType: reflect.TypeOf(&NetworkConfig{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*Notification).DeepCopyInto(out.(*Notification)) + return nil + }, InType: reflect.TypeOf(&Notification{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*Notifier).DeepCopyInto(out.(*Notifier)) + return nil + }, InType: reflect.TypeOf(&Notifier{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*NotifierList).DeepCopyInto(out.(*NotifierList)) + return nil + }, InType: reflect.TypeOf(&NotifierList{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*NotifierSpec).DeepCopyInto(out.(*NotifierSpec)) + return nil + }, InType: reflect.TypeOf(&NotifierSpec{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*NotifierStatus).DeepCopyInto(out.(*NotifierStatus)) + return nil + }, InType: reflect.TypeOf(&NotifierStatus{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*PagerdutyConfig).DeepCopyInto(out.(*PagerdutyConfig)) + return nil + }, InType: reflect.TypeOf(&PagerdutyConfig{})}, conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { in.(*PodSecurityPolicyTemplate).DeepCopyInto(out.(*PodSecurityPolicyTemplate)) return nil @@ -391,6 +435,18 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*Project).DeepCopyInto(out.(*Project)) return nil }, InType: reflect.TypeOf(&Project{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*ProjectAlert).DeepCopyInto(out.(*ProjectAlert)) + return nil + }, InType: reflect.TypeOf(&ProjectAlert{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*ProjectAlertList).DeepCopyInto(out.(*ProjectAlertList)) + return nil + }, InType: reflect.TypeOf(&ProjectAlertList{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*ProjectAlertSpec).DeepCopyInto(out.(*ProjectAlertSpec)) + return nil + }, InType: reflect.TypeOf(&ProjectAlertSpec{})}, conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { in.(*ProjectCondition).DeepCopyInto(out.(*ProjectCondition)) return nil @@ -447,6 +503,10 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*RancherKubernetesEngineConfig).DeepCopyInto(out.(*RancherKubernetesEngineConfig)) return nil }, InType: reflect.TypeOf(&RancherKubernetesEngineConfig{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*Recipient).DeepCopyInto(out.(*Recipient)) + return nil + }, InType: reflect.TypeOf(&Recipient{})}, conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { in.(*RoleTemplate).DeepCopyInto(out.(*RoleTemplate)) return nil @@ -455,6 +515,10 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*RoleTemplateList).DeepCopyInto(out.(*RoleTemplateList)) return nil }, InType: reflect.TypeOf(&RoleTemplateList{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*SMTPConfig).DeepCopyInto(out.(*SMTPConfig)) + return nil + }, InType: reflect.TypeOf(&SMTPConfig{})}, conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { in.(*SchedulerService).DeepCopyInto(out.(*SchedulerService)) return nil @@ -475,6 +539,10 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*SettingList).DeepCopyInto(out.(*SettingList)) return nil }, InType: reflect.TypeOf(&SettingList{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*SlackConfig).DeepCopyInto(out.(*SlackConfig)) + return nil + }, InType: reflect.TypeOf(&SlackConfig{})}, conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { in.(*SplunkConfig).DeepCopyInto(out.(*SplunkConfig)) return nil @@ -483,6 +551,26 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*SyslogConfig).DeepCopyInto(out.(*SyslogConfig)) return nil }, InType: reflect.TypeOf(&SyslogConfig{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*TargetEvent).DeepCopyInto(out.(*TargetEvent)) + return nil + }, InType: reflect.TypeOf(&TargetEvent{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*TargetNode).DeepCopyInto(out.(*TargetNode)) + return nil + }, InType: reflect.TypeOf(&TargetNode{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*TargetPod).DeepCopyInto(out.(*TargetPod)) + return nil + }, InType: reflect.TypeOf(&TargetPod{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*TargetSystemService).DeepCopyInto(out.(*TargetSystemService)) + return nil + }, InType: reflect.TypeOf(&TargetSystemService{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*TargetWorkload).DeepCopyInto(out.(*TargetWorkload)) + return nil + }, InType: reflect.TypeOf(&TargetWorkload{})}, conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { in.(*Template).DeepCopyInto(out.(*Template)) return nil @@ -539,6 +627,10 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error { in.(*VersionCommits).DeepCopyInto(out.(*VersionCommits)) return nil }, InType: reflect.TypeOf(&VersionCommits{})}, + conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error { + in.(*WebhookConfig).DeepCopyInto(out.(*WebhookConfig)) + return nil + }, InType: reflect.TypeOf(&WebhookConfig{})}, ) } @@ -558,6 +650,43 @@ func (in *Action) DeepCopy() *Action { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AlertCommonSpec) DeepCopyInto(out *AlertCommonSpec) { + *out = *in + if in.Recipients != nil { + in, out := &in.Recipients, &out.Recipients + *out = make([]Recipient, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AlertCommonSpec. +func (in *AlertCommonSpec) DeepCopy() *AlertCommonSpec { + if in == nil { + return nil + } + out := new(AlertCommonSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AlertStatus) DeepCopyInto(out *AlertStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AlertStatus. +func (in *AlertStatus) DeepCopy() *AlertStatus { + if in == nil { + return nil + } + out := new(AlertStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AuthConfig) DeepCopyInto(out *AuthConfig) { *out = *in @@ -858,6 +987,90 @@ func (in *Cluster) DeepCopyObject() runtime.Object { } } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterAlert) DeepCopyInto(out *ClusterAlert) { + *out = *in + out.Namespaced = in.Namespaced + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterAlert. +func (in *ClusterAlert) DeepCopy() *ClusterAlert { + if in == nil { + return nil + } + out := new(ClusterAlert) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterAlert) 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 *ClusterAlertList) DeepCopyInto(out *ClusterAlertList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterAlert, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterAlertList. +func (in *ClusterAlertList) DeepCopy() *ClusterAlertList { + if in == nil { + return nil + } + out := new(ClusterAlertList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterAlertList) 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 *ClusterAlertSpec) DeepCopyInto(out *ClusterAlertSpec) { + *out = *in + in.AlertCommonSpec.DeepCopyInto(&out.AlertCommonSpec) + in.TargetNode.DeepCopyInto(&out.TargetNode) + out.TargetSystemService = in.TargetSystemService + out.TargetEvent = in.TargetEvent + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterAlertSpec. +func (in *ClusterAlertSpec) DeepCopy() *ClusterAlertSpec { + if in == nil { + return nil + } + out := new(ClusterAlertSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterComponentStatus) DeepCopyInto(out *ClusterComponentStatus) { *out = *in @@ -2892,6 +3105,206 @@ func (in *NetworkConfig) DeepCopy() *NetworkConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Notification) DeepCopyInto(out *Notification) { + *out = *in + if in.SMTPConfig != nil { + in, out := &in.SMTPConfig, &out.SMTPConfig + if *in == nil { + *out = nil + } else { + *out = new(SMTPConfig) + **out = **in + } + } + if in.SlackConfig != nil { + in, out := &in.SlackConfig, &out.SlackConfig + if *in == nil { + *out = nil + } else { + *out = new(SlackConfig) + **out = **in + } + } + if in.PagerdutyConfig != nil { + in, out := &in.PagerdutyConfig, &out.PagerdutyConfig + if *in == nil { + *out = nil + } else { + *out = new(PagerdutyConfig) + **out = **in + } + } + if in.WebhookConfig != nil { + in, out := &in.WebhookConfig, &out.WebhookConfig + if *in == nil { + *out = nil + } else { + *out = new(WebhookConfig) + **out = **in + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Notification. +func (in *Notification) DeepCopy() *Notification { + if in == nil { + return nil + } + out := new(Notification) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Notifier) DeepCopyInto(out *Notifier) { + *out = *in + out.Namespaced = in.Namespaced + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Notifier. +func (in *Notifier) DeepCopy() *Notifier { + if in == nil { + return nil + } + out := new(Notifier) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Notifier) 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 *NotifierList) DeepCopyInto(out *NotifierList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Notifier, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotifierList. +func (in *NotifierList) DeepCopy() *NotifierList { + if in == nil { + return nil + } + out := new(NotifierList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NotifierList) 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 *NotifierSpec) DeepCopyInto(out *NotifierSpec) { + *out = *in + if in.SMTPConfig != nil { + in, out := &in.SMTPConfig, &out.SMTPConfig + if *in == nil { + *out = nil + } else { + *out = new(SMTPConfig) + **out = **in + } + } + if in.SlackConfig != nil { + in, out := &in.SlackConfig, &out.SlackConfig + if *in == nil { + *out = nil + } else { + *out = new(SlackConfig) + **out = **in + } + } + if in.PagerdutyConfig != nil { + in, out := &in.PagerdutyConfig, &out.PagerdutyConfig + if *in == nil { + *out = nil + } else { + *out = new(PagerdutyConfig) + **out = **in + } + } + if in.WebhookConfig != nil { + in, out := &in.WebhookConfig, &out.WebhookConfig + if *in == nil { + *out = nil + } else { + *out = new(WebhookConfig) + **out = **in + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotifierSpec. +func (in *NotifierSpec) DeepCopy() *NotifierSpec { + if in == nil { + return nil + } + out := new(NotifierSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NotifierStatus) DeepCopyInto(out *NotifierStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotifierStatus. +func (in *NotifierStatus) DeepCopy() *NotifierStatus { + if in == nil { + return nil + } + out := new(NotifierStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PagerdutyConfig) DeepCopyInto(out *PagerdutyConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PagerdutyConfig. +func (in *PagerdutyConfig) DeepCopy() *PagerdutyConfig { + if in == nil { + return nil + } + out := new(PagerdutyConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PodSecurityPolicyTemplate) DeepCopyInto(out *PodSecurityPolicyTemplate) { *out = *in @@ -3130,6 +3543,89 @@ func (in *Project) DeepCopyObject() runtime.Object { } } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ProjectAlert) DeepCopyInto(out *ProjectAlert) { + *out = *in + out.Namespaced = in.Namespaced + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProjectAlert. +func (in *ProjectAlert) DeepCopy() *ProjectAlert { + if in == nil { + return nil + } + out := new(ProjectAlert) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ProjectAlert) 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 *ProjectAlertList) DeepCopyInto(out *ProjectAlertList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ProjectAlert, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProjectAlertList. +func (in *ProjectAlertList) DeepCopy() *ProjectAlertList { + if in == nil { + return nil + } + out := new(ProjectAlertList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ProjectAlertList) 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 *ProjectAlertSpec) DeepCopyInto(out *ProjectAlertSpec) { + *out = *in + in.AlertCommonSpec.DeepCopyInto(&out.AlertCommonSpec) + in.TargetWorkload.DeepCopyInto(&out.TargetWorkload) + out.TargetPod = in.TargetPod + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProjectAlertSpec. +func (in *ProjectAlertSpec) DeepCopy() *ProjectAlertSpec { + if in == nil { + return nil + } + out := new(ProjectAlertSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ProjectCondition) DeepCopyInto(out *ProjectCondition) { *out = *in @@ -3481,6 +3977,22 @@ func (in *RancherKubernetesEngineConfig) DeepCopy() *RancherKubernetesEngineConf return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Recipient) DeepCopyInto(out *Recipient) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Recipient. +func (in *Recipient) DeepCopy() *Recipient { + if in == nil { + return nil + } + out := new(Recipient) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RoleTemplate) DeepCopyInto(out *RoleTemplate) { *out = *in @@ -3554,6 +4066,22 @@ func (in *RoleTemplateList) DeepCopyObject() runtime.Object { } } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SMTPConfig) DeepCopyInto(out *SMTPConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SMTPConfig. +func (in *SMTPConfig) DeepCopy() *SMTPConfig { + if in == nil { + return nil + } + out := new(SMTPConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SchedulerService) DeepCopyInto(out *SchedulerService) { *out = *in @@ -3664,6 +4192,22 @@ func (in *SettingList) DeepCopyObject() runtime.Object { } } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SlackConfig) DeepCopyInto(out *SlackConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SlackConfig. +func (in *SlackConfig) DeepCopy() *SlackConfig { + if in == nil { + return nil + } + out := new(SlackConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SplunkConfig) DeepCopyInto(out *SplunkConfig) { *out = *in @@ -3696,6 +4240,100 @@ func (in *SyslogConfig) DeepCopy() *SyslogConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TargetEvent) DeepCopyInto(out *TargetEvent) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetEvent. +func (in *TargetEvent) DeepCopy() *TargetEvent { + if in == nil { + return nil + } + out := new(TargetEvent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TargetNode) DeepCopyInto(out *TargetNode) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetNode. +func (in *TargetNode) DeepCopy() *TargetNode { + if in == nil { + return nil + } + out := new(TargetNode) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TargetPod) DeepCopyInto(out *TargetPod) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetPod. +func (in *TargetPod) DeepCopy() *TargetPod { + if in == nil { + return nil + } + out := new(TargetPod) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TargetSystemService) DeepCopyInto(out *TargetSystemService) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetSystemService. +func (in *TargetSystemService) DeepCopy() *TargetSystemService { + if in == nil { + return nil + } + out := new(TargetSystemService) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TargetWorkload) DeepCopyInto(out *TargetWorkload) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetWorkload. +func (in *TargetWorkload) DeepCopy() *TargetWorkload { + if in == nil { + return nil + } + out := new(TargetWorkload) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Template) DeepCopyInto(out *Template) { *out = *in @@ -4111,3 +4749,19 @@ func (in *VersionCommits) DeepCopy() *VersionCommits { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WebhookConfig) DeepCopyInto(out *WebhookConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookConfig. +func (in *WebhookConfig) DeepCopy() *WebhookConfig { + if in == nil { + return nil + } + out := new(WebhookConfig) + in.DeepCopyInto(out) + return out +} diff --git a/apis/management.cattle.io/v3/zz_generated_k8s_client.go b/apis/management.cattle.io/v3/zz_generated_k8s_client.go index 19f77b41..3aa33fc3 100644 --- a/apis/management.cattle.io/v3/zz_generated_k8s_client.go +++ b/apis/management.cattle.io/v3/zz_generated_k8s_client.go @@ -42,6 +42,9 @@ type Interface interface { ProjectLoggingsGetter ListenConfigsGetter SettingsGetter + NotifiersGetter + ClusterAlertsGetter + ProjectAlertsGetter } type Client struct { @@ -77,6 +80,9 @@ type Client struct { projectLoggingControllers map[string]ProjectLoggingController listenConfigControllers map[string]ListenConfigController settingControllers map[string]SettingController + notifierControllers map[string]NotifierController + clusterAlertControllers map[string]ClusterAlertController + projectAlertControllers map[string]ProjectAlertController } func NewForConfig(config rest.Config) (Interface, error) { @@ -121,6 +127,9 @@ func NewForConfig(config rest.Config) (Interface, error) { projectLoggingControllers: map[string]ProjectLoggingController{}, listenConfigControllers: map[string]ListenConfigController{}, settingControllers: map[string]SettingController{}, + notifierControllers: map[string]NotifierController{}, + clusterAlertControllers: map[string]ClusterAlertController{}, + projectAlertControllers: map[string]ProjectAlertController{}, }, nil } @@ -499,3 +508,42 @@ func (c *Client) Settings(namespace string) SettingInterface { objectClient: objectClient, } } + +type NotifiersGetter interface { + Notifiers(namespace string) NotifierInterface +} + +func (c *Client) Notifiers(namespace string) NotifierInterface { + objectClient := clientbase.NewObjectClient(namespace, c.restClient, &NotifierResource, NotifierGroupVersionKind, notifierFactory{}) + return ¬ifierClient{ + ns: namespace, + client: c, + objectClient: objectClient, + } +} + +type ClusterAlertsGetter interface { + ClusterAlerts(namespace string) ClusterAlertInterface +} + +func (c *Client) ClusterAlerts(namespace string) ClusterAlertInterface { + objectClient := clientbase.NewObjectClient(namespace, c.restClient, &ClusterAlertResource, ClusterAlertGroupVersionKind, clusterAlertFactory{}) + return &clusterAlertClient{ + ns: namespace, + client: c, + objectClient: objectClient, + } +} + +type ProjectAlertsGetter interface { + ProjectAlerts(namespace string) ProjectAlertInterface +} + +func (c *Client) ProjectAlerts(namespace string) ProjectAlertInterface { + objectClient := clientbase.NewObjectClient(namespace, c.restClient, &ProjectAlertResource, ProjectAlertGroupVersionKind, projectAlertFactory{}) + return &projectAlertClient{ + ns: namespace, + client: c, + objectClient: objectClient, + } +} diff --git a/apis/management.cattle.io/v3/zz_generated_notifier_controller.go b/apis/management.cattle.io/v3/zz_generated_notifier_controller.go new file mode 100644 index 00000000..758fab7b --- /dev/null +++ b/apis/management.cattle.io/v3/zz_generated_notifier_controller.go @@ -0,0 +1,252 @@ +package v3 + +import ( + "context" + + "github.com/rancher/norman/clientbase" + "github.com/rancher/norman/controller" + "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 ( + NotifierGroupVersionKind = schema.GroupVersionKind{ + Version: Version, + Group: GroupName, + Kind: "Notifier", + } + NotifierResource = metav1.APIResource{ + Name: "notifiers", + SingularName: "notifier", + Namespaced: true, + + Kind: NotifierGroupVersionKind.Kind, + } +) + +type NotifierList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Notifier +} + +type NotifierHandlerFunc func(key string, obj *Notifier) error + +type NotifierLister interface { + List(namespace string, selector labels.Selector) (ret []*Notifier, err error) + Get(namespace, name string) (*Notifier, error) +} + +type NotifierController interface { + Informer() cache.SharedIndexInformer + Lister() NotifierLister + AddHandler(name string, handler NotifierHandlerFunc) + AddClusterScopedHandler(name, clusterName string, handler NotifierHandlerFunc) + Enqueue(namespace, name string) + Sync(ctx context.Context) error + Start(ctx context.Context, threadiness int) error +} + +type NotifierInterface interface { + ObjectClient() *clientbase.ObjectClient + Create(*Notifier) (*Notifier, error) + GetNamespaced(namespace, name string, opts metav1.GetOptions) (*Notifier, error) + Get(name string, opts metav1.GetOptions) (*Notifier, error) + Update(*Notifier) (*Notifier, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error + List(opts metav1.ListOptions) (*NotifierList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error + Controller() NotifierController + AddHandler(name string, sync NotifierHandlerFunc) + AddLifecycle(name string, lifecycle NotifierLifecycle) + AddClusterScopedHandler(name, clusterName string, sync NotifierHandlerFunc) + AddClusterScopedLifecycle(name, clusterName string, lifecycle NotifierLifecycle) +} + +type notifierLister struct { + controller *notifierController +} + +func (l *notifierLister) List(namespace string, selector labels.Selector) (ret []*Notifier, err error) { + err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) { + ret = append(ret, obj.(*Notifier)) + }) + return +} + +func (l *notifierLister) Get(namespace, name string) (*Notifier, 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: NotifierGroupVersionKind.Group, + Resource: "notifier", + }, name) + } + return obj.(*Notifier), nil +} + +type notifierController struct { + controller.GenericController +} + +func (c *notifierController) Lister() NotifierLister { + return ¬ifierLister{ + controller: c, + } +} + +func (c *notifierController) AddHandler(name string, handler NotifierHandlerFunc) { + 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.(*Notifier)) + }) +} + +func (c *notifierController) AddClusterScopedHandler(name, cluster string, handler NotifierHandlerFunc) { + 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.(*Notifier)) + }) +} + +type notifierFactory struct { +} + +func (c notifierFactory) Object() runtime.Object { + return &Notifier{} +} + +func (c notifierFactory) List() runtime.Object { + return &NotifierList{} +} + +func (s *notifierClient) Controller() NotifierController { + s.client.Lock() + defer s.client.Unlock() + + c, ok := s.client.notifierControllers[s.ns] + if ok { + return c + } + + genericController := controller.NewGenericController(NotifierGroupVersionKind.Kind+"Controller", + s.objectClient) + + c = ¬ifierController{ + GenericController: genericController, + } + + s.client.notifierControllers[s.ns] = c + s.client.starters = append(s.client.starters, c) + + return c +} + +type notifierClient struct { + client *Client + ns string + objectClient *clientbase.ObjectClient + controller NotifierController +} + +func (s *notifierClient) ObjectClient() *clientbase.ObjectClient { + return s.objectClient +} + +func (s *notifierClient) Create(o *Notifier) (*Notifier, error) { + obj, err := s.objectClient.Create(o) + return obj.(*Notifier), err +} + +func (s *notifierClient) Get(name string, opts metav1.GetOptions) (*Notifier, error) { + obj, err := s.objectClient.Get(name, opts) + return obj.(*Notifier), err +} + +func (s *notifierClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*Notifier, error) { + obj, err := s.objectClient.GetNamespaced(namespace, name, opts) + return obj.(*Notifier), err +} + +func (s *notifierClient) Update(o *Notifier) (*Notifier, error) { + obj, err := s.objectClient.Update(o.Name, o) + return obj.(*Notifier), err +} + +func (s *notifierClient) Delete(name string, options *metav1.DeleteOptions) error { + return s.objectClient.Delete(name, options) +} + +func (s *notifierClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error { + return s.objectClient.DeleteNamespaced(namespace, name, options) +} + +func (s *notifierClient) List(opts metav1.ListOptions) (*NotifierList, error) { + obj, err := s.objectClient.List(opts) + return obj.(*NotifierList), err +} + +func (s *notifierClient) Watch(opts metav1.ListOptions) (watch.Interface, error) { + return s.objectClient.Watch(opts) +} + +// Patch applies the patch and returns the patched deployment. +func (s *notifierClient) Patch(o *Notifier, data []byte, subresources ...string) (*Notifier, error) { + obj, err := s.objectClient.Patch(o.Name, o, data, subresources...) + return obj.(*Notifier), err +} + +func (s *notifierClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error { + return s.objectClient.DeleteCollection(deleteOpts, listOpts) +} + +func (s *notifierClient) AddHandler(name string, sync NotifierHandlerFunc) { + s.Controller().AddHandler(name, sync) +} + +func (s *notifierClient) AddLifecycle(name string, lifecycle NotifierLifecycle) { + sync := NewNotifierLifecycleAdapter(name, false, s, lifecycle) + s.AddHandler(name, sync) +} + +func (s *notifierClient) AddClusterScopedHandler(name, clusterName string, sync NotifierHandlerFunc) { + s.Controller().AddClusterScopedHandler(name, clusterName, sync) +} + +func (s *notifierClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle NotifierLifecycle) { + sync := NewNotifierLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle) + s.AddClusterScopedHandler(name, clusterName, sync) +} diff --git a/apis/management.cattle.io/v3/zz_generated_notifier_lifecycle_adapter.go b/apis/management.cattle.io/v3/zz_generated_notifier_lifecycle_adapter.go new file mode 100644 index 00000000..cec2f0dd --- /dev/null +++ b/apis/management.cattle.io/v3/zz_generated_notifier_lifecycle_adapter.go @@ -0,0 +1,51 @@ +package v3 + +import ( + "github.com/rancher/norman/lifecycle" + "k8s.io/apimachinery/pkg/runtime" +) + +type NotifierLifecycle interface { + Create(obj *Notifier) (*Notifier, error) + Remove(obj *Notifier) (*Notifier, error) + Updated(obj *Notifier) (*Notifier, error) +} + +type notifierLifecycleAdapter struct { + lifecycle NotifierLifecycle +} + +func (w *notifierLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Create(obj.(*Notifier)) + if o == nil { + return nil, err + } + return o, err +} + +func (w *notifierLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Remove(obj.(*Notifier)) + if o == nil { + return nil, err + } + return o, err +} + +func (w *notifierLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Updated(obj.(*Notifier)) + if o == nil { + return nil, err + } + return o, err +} + +func NewNotifierLifecycleAdapter(name string, clusterScoped bool, client NotifierInterface, l NotifierLifecycle) NotifierHandlerFunc { + adapter := ¬ifierLifecycleAdapter{lifecycle: l} + syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient()) + return func(key string, obj *Notifier) error { + if obj == nil { + return syncFn(key, nil) + } + return syncFn(key, obj) + } +} diff --git a/apis/management.cattle.io/v3/zz_generated_project_alert_controller.go b/apis/management.cattle.io/v3/zz_generated_project_alert_controller.go new file mode 100644 index 00000000..e1c60e61 --- /dev/null +++ b/apis/management.cattle.io/v3/zz_generated_project_alert_controller.go @@ -0,0 +1,252 @@ +package v3 + +import ( + "context" + + "github.com/rancher/norman/clientbase" + "github.com/rancher/norman/controller" + "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 ( + ProjectAlertGroupVersionKind = schema.GroupVersionKind{ + Version: Version, + Group: GroupName, + Kind: "ProjectAlert", + } + ProjectAlertResource = metav1.APIResource{ + Name: "projectalerts", + SingularName: "projectalert", + Namespaced: true, + + Kind: ProjectAlertGroupVersionKind.Kind, + } +) + +type ProjectAlertList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ProjectAlert +} + +type ProjectAlertHandlerFunc func(key string, obj *ProjectAlert) error + +type ProjectAlertLister interface { + List(namespace string, selector labels.Selector) (ret []*ProjectAlert, err error) + Get(namespace, name string) (*ProjectAlert, error) +} + +type ProjectAlertController interface { + Informer() cache.SharedIndexInformer + Lister() ProjectAlertLister + AddHandler(name string, handler ProjectAlertHandlerFunc) + AddClusterScopedHandler(name, clusterName string, handler ProjectAlertHandlerFunc) + Enqueue(namespace, name string) + Sync(ctx context.Context) error + Start(ctx context.Context, threadiness int) error +} + +type ProjectAlertInterface interface { + ObjectClient() *clientbase.ObjectClient + Create(*ProjectAlert) (*ProjectAlert, error) + GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ProjectAlert, error) + Get(name string, opts metav1.GetOptions) (*ProjectAlert, error) + Update(*ProjectAlert) (*ProjectAlert, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error + List(opts metav1.ListOptions) (*ProjectAlertList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error + Controller() ProjectAlertController + AddHandler(name string, sync ProjectAlertHandlerFunc) + AddLifecycle(name string, lifecycle ProjectAlertLifecycle) + AddClusterScopedHandler(name, clusterName string, sync ProjectAlertHandlerFunc) + AddClusterScopedLifecycle(name, clusterName string, lifecycle ProjectAlertLifecycle) +} + +type projectAlertLister struct { + controller *projectAlertController +} + +func (l *projectAlertLister) List(namespace string, selector labels.Selector) (ret []*ProjectAlert, err error) { + err = cache.ListAllByNamespace(l.controller.Informer().GetIndexer(), namespace, selector, func(obj interface{}) { + ret = append(ret, obj.(*ProjectAlert)) + }) + return +} + +func (l *projectAlertLister) Get(namespace, name string) (*ProjectAlert, 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: ProjectAlertGroupVersionKind.Group, + Resource: "projectAlert", + }, name) + } + return obj.(*ProjectAlert), nil +} + +type projectAlertController struct { + controller.GenericController +} + +func (c *projectAlertController) Lister() ProjectAlertLister { + return &projectAlertLister{ + controller: c, + } +} + +func (c *projectAlertController) AddHandler(name string, handler ProjectAlertHandlerFunc) { + 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.(*ProjectAlert)) + }) +} + +func (c *projectAlertController) AddClusterScopedHandler(name, cluster string, handler ProjectAlertHandlerFunc) { + 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.(*ProjectAlert)) + }) +} + +type projectAlertFactory struct { +} + +func (c projectAlertFactory) Object() runtime.Object { + return &ProjectAlert{} +} + +func (c projectAlertFactory) List() runtime.Object { + return &ProjectAlertList{} +} + +func (s *projectAlertClient) Controller() ProjectAlertController { + s.client.Lock() + defer s.client.Unlock() + + c, ok := s.client.projectAlertControllers[s.ns] + if ok { + return c + } + + genericController := controller.NewGenericController(ProjectAlertGroupVersionKind.Kind+"Controller", + s.objectClient) + + c = &projectAlertController{ + GenericController: genericController, + } + + s.client.projectAlertControllers[s.ns] = c + s.client.starters = append(s.client.starters, c) + + return c +} + +type projectAlertClient struct { + client *Client + ns string + objectClient *clientbase.ObjectClient + controller ProjectAlertController +} + +func (s *projectAlertClient) ObjectClient() *clientbase.ObjectClient { + return s.objectClient +} + +func (s *projectAlertClient) Create(o *ProjectAlert) (*ProjectAlert, error) { + obj, err := s.objectClient.Create(o) + return obj.(*ProjectAlert), err +} + +func (s *projectAlertClient) Get(name string, opts metav1.GetOptions) (*ProjectAlert, error) { + obj, err := s.objectClient.Get(name, opts) + return obj.(*ProjectAlert), err +} + +func (s *projectAlertClient) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*ProjectAlert, error) { + obj, err := s.objectClient.GetNamespaced(namespace, name, opts) + return obj.(*ProjectAlert), err +} + +func (s *projectAlertClient) Update(o *ProjectAlert) (*ProjectAlert, error) { + obj, err := s.objectClient.Update(o.Name, o) + return obj.(*ProjectAlert), err +} + +func (s *projectAlertClient) Delete(name string, options *metav1.DeleteOptions) error { + return s.objectClient.Delete(name, options) +} + +func (s *projectAlertClient) DeleteNamespaced(namespace, name string, options *metav1.DeleteOptions) error { + return s.objectClient.DeleteNamespaced(namespace, name, options) +} + +func (s *projectAlertClient) List(opts metav1.ListOptions) (*ProjectAlertList, error) { + obj, err := s.objectClient.List(opts) + return obj.(*ProjectAlertList), err +} + +func (s *projectAlertClient) Watch(opts metav1.ListOptions) (watch.Interface, error) { + return s.objectClient.Watch(opts) +} + +// Patch applies the patch and returns the patched deployment. +func (s *projectAlertClient) Patch(o *ProjectAlert, data []byte, subresources ...string) (*ProjectAlert, error) { + obj, err := s.objectClient.Patch(o.Name, o, data, subresources...) + return obj.(*ProjectAlert), err +} + +func (s *projectAlertClient) DeleteCollection(deleteOpts *metav1.DeleteOptions, listOpts metav1.ListOptions) error { + return s.objectClient.DeleteCollection(deleteOpts, listOpts) +} + +func (s *projectAlertClient) AddHandler(name string, sync ProjectAlertHandlerFunc) { + s.Controller().AddHandler(name, sync) +} + +func (s *projectAlertClient) AddLifecycle(name string, lifecycle ProjectAlertLifecycle) { + sync := NewProjectAlertLifecycleAdapter(name, false, s, lifecycle) + s.AddHandler(name, sync) +} + +func (s *projectAlertClient) AddClusterScopedHandler(name, clusterName string, sync ProjectAlertHandlerFunc) { + s.Controller().AddClusterScopedHandler(name, clusterName, sync) +} + +func (s *projectAlertClient) AddClusterScopedLifecycle(name, clusterName string, lifecycle ProjectAlertLifecycle) { + sync := NewProjectAlertLifecycleAdapter(name+"_"+clusterName, true, s, lifecycle) + s.AddClusterScopedHandler(name, clusterName, sync) +} diff --git a/apis/management.cattle.io/v3/zz_generated_project_alert_lifecycle_adapter.go b/apis/management.cattle.io/v3/zz_generated_project_alert_lifecycle_adapter.go new file mode 100644 index 00000000..93ccc96e --- /dev/null +++ b/apis/management.cattle.io/v3/zz_generated_project_alert_lifecycle_adapter.go @@ -0,0 +1,51 @@ +package v3 + +import ( + "github.com/rancher/norman/lifecycle" + "k8s.io/apimachinery/pkg/runtime" +) + +type ProjectAlertLifecycle interface { + Create(obj *ProjectAlert) (*ProjectAlert, error) + Remove(obj *ProjectAlert) (*ProjectAlert, error) + Updated(obj *ProjectAlert) (*ProjectAlert, error) +} + +type projectAlertLifecycleAdapter struct { + lifecycle ProjectAlertLifecycle +} + +func (w *projectAlertLifecycleAdapter) Create(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Create(obj.(*ProjectAlert)) + if o == nil { + return nil, err + } + return o, err +} + +func (w *projectAlertLifecycleAdapter) Finalize(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Remove(obj.(*ProjectAlert)) + if o == nil { + return nil, err + } + return o, err +} + +func (w *projectAlertLifecycleAdapter) Updated(obj runtime.Object) (runtime.Object, error) { + o, err := w.lifecycle.Updated(obj.(*ProjectAlert)) + if o == nil { + return nil, err + } + return o, err +} + +func NewProjectAlertLifecycleAdapter(name string, clusterScoped bool, client ProjectAlertInterface, l ProjectAlertLifecycle) ProjectAlertHandlerFunc { + adapter := &projectAlertLifecycleAdapter{lifecycle: l} + syncFn := lifecycle.NewObjectLifecycleAdapter(name, clusterScoped, adapter, client.ObjectClient()) + return func(key string, obj *ProjectAlert) error { + if obj == nil { + return syncFn(key, nil) + } + return syncFn(key, obj) + } +} diff --git a/apis/management.cattle.io/v3/zz_generated_scheme.go b/apis/management.cattle.io/v3/zz_generated_scheme.go index df92909f..f43d9d3c 100644 --- a/apis/management.cattle.io/v3/zz_generated_scheme.go +++ b/apis/management.cattle.io/v3/zz_generated_scheme.go @@ -89,6 +89,12 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ListenConfigList{}, &Setting{}, &SettingList{}, + &Notifier{}, + &NotifierList{}, + &ClusterAlert{}, + &ClusterAlertList{}, + &ProjectAlert{}, + &ProjectAlertList{}, ) return nil } diff --git a/client/management/v3/zz_generated_alert_status.go b/client/management/v3/zz_generated_alert_status.go new file mode 100644 index 00000000..55767c97 --- /dev/null +++ b/client/management/v3/zz_generated_alert_status.go @@ -0,0 +1,10 @@ +package client + +const ( + AlertStatusType = "alertStatus" + AlertStatusFieldState = "state" +) + +type AlertStatus struct { + State string `json:"state,omitempty"` +} diff --git a/client/management/v3/zz_generated_client.go b/client/management/v3/zz_generated_client.go index 353b8562..ee58ec7c 100644 --- a/client/management/v3/zz_generated_client.go +++ b/client/management/v3/zz_generated_client.go @@ -36,6 +36,9 @@ type Client struct { ProjectLogging ProjectLoggingOperations ListenConfig ListenConfigOperations Setting SettingOperations + Notifier NotifierOperations + ClusterAlert ClusterAlertOperations + ProjectAlert ProjectAlertOperations } func NewClient(opts *clientbase.ClientOpts) (*Client, error) { @@ -77,6 +80,9 @@ func NewClient(opts *clientbase.ClientOpts) (*Client, error) { client.ProjectLogging = newProjectLoggingClient(client) client.ListenConfig = newListenConfigClient(client) client.Setting = newSettingClient(client) + client.Notifier = newNotifierClient(client) + client.ClusterAlert = newClusterAlertClient(client) + client.ProjectAlert = newProjectAlertClient(client) return client, nil } diff --git a/client/management/v3/zz_generated_cluster_alert.go b/client/management/v3/zz_generated_cluster_alert.go new file mode 100644 index 00000000..8482e0d5 --- /dev/null +++ b/client/management/v3/zz_generated_cluster_alert.go @@ -0,0 +1,121 @@ +package client + +import ( + "github.com/rancher/norman/types" +) + +const ( + ClusterAlertType = "clusterAlert" + ClusterAlertFieldAnnotations = "annotations" + ClusterAlertFieldClusterId = "clusterId" + ClusterAlertFieldCreated = "created" + ClusterAlertFieldCreatorID = "creatorId" + ClusterAlertFieldDescription = "description" + ClusterAlertFieldDisplayName = "displayName" + ClusterAlertFieldInitialWaitSeconds = "initialWaitSeconds" + ClusterAlertFieldLabels = "labels" + ClusterAlertFieldName = "name" + ClusterAlertFieldNamespaceId = "namespaceId" + ClusterAlertFieldOwnerReferences = "ownerReferences" + ClusterAlertFieldRecipients = "recipients" + ClusterAlertFieldRemoved = "removed" + ClusterAlertFieldRepeatIntervalSeconds = "repeatIntervalSeconds" + ClusterAlertFieldSeverity = "severity" + ClusterAlertFieldState = "state" + ClusterAlertFieldStatus = "status" + ClusterAlertFieldTargetEvent = "targetEvent" + ClusterAlertFieldTargetNode = "targetNode" + ClusterAlertFieldTargetSystemService = "targetSystemService" + ClusterAlertFieldTransitioning = "transitioning" + ClusterAlertFieldTransitioningMessage = "transitioningMessage" + ClusterAlertFieldUuid = "uuid" +) + +type ClusterAlert struct { + types.Resource + Annotations map[string]string `json:"annotations,omitempty"` + ClusterId string `json:"clusterId,omitempty"` + Created string `json:"created,omitempty"` + CreatorID string `json:"creatorId,omitempty"` + Description string `json:"description,omitempty"` + DisplayName string `json:"displayName,omitempty"` + InitialWaitSeconds *int64 `json:"initialWaitSeconds,omitempty"` + Labels map[string]string `json:"labels,omitempty"` + Name string `json:"name,omitempty"` + NamespaceId string `json:"namespaceId,omitempty"` + OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"` + Recipients []Recipient `json:"recipients,omitempty"` + Removed string `json:"removed,omitempty"` + RepeatIntervalSeconds *int64 `json:"repeatIntervalSeconds,omitempty"` + Severity string `json:"severity,omitempty"` + State string `json:"state,omitempty"` + Status *AlertStatus `json:"status,omitempty"` + TargetEvent *TargetEvent `json:"targetEvent,omitempty"` + TargetNode *TargetNode `json:"targetNode,omitempty"` + TargetSystemService *TargetSystemService `json:"targetSystemService,omitempty"` + Transitioning string `json:"transitioning,omitempty"` + TransitioningMessage string `json:"transitioningMessage,omitempty"` + Uuid string `json:"uuid,omitempty"` +} +type ClusterAlertCollection struct { + types.Collection + Data []ClusterAlert `json:"data,omitempty"` + client *ClusterAlertClient +} + +type ClusterAlertClient struct { + apiClient *Client +} + +type ClusterAlertOperations interface { + List(opts *types.ListOpts) (*ClusterAlertCollection, error) + Create(opts *ClusterAlert) (*ClusterAlert, error) + Update(existing *ClusterAlert, updates interface{}) (*ClusterAlert, error) + ByID(id string) (*ClusterAlert, error) + Delete(container *ClusterAlert) error +} + +func newClusterAlertClient(apiClient *Client) *ClusterAlertClient { + return &ClusterAlertClient{ + apiClient: apiClient, + } +} + +func (c *ClusterAlertClient) Create(container *ClusterAlert) (*ClusterAlert, error) { + resp := &ClusterAlert{} + err := c.apiClient.Ops.DoCreate(ClusterAlertType, container, resp) + return resp, err +} + +func (c *ClusterAlertClient) Update(existing *ClusterAlert, updates interface{}) (*ClusterAlert, error) { + resp := &ClusterAlert{} + err := c.apiClient.Ops.DoUpdate(ClusterAlertType, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ClusterAlertClient) List(opts *types.ListOpts) (*ClusterAlertCollection, error) { + resp := &ClusterAlertCollection{} + err := c.apiClient.Ops.DoList(ClusterAlertType, opts, resp) + resp.client = c + return resp, err +} + +func (cc *ClusterAlertCollection) Next() (*ClusterAlertCollection, error) { + if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" { + resp := &ClusterAlertCollection{} + err := cc.client.apiClient.Ops.DoNext(cc.Pagination.Next, resp) + resp.client = cc.client + return resp, err + } + return nil, nil +} + +func (c *ClusterAlertClient) ByID(id string) (*ClusterAlert, error) { + resp := &ClusterAlert{} + err := c.apiClient.Ops.DoByID(ClusterAlertType, id, resp) + return resp, err +} + +func (c *ClusterAlertClient) Delete(container *ClusterAlert) error { + return c.apiClient.Ops.DoResourceDelete(ClusterAlertType, &container.Resource) +} diff --git a/client/management/v3/zz_generated_cluster_alert_spec.go b/client/management/v3/zz_generated_cluster_alert_spec.go new file mode 100644 index 00000000..06cd419b --- /dev/null +++ b/client/management/v3/zz_generated_cluster_alert_spec.go @@ -0,0 +1,28 @@ +package client + +const ( + ClusterAlertSpecType = "clusterAlertSpec" + ClusterAlertSpecFieldClusterId = "clusterId" + ClusterAlertSpecFieldDescription = "description" + ClusterAlertSpecFieldDisplayName = "displayName" + ClusterAlertSpecFieldInitialWaitSeconds = "initialWaitSeconds" + ClusterAlertSpecFieldRecipients = "recipients" + ClusterAlertSpecFieldRepeatIntervalSeconds = "repeatIntervalSeconds" + ClusterAlertSpecFieldSeverity = "severity" + ClusterAlertSpecFieldTargetEvent = "targetEvent" + ClusterAlertSpecFieldTargetNode = "targetNode" + ClusterAlertSpecFieldTargetSystemService = "targetSystemService" +) + +type ClusterAlertSpec struct { + ClusterId string `json:"clusterId,omitempty"` + Description string `json:"description,omitempty"` + DisplayName string `json:"displayName,omitempty"` + InitialWaitSeconds *int64 `json:"initialWaitSeconds,omitempty"` + Recipients []Recipient `json:"recipients,omitempty"` + RepeatIntervalSeconds *int64 `json:"repeatIntervalSeconds,omitempty"` + Severity string `json:"severity,omitempty"` + TargetEvent *TargetEvent `json:"targetEvent,omitempty"` + TargetNode *TargetNode `json:"targetNode,omitempty"` + TargetSystemService *TargetSystemService `json:"targetSystemService,omitempty"` +} diff --git a/client/management/v3/zz_generated_notification.go b/client/management/v3/zz_generated_notification.go new file mode 100644 index 00000000..b3c4cd5b --- /dev/null +++ b/client/management/v3/zz_generated_notification.go @@ -0,0 +1,18 @@ +package client + +const ( + NotificationType = "notification" + NotificationFieldMessage = "message" + NotificationFieldPagerdutyConfig = "pagerdutyConfig" + NotificationFieldSMTPConfig = "smtpConfig" + NotificationFieldSlackConfig = "slackConfig" + NotificationFieldWebhookConfig = "webhookConfig" +) + +type Notification struct { + Message string `json:"message,omitempty"` + PagerdutyConfig *PagerdutyConfig `json:"pagerdutyConfig,omitempty"` + SMTPConfig *SMTPConfig `json:"smtpConfig,omitempty"` + SlackConfig *SlackConfig `json:"slackConfig,omitempty"` + WebhookConfig *WebhookConfig `json:"webhookConfig,omitempty"` +} diff --git a/client/management/v3/zz_generated_notifier.go b/client/management/v3/zz_generated_notifier.go new file mode 100644 index 00000000..3114a940 --- /dev/null +++ b/client/management/v3/zz_generated_notifier.go @@ -0,0 +1,115 @@ +package client + +import ( + "github.com/rancher/norman/types" +) + +const ( + NotifierType = "notifier" + NotifierFieldAnnotations = "annotations" + NotifierFieldClusterId = "clusterId" + NotifierFieldCreated = "created" + NotifierFieldCreatorID = "creatorId" + NotifierFieldDescription = "description" + NotifierFieldDisplayName = "displayName" + NotifierFieldLabels = "labels" + NotifierFieldName = "name" + NotifierFieldNamespaceId = "namespaceId" + NotifierFieldOwnerReferences = "ownerReferences" + NotifierFieldPagerdutyConfig = "pagerdutyConfig" + NotifierFieldRemoved = "removed" + NotifierFieldSMTPConfig = "smtpConfig" + NotifierFieldSlackConfig = "slackConfig" + NotifierFieldState = "state" + NotifierFieldStatus = "status" + NotifierFieldTransitioning = "transitioning" + NotifierFieldTransitioningMessage = "transitioningMessage" + NotifierFieldUuid = "uuid" + NotifierFieldWebhookConfig = "webhookConfig" +) + +type Notifier struct { + types.Resource + Annotations map[string]string `json:"annotations,omitempty"` + ClusterId string `json:"clusterId,omitempty"` + Created string `json:"created,omitempty"` + CreatorID string `json:"creatorId,omitempty"` + Description string `json:"description,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Labels map[string]string `json:"labels,omitempty"` + Name string `json:"name,omitempty"` + NamespaceId string `json:"namespaceId,omitempty"` + OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"` + PagerdutyConfig *PagerdutyConfig `json:"pagerdutyConfig,omitempty"` + Removed string `json:"removed,omitempty"` + SMTPConfig *SMTPConfig `json:"smtpConfig,omitempty"` + SlackConfig *SlackConfig `json:"slackConfig,omitempty"` + State string `json:"state,omitempty"` + Status *NotifierStatus `json:"status,omitempty"` + Transitioning string `json:"transitioning,omitempty"` + TransitioningMessage string `json:"transitioningMessage,omitempty"` + Uuid string `json:"uuid,omitempty"` + WebhookConfig *WebhookConfig `json:"webhookConfig,omitempty"` +} +type NotifierCollection struct { + types.Collection + Data []Notifier `json:"data,omitempty"` + client *NotifierClient +} + +type NotifierClient struct { + apiClient *Client +} + +type NotifierOperations interface { + List(opts *types.ListOpts) (*NotifierCollection, error) + Create(opts *Notifier) (*Notifier, error) + Update(existing *Notifier, updates interface{}) (*Notifier, error) + ByID(id string) (*Notifier, error) + Delete(container *Notifier) error +} + +func newNotifierClient(apiClient *Client) *NotifierClient { + return &NotifierClient{ + apiClient: apiClient, + } +} + +func (c *NotifierClient) Create(container *Notifier) (*Notifier, error) { + resp := &Notifier{} + err := c.apiClient.Ops.DoCreate(NotifierType, container, resp) + return resp, err +} + +func (c *NotifierClient) Update(existing *Notifier, updates interface{}) (*Notifier, error) { + resp := &Notifier{} + err := c.apiClient.Ops.DoUpdate(NotifierType, &existing.Resource, updates, resp) + return resp, err +} + +func (c *NotifierClient) List(opts *types.ListOpts) (*NotifierCollection, error) { + resp := &NotifierCollection{} + err := c.apiClient.Ops.DoList(NotifierType, opts, resp) + resp.client = c + return resp, err +} + +func (cc *NotifierCollection) Next() (*NotifierCollection, error) { + if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" { + resp := &NotifierCollection{} + err := cc.client.apiClient.Ops.DoNext(cc.Pagination.Next, resp) + resp.client = cc.client + return resp, err + } + return nil, nil +} + +func (c *NotifierClient) ByID(id string) (*Notifier, error) { + resp := &Notifier{} + err := c.apiClient.Ops.DoByID(NotifierType, id, resp) + return resp, err +} + +func (c *NotifierClient) Delete(container *Notifier) error { + return c.apiClient.Ops.DoResourceDelete(NotifierType, &container.Resource) +} diff --git a/client/management/v3/zz_generated_notifier_spec.go b/client/management/v3/zz_generated_notifier_spec.go new file mode 100644 index 00000000..5c972a65 --- /dev/null +++ b/client/management/v3/zz_generated_notifier_spec.go @@ -0,0 +1,22 @@ +package client + +const ( + NotifierSpecType = "notifierSpec" + NotifierSpecFieldClusterId = "clusterId" + NotifierSpecFieldDescription = "description" + NotifierSpecFieldDisplayName = "displayName" + NotifierSpecFieldPagerdutyConfig = "pagerdutyConfig" + NotifierSpecFieldSMTPConfig = "smtpConfig" + NotifierSpecFieldSlackConfig = "slackConfig" + NotifierSpecFieldWebhookConfig = "webhookConfig" +) + +type NotifierSpec struct { + ClusterId string `json:"clusterId,omitempty"` + Description string `json:"description,omitempty"` + DisplayName string `json:"displayName,omitempty"` + PagerdutyConfig *PagerdutyConfig `json:"pagerdutyConfig,omitempty"` + SMTPConfig *SMTPConfig `json:"smtpConfig,omitempty"` + SlackConfig *SlackConfig `json:"slackConfig,omitempty"` + WebhookConfig *WebhookConfig `json:"webhookConfig,omitempty"` +} diff --git a/client/management/v3/zz_generated_notifier_status.go b/client/management/v3/zz_generated_notifier_status.go new file mode 100644 index 00000000..171f9c5a --- /dev/null +++ b/client/management/v3/zz_generated_notifier_status.go @@ -0,0 +1,8 @@ +package client + +const ( + NotifierStatusType = "notifierStatus" +) + +type NotifierStatus struct { +} diff --git a/client/management/v3/zz_generated_pagerduty_config.go b/client/management/v3/zz_generated_pagerduty_config.go new file mode 100644 index 00000000..9aeb516c --- /dev/null +++ b/client/management/v3/zz_generated_pagerduty_config.go @@ -0,0 +1,10 @@ +package client + +const ( + PagerdutyConfigType = "pagerdutyConfig" + PagerdutyConfigFieldServiceKey = "serviceKey" +) + +type PagerdutyConfig struct { + ServiceKey string `json:"serviceKey,omitempty"` +} diff --git a/client/management/v3/zz_generated_project_alert.go b/client/management/v3/zz_generated_project_alert.go new file mode 100644 index 00000000..6e4a2d90 --- /dev/null +++ b/client/management/v3/zz_generated_project_alert.go @@ -0,0 +1,119 @@ +package client + +import ( + "github.com/rancher/norman/types" +) + +const ( + ProjectAlertType = "projectAlert" + ProjectAlertFieldAnnotations = "annotations" + ProjectAlertFieldCreated = "created" + ProjectAlertFieldCreatorID = "creatorId" + ProjectAlertFieldDescription = "description" + ProjectAlertFieldDisplayName = "displayName" + ProjectAlertFieldInitialWaitSeconds = "initialWaitSeconds" + ProjectAlertFieldLabels = "labels" + ProjectAlertFieldName = "name" + ProjectAlertFieldNamespaceId = "namespaceId" + ProjectAlertFieldOwnerReferences = "ownerReferences" + ProjectAlertFieldProjectId = "projectId" + ProjectAlertFieldRecipients = "recipients" + ProjectAlertFieldRemoved = "removed" + ProjectAlertFieldRepeatIntervalSeconds = "repeatIntervalSeconds" + ProjectAlertFieldSeverity = "severity" + ProjectAlertFieldState = "state" + ProjectAlertFieldStatus = "status" + ProjectAlertFieldTargetPod = "targetPod" + ProjectAlertFieldTargetWorkload = "targetWorkload" + ProjectAlertFieldTransitioning = "transitioning" + ProjectAlertFieldTransitioningMessage = "transitioningMessage" + ProjectAlertFieldUuid = "uuid" +) + +type ProjectAlert struct { + types.Resource + Annotations map[string]string `json:"annotations,omitempty"` + Created string `json:"created,omitempty"` + CreatorID string `json:"creatorId,omitempty"` + Description string `json:"description,omitempty"` + DisplayName string `json:"displayName,omitempty"` + InitialWaitSeconds *int64 `json:"initialWaitSeconds,omitempty"` + Labels map[string]string `json:"labels,omitempty"` + Name string `json:"name,omitempty"` + NamespaceId string `json:"namespaceId,omitempty"` + OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"` + ProjectId string `json:"projectId,omitempty"` + Recipients []Recipient `json:"recipients,omitempty"` + Removed string `json:"removed,omitempty"` + RepeatIntervalSeconds *int64 `json:"repeatIntervalSeconds,omitempty"` + Severity string `json:"severity,omitempty"` + State string `json:"state,omitempty"` + Status *AlertStatus `json:"status,omitempty"` + TargetPod *TargetPod `json:"targetPod,omitempty"` + TargetWorkload *TargetWorkload `json:"targetWorkload,omitempty"` + Transitioning string `json:"transitioning,omitempty"` + TransitioningMessage string `json:"transitioningMessage,omitempty"` + Uuid string `json:"uuid,omitempty"` +} +type ProjectAlertCollection struct { + types.Collection + Data []ProjectAlert `json:"data,omitempty"` + client *ProjectAlertClient +} + +type ProjectAlertClient struct { + apiClient *Client +} + +type ProjectAlertOperations interface { + List(opts *types.ListOpts) (*ProjectAlertCollection, error) + Create(opts *ProjectAlert) (*ProjectAlert, error) + Update(existing *ProjectAlert, updates interface{}) (*ProjectAlert, error) + ByID(id string) (*ProjectAlert, error) + Delete(container *ProjectAlert) error +} + +func newProjectAlertClient(apiClient *Client) *ProjectAlertClient { + return &ProjectAlertClient{ + apiClient: apiClient, + } +} + +func (c *ProjectAlertClient) Create(container *ProjectAlert) (*ProjectAlert, error) { + resp := &ProjectAlert{} + err := c.apiClient.Ops.DoCreate(ProjectAlertType, container, resp) + return resp, err +} + +func (c *ProjectAlertClient) Update(existing *ProjectAlert, updates interface{}) (*ProjectAlert, error) { + resp := &ProjectAlert{} + err := c.apiClient.Ops.DoUpdate(ProjectAlertType, &existing.Resource, updates, resp) + return resp, err +} + +func (c *ProjectAlertClient) List(opts *types.ListOpts) (*ProjectAlertCollection, error) { + resp := &ProjectAlertCollection{} + err := c.apiClient.Ops.DoList(ProjectAlertType, opts, resp) + resp.client = c + return resp, err +} + +func (cc *ProjectAlertCollection) Next() (*ProjectAlertCollection, error) { + if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" { + resp := &ProjectAlertCollection{} + err := cc.client.apiClient.Ops.DoNext(cc.Pagination.Next, resp) + resp.client = cc.client + return resp, err + } + return nil, nil +} + +func (c *ProjectAlertClient) ByID(id string) (*ProjectAlert, error) { + resp := &ProjectAlert{} + err := c.apiClient.Ops.DoByID(ProjectAlertType, id, resp) + return resp, err +} + +func (c *ProjectAlertClient) Delete(container *ProjectAlert) error { + return c.apiClient.Ops.DoResourceDelete(ProjectAlertType, &container.Resource) +} diff --git a/client/management/v3/zz_generated_project_alert_spec.go b/client/management/v3/zz_generated_project_alert_spec.go new file mode 100644 index 00000000..b8529ef4 --- /dev/null +++ b/client/management/v3/zz_generated_project_alert_spec.go @@ -0,0 +1,26 @@ +package client + +const ( + ProjectAlertSpecType = "projectAlertSpec" + ProjectAlertSpecFieldDescription = "description" + ProjectAlertSpecFieldDisplayName = "displayName" + ProjectAlertSpecFieldInitialWaitSeconds = "initialWaitSeconds" + ProjectAlertSpecFieldProjectId = "projectId" + ProjectAlertSpecFieldRecipients = "recipients" + ProjectAlertSpecFieldRepeatIntervalSeconds = "repeatIntervalSeconds" + ProjectAlertSpecFieldSeverity = "severity" + ProjectAlertSpecFieldTargetPod = "targetPod" + ProjectAlertSpecFieldTargetWorkload = "targetWorkload" +) + +type ProjectAlertSpec struct { + Description string `json:"description,omitempty"` + DisplayName string `json:"displayName,omitempty"` + InitialWaitSeconds *int64 `json:"initialWaitSeconds,omitempty"` + ProjectId string `json:"projectId,omitempty"` + Recipients []Recipient `json:"recipients,omitempty"` + RepeatIntervalSeconds *int64 `json:"repeatIntervalSeconds,omitempty"` + Severity string `json:"severity,omitempty"` + TargetPod *TargetPod `json:"targetPod,omitempty"` + TargetWorkload *TargetWorkload `json:"targetWorkload,omitempty"` +} diff --git a/client/management/v3/zz_generated_recipient.go b/client/management/v3/zz_generated_recipient.go new file mode 100644 index 00000000..e99166a7 --- /dev/null +++ b/client/management/v3/zz_generated_recipient.go @@ -0,0 +1,14 @@ +package client + +const ( + RecipientType = "recipient" + RecipientFieldNotifierId = "notifierId" + RecipientFieldNotifierType = "notifierType" + RecipientFieldRecipient = "recipient" +) + +type Recipient struct { + NotifierId string `json:"notifierId,omitempty"` + NotifierType string `json:"notifierType,omitempty"` + Recipient string `json:"recipient,omitempty"` +} diff --git a/client/management/v3/zz_generated_slack_config.go b/client/management/v3/zz_generated_slack_config.go new file mode 100644 index 00000000..0109317b --- /dev/null +++ b/client/management/v3/zz_generated_slack_config.go @@ -0,0 +1,12 @@ +package client + +const ( + SlackConfigType = "slackConfig" + SlackConfigFieldDefaultRecipient = "defaultRecipient" + SlackConfigFieldURL = "url" +) + +type SlackConfig struct { + DefaultRecipient string `json:"defaultRecipient,omitempty"` + URL string `json:"url,omitempty"` +} diff --git a/client/management/v3/zz_generated_smtp_config.go b/client/management/v3/zz_generated_smtp_config.go new file mode 100644 index 00000000..73e81025 --- /dev/null +++ b/client/management/v3/zz_generated_smtp_config.go @@ -0,0 +1,20 @@ +package client + +const ( + SMTPConfigType = "smtpConfig" + SMTPConfigFieldDefaultRecipient = "defaultRecipient" + SMTPConfigFieldHost = "host" + SMTPConfigFieldPassword = "password" + SMTPConfigFieldPort = "port" + SMTPConfigFieldTLS = "tls" + SMTPConfigFieldUsername = "username" +) + +type SMTPConfig struct { + DefaultRecipient string `json:"defaultRecipient,omitempty"` + Host string `json:"host,omitempty"` + Password string `json:"password,omitempty"` + Port *int64 `json:"port,omitempty"` + TLS *bool `json:"tls,omitempty"` + Username string `json:"username,omitempty"` +} diff --git a/client/management/v3/zz_generated_target_event.go b/client/management/v3/zz_generated_target_event.go new file mode 100644 index 00000000..0bc88791 --- /dev/null +++ b/client/management/v3/zz_generated_target_event.go @@ -0,0 +1,12 @@ +package client + +const ( + TargetEventType = "targetEvent" + TargetEventFieldResourceKind = "resourceKind" + TargetEventFieldType = "type" +) + +type TargetEvent struct { + ResourceKind string `json:"resourceKind,omitempty"` + Type string `json:"type,omitempty"` +} diff --git a/client/management/v3/zz_generated_target_node.go b/client/management/v3/zz_generated_target_node.go new file mode 100644 index 00000000..5ceeaf49 --- /dev/null +++ b/client/management/v3/zz_generated_target_node.go @@ -0,0 +1,18 @@ +package client + +const ( + TargetNodeType = "targetNode" + TargetNodeFieldCPUThreshold = "cpuThreshold" + TargetNodeFieldCondition = "condition" + TargetNodeFieldMemThreshold = "memThreshold" + TargetNodeFieldNodeId = "nodeId" + TargetNodeFieldSelector = "selector" +) + +type TargetNode struct { + CPUThreshold *int64 `json:"cpuThreshold,omitempty"` + Condition string `json:"condition,omitempty"` + MemThreshold *int64 `json:"memThreshold,omitempty"` + NodeId string `json:"nodeId,omitempty"` + Selector map[string]string `json:"selector,omitempty"` +} diff --git a/client/management/v3/zz_generated_target_pod.go b/client/management/v3/zz_generated_target_pod.go new file mode 100644 index 00000000..03f2ffae --- /dev/null +++ b/client/management/v3/zz_generated_target_pod.go @@ -0,0 +1,16 @@ +package client + +const ( + TargetPodType = "targetPod" + TargetPodFieldCondition = "condition" + TargetPodFieldPodId = "podId" + TargetPodFieldRestartIntervalSeconds = "restartIntervalSeconds" + TargetPodFieldRestartTimes = "restartTimes" +) + +type TargetPod struct { + Condition string `json:"condition,omitempty"` + PodId string `json:"podId,omitempty"` + RestartIntervalSeconds *int64 `json:"restartIntervalSeconds,omitempty"` + RestartTimes *int64 `json:"restartTimes,omitempty"` +} diff --git a/client/management/v3/zz_generated_target_system_service.go b/client/management/v3/zz_generated_target_system_service.go new file mode 100644 index 00000000..2592f7a5 --- /dev/null +++ b/client/management/v3/zz_generated_target_system_service.go @@ -0,0 +1,10 @@ +package client + +const ( + TargetSystemServiceType = "targetSystemService" + TargetSystemServiceFieldCondition = "condition" +) + +type TargetSystemService struct { + Condition string `json:"condition,omitempty"` +} diff --git a/client/management/v3/zz_generated_target_workload.go b/client/management/v3/zz_generated_target_workload.go new file mode 100644 index 00000000..5d4b0cfe --- /dev/null +++ b/client/management/v3/zz_generated_target_workload.go @@ -0,0 +1,16 @@ +package client + +const ( + TargetWorkloadType = "targetWorkload" + TargetWorkloadFieldAvailablePercentage = "availablePercentage" + TargetWorkloadFieldSelector = "selector" + TargetWorkloadFieldType = "type" + TargetWorkloadFieldWorkloadID = "workloadId" +) + +type TargetWorkload struct { + AvailablePercentage *int64 `json:"availablePercentage,omitempty"` + Selector map[string]string `json:"selector,omitempty"` + Type string `json:"type,omitempty"` + WorkloadID string `json:"workloadId,omitempty"` +} diff --git a/client/management/v3/zz_generated_webhook_config.go b/client/management/v3/zz_generated_webhook_config.go new file mode 100644 index 00000000..35225362 --- /dev/null +++ b/client/management/v3/zz_generated_webhook_config.go @@ -0,0 +1,10 @@ +package client + +const ( + WebhookConfigType = "webhookConfig" + WebhookConfigFieldURL = "url" +) + +type WebhookConfig struct { + URL string `json:"url,omitempty"` +}