From a2059725ddfa61c53d552af7d30fd2c3446ae85c Mon Sep 17 00:00:00 2001 From: wanjunlei <53003665+wanjunlei@users.noreply.github.com> Date: Wed, 20 Jul 2022 19:27:51 +0800 Subject: [PATCH] support clean up the notification configure when delete cluster (#5077) --- pkg/apis/addtoscheme_notification_v2beta2.go | 25 + pkg/apis/addtoscheme_types_v1beta2.go | 26 + pkg/apiserver/apiserver.go | 1 + .../v2beta2/fake/fake_notification_client.go | 4 + .../v2beta2/fake/fake_notificationmanager.go | 133 ++++ .../v2beta2/generated_expansion.go | 2 + .../v2beta2/notification_client.go | 5 + .../v2beta2/notificationmanager.go | 184 ++++++ .../fake/fake_federatednotificationconfig.go | 133 ++++ .../fake/fake_federatednotificationmanager.go | 133 ++++ .../fake_federatednotificationreceiver.go | 133 ++++ .../fake/fake_federatednotificationrouter.go | 133 ++++ .../fake/fake_federatednotificationsilence.go | 133 ++++ .../types/v1beta2/fake/fake_types_client.go | 21 + .../v1beta2/federatednotificationconfig.go | 184 ++++++ .../v1beta2/federatednotificationmanager.go | 184 ++++++ .../v1beta2/federatednotificationreceiver.go | 184 ++++++ .../v1beta2/federatednotificationrouter.go | 184 ++++++ .../v1beta2/federatednotificationsilence.go | 184 ++++++ .../types/v1beta2/generated_expansion.go | 10 + .../typed/types/v1beta2/types_client.go | 25 + .../informers/externalversions/generic.go | 15 + .../notification/v2beta2/interface.go | 7 + .../v2beta2/notificationmanager.go | 89 +++ .../externalversions/types/interface.go | 8 + .../v1beta2/federatednotificationconfig.go | 89 +++ .../v1beta2/federatednotificationmanager.go | 89 +++ .../v1beta2/federatednotificationreceiver.go | 89 +++ .../v1beta2/federatednotificationrouter.go | 89 +++ .../v1beta2/federatednotificationsilence.go | 89 +++ .../types/v1beta2/interface.go | 73 +++ .../v2beta2/expansion_generated.go | 4 + .../v2beta2/notificationmanager.go | 68 ++ .../types/v1beta2/expansion_generated.go | 39 ++ .../v1beta2/federatednotificationconfig.go | 68 ++ .../v1beta2/federatednotificationmanager.go | 68 ++ .../v1beta2/federatednotificationreceiver.go | 68 ++ .../v1beta2/federatednotificationrouter.go | 68 ++ .../v1beta2/federatednotificationsilence.go | 68 ++ pkg/controller/cluster/cluster_controller.go | 119 ++++ .../notification/notification_controller.go | 618 ++++++++---------- pkg/kapis/notification/v2beta2/register.go | 40 +- pkg/models/notification/notification.go | 23 +- .../v2beta2/notificationmanager_types.go | 11 +- .../api/notification/v2beta2/types.go | 4 + .../kubesphere.io/api/types/v1beta2/doc.go | 22 + .../federatednotificationconfig_types.go | 6 +- .../federatednotificationmanager_types.go | 65 ++ .../federatednotificationreceiver_types.go | 5 +- .../federatednotificationrouter_types.go | 5 +- .../federatednotificationsilence_types.go | 5 +- .../api/types/v1beta2/register.go | 2 + .../types/v1beta2/zz_generated.deepcopy.go | 104 +++ 53 files changed, 3754 insertions(+), 384 deletions(-) create mode 100644 pkg/apis/addtoscheme_notification_v2beta2.go create mode 100644 pkg/apis/addtoscheme_types_v1beta2.go create mode 100644 pkg/client/clientset/versioned/typed/notification/v2beta2/fake/fake_notificationmanager.go create mode 100644 pkg/client/clientset/versioned/typed/notification/v2beta2/notificationmanager.go create mode 100644 pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationconfig.go create mode 100644 pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationmanager.go create mode 100644 pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationreceiver.go create mode 100644 pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationrouter.go create mode 100644 pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationsilence.go create mode 100644 pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationconfig.go create mode 100644 pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationmanager.go create mode 100644 pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationreceiver.go create mode 100644 pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationrouter.go create mode 100644 pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationsilence.go create mode 100644 pkg/client/informers/externalversions/notification/v2beta2/notificationmanager.go create mode 100644 pkg/client/informers/externalversions/types/v1beta2/federatednotificationconfig.go create mode 100644 pkg/client/informers/externalversions/types/v1beta2/federatednotificationmanager.go create mode 100644 pkg/client/informers/externalversions/types/v1beta2/federatednotificationreceiver.go create mode 100644 pkg/client/informers/externalversions/types/v1beta2/federatednotificationrouter.go create mode 100644 pkg/client/informers/externalversions/types/v1beta2/federatednotificationsilence.go create mode 100644 pkg/client/informers/externalversions/types/v1beta2/interface.go create mode 100644 pkg/client/listers/notification/v2beta2/notificationmanager.go create mode 100644 pkg/client/listers/types/v1beta2/expansion_generated.go create mode 100644 pkg/client/listers/types/v1beta2/federatednotificationconfig.go create mode 100644 pkg/client/listers/types/v1beta2/federatednotificationmanager.go create mode 100644 pkg/client/listers/types/v1beta2/federatednotificationreceiver.go create mode 100644 pkg/client/listers/types/v1beta2/federatednotificationrouter.go create mode 100644 pkg/client/listers/types/v1beta2/federatednotificationsilence.go create mode 100644 staging/src/kubesphere.io/api/types/v1beta2/doc.go create mode 100644 staging/src/kubesphere.io/api/types/v1beta2/federatednotificationmanager_types.go diff --git a/pkg/apis/addtoscheme_notification_v2beta2.go b/pkg/apis/addtoscheme_notification_v2beta2.go new file mode 100644 index 000000000..e7a75b383 --- /dev/null +++ b/pkg/apis/addtoscheme_notification_v2beta2.go @@ -0,0 +1,25 @@ +/* +Copyright 2019 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package apis + +import ( + "kubesphere.io/api/notification/v2beta2" +) + +func init() { + AddToSchemes = append(AddToSchemes, v2beta2.SchemeBuilder.AddToScheme) +} diff --git a/pkg/apis/addtoscheme_types_v1beta2.go b/pkg/apis/addtoscheme_types_v1beta2.go new file mode 100644 index 000000000..a495dc3b1 --- /dev/null +++ b/pkg/apis/addtoscheme_types_v1beta2.go @@ -0,0 +1,26 @@ +/* +Copyright 2020 KubeSphere Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package apis + +import ( + typesv1beta2 "kubesphere.io/api/types/v1beta2" +) + +func init() { + // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back + AddToSchemes = append(AddToSchemes, typesv1beta2.AddToScheme) +} diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index 2ed17fc3d..075025af6 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -322,6 +322,7 @@ func (s *APIServer) buildHandlerChain(stopCh <-chan struct{}) { resourcev1alpha3.Resource(clusterv1alpha1.ResourcesPluralCluster), notificationv2beta1.Resource(notificationv2beta1.ResourcesPluralConfig), notificationv2beta1.Resource(notificationv2beta1.ResourcesPluralReceiver), + notificationv2beta2.Resource(notificationv2beta2.ResourcesPluralNotificationManager), notificationv2beta2.Resource(notificationv2beta2.ResourcesPluralConfig), notificationv2beta2.Resource(notificationv2beta2.ResourcesPluralReceiver), notificationv2beta2.Resource(notificationv2beta2.ResourcesPluralRouter), diff --git a/pkg/client/clientset/versioned/typed/notification/v2beta2/fake/fake_notification_client.go b/pkg/client/clientset/versioned/typed/notification/v2beta2/fake/fake_notification_client.go index 4e846b425..0b1a5f00b 100644 --- a/pkg/client/clientset/versioned/typed/notification/v2beta2/fake/fake_notification_client.go +++ b/pkg/client/clientset/versioned/typed/notification/v2beta2/fake/fake_notification_client.go @@ -32,6 +32,10 @@ func (c *FakeNotificationV2beta2) Configs() v2beta2.ConfigInterface { return &FakeConfigs{c} } +func (c *FakeNotificationV2beta2) NotificationManagers() v2beta2.NotificationManagerInterface { + return &FakeNotificationManagers{c} +} + func (c *FakeNotificationV2beta2) Receivers() v2beta2.ReceiverInterface { return &FakeReceivers{c} } diff --git a/pkg/client/clientset/versioned/typed/notification/v2beta2/fake/fake_notificationmanager.go b/pkg/client/clientset/versioned/typed/notification/v2beta2/fake/fake_notificationmanager.go new file mode 100644 index 000000000..f5d599469 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/notification/v2beta2/fake/fake_notificationmanager.go @@ -0,0 +1,133 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v2beta2 "kubesphere.io/api/notification/v2beta2" +) + +// FakeNotificationManagers implements NotificationManagerInterface +type FakeNotificationManagers struct { + Fake *FakeNotificationV2beta2 +} + +var notificationmanagersResource = schema.GroupVersionResource{Group: "notification.kubesphere.io", Version: "v2beta2", Resource: "notificationmanagers"} + +var notificationmanagersKind = schema.GroupVersionKind{Group: "notification.kubesphere.io", Version: "v2beta2", Kind: "NotificationManager"} + +// Get takes name of the notificationManager, and returns the corresponding notificationManager object, and an error if there is any. +func (c *FakeNotificationManagers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.NotificationManager, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(notificationmanagersResource, name), &v2beta2.NotificationManager{}) + if obj == nil { + return nil, err + } + return obj.(*v2beta2.NotificationManager), err +} + +// List takes label and field selectors, and returns the list of NotificationManagers that match those selectors. +func (c *FakeNotificationManagers) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.NotificationManagerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(notificationmanagersResource, notificationmanagersKind, opts), &v2beta2.NotificationManagerList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v2beta2.NotificationManagerList{ListMeta: obj.(*v2beta2.NotificationManagerList).ListMeta} + for _, item := range obj.(*v2beta2.NotificationManagerList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested notificationManagers. +func (c *FakeNotificationManagers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(notificationmanagersResource, opts)) +} + +// Create takes the representation of a notificationManager and creates it. Returns the server's representation of the notificationManager, and an error, if there is any. +func (c *FakeNotificationManagers) Create(ctx context.Context, notificationManager *v2beta2.NotificationManager, opts v1.CreateOptions) (result *v2beta2.NotificationManager, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(notificationmanagersResource, notificationManager), &v2beta2.NotificationManager{}) + if obj == nil { + return nil, err + } + return obj.(*v2beta2.NotificationManager), err +} + +// Update takes the representation of a notificationManager and updates it. Returns the server's representation of the notificationManager, and an error, if there is any. +func (c *FakeNotificationManagers) Update(ctx context.Context, notificationManager *v2beta2.NotificationManager, opts v1.UpdateOptions) (result *v2beta2.NotificationManager, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(notificationmanagersResource, notificationManager), &v2beta2.NotificationManager{}) + if obj == nil { + return nil, err + } + return obj.(*v2beta2.NotificationManager), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeNotificationManagers) UpdateStatus(ctx context.Context, notificationManager *v2beta2.NotificationManager, opts v1.UpdateOptions) (*v2beta2.NotificationManager, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(notificationmanagersResource, "status", notificationManager), &v2beta2.NotificationManager{}) + if obj == nil { + return nil, err + } + return obj.(*v2beta2.NotificationManager), err +} + +// Delete takes name of the notificationManager and deletes it. Returns an error if one occurs. +func (c *FakeNotificationManagers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(notificationmanagersResource, name), &v2beta2.NotificationManager{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeNotificationManagers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(notificationmanagersResource, listOpts) + + _, err := c.Fake.Invokes(action, &v2beta2.NotificationManagerList{}) + return err +} + +// Patch applies the patch and returns the patched notificationManager. +func (c *FakeNotificationManagers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.NotificationManager, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(notificationmanagersResource, name, pt, data, subresources...), &v2beta2.NotificationManager{}) + if obj == nil { + return nil, err + } + return obj.(*v2beta2.NotificationManager), err +} diff --git a/pkg/client/clientset/versioned/typed/notification/v2beta2/generated_expansion.go b/pkg/client/clientset/versioned/typed/notification/v2beta2/generated_expansion.go index 9f96706e7..23d797ce0 100644 --- a/pkg/client/clientset/versioned/typed/notification/v2beta2/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/notification/v2beta2/generated_expansion.go @@ -20,6 +20,8 @@ package v2beta2 type ConfigExpansion interface{} +type NotificationManagerExpansion interface{} + type ReceiverExpansion interface{} type RouterExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/notification/v2beta2/notification_client.go b/pkg/client/clientset/versioned/typed/notification/v2beta2/notification_client.go index c8c4df025..457e9520e 100644 --- a/pkg/client/clientset/versioned/typed/notification/v2beta2/notification_client.go +++ b/pkg/client/clientset/versioned/typed/notification/v2beta2/notification_client.go @@ -27,6 +27,7 @@ import ( type NotificationV2beta2Interface interface { RESTClient() rest.Interface ConfigsGetter + NotificationManagersGetter ReceiversGetter RoutersGetter SilencesGetter @@ -41,6 +42,10 @@ func (c *NotificationV2beta2Client) Configs() ConfigInterface { return newConfigs(c) } +func (c *NotificationV2beta2Client) NotificationManagers() NotificationManagerInterface { + return newNotificationManagers(c) +} + func (c *NotificationV2beta2Client) Receivers() ReceiverInterface { return newReceivers(c) } diff --git a/pkg/client/clientset/versioned/typed/notification/v2beta2/notificationmanager.go b/pkg/client/clientset/versioned/typed/notification/v2beta2/notificationmanager.go new file mode 100644 index 000000000..4595c896c --- /dev/null +++ b/pkg/client/clientset/versioned/typed/notification/v2beta2/notificationmanager.go @@ -0,0 +1,184 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v2beta2 + +import ( + "context" + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v2beta2 "kubesphere.io/api/notification/v2beta2" + scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme" +) + +// NotificationManagersGetter has a method to return a NotificationManagerInterface. +// A group's client should implement this interface. +type NotificationManagersGetter interface { + NotificationManagers() NotificationManagerInterface +} + +// NotificationManagerInterface has methods to work with NotificationManager resources. +type NotificationManagerInterface interface { + Create(ctx context.Context, notificationManager *v2beta2.NotificationManager, opts v1.CreateOptions) (*v2beta2.NotificationManager, error) + Update(ctx context.Context, notificationManager *v2beta2.NotificationManager, opts v1.UpdateOptions) (*v2beta2.NotificationManager, error) + UpdateStatus(ctx context.Context, notificationManager *v2beta2.NotificationManager, opts v1.UpdateOptions) (*v2beta2.NotificationManager, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v2beta2.NotificationManager, error) + List(ctx context.Context, opts v1.ListOptions) (*v2beta2.NotificationManagerList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.NotificationManager, err error) + NotificationManagerExpansion +} + +// notificationManagers implements NotificationManagerInterface +type notificationManagers struct { + client rest.Interface +} + +// newNotificationManagers returns a NotificationManagers +func newNotificationManagers(c *NotificationV2beta2Client) *notificationManagers { + return ¬ificationManagers{ + client: c.RESTClient(), + } +} + +// Get takes name of the notificationManager, and returns the corresponding notificationManager object, and an error if there is any. +func (c *notificationManagers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.NotificationManager, err error) { + result = &v2beta2.NotificationManager{} + err = c.client.Get(). + Resource("notificationmanagers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of NotificationManagers that match those selectors. +func (c *notificationManagers) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.NotificationManagerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v2beta2.NotificationManagerList{} + err = c.client.Get(). + Resource("notificationmanagers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested notificationManagers. +func (c *notificationManagers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("notificationmanagers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a notificationManager and creates it. Returns the server's representation of the notificationManager, and an error, if there is any. +func (c *notificationManagers) Create(ctx context.Context, notificationManager *v2beta2.NotificationManager, opts v1.CreateOptions) (result *v2beta2.NotificationManager, err error) { + result = &v2beta2.NotificationManager{} + err = c.client.Post(). + Resource("notificationmanagers"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(notificationManager). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a notificationManager and updates it. Returns the server's representation of the notificationManager, and an error, if there is any. +func (c *notificationManagers) Update(ctx context.Context, notificationManager *v2beta2.NotificationManager, opts v1.UpdateOptions) (result *v2beta2.NotificationManager, err error) { + result = &v2beta2.NotificationManager{} + err = c.client.Put(). + Resource("notificationmanagers"). + Name(notificationManager.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(notificationManager). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *notificationManagers) UpdateStatus(ctx context.Context, notificationManager *v2beta2.NotificationManager, opts v1.UpdateOptions) (result *v2beta2.NotificationManager, err error) { + result = &v2beta2.NotificationManager{} + err = c.client.Put(). + Resource("notificationmanagers"). + Name(notificationManager.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(notificationManager). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the notificationManager and deletes it. Returns an error if one occurs. +func (c *notificationManagers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("notificationmanagers"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *notificationManagers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("notificationmanagers"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched notificationManager. +func (c *notificationManagers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.NotificationManager, err error) { + result = &v2beta2.NotificationManager{} + err = c.client.Patch(pt). + Resource("notificationmanagers"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationconfig.go b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationconfig.go new file mode 100644 index 000000000..72837e670 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationconfig.go @@ -0,0 +1,133 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1beta2 "kubesphere.io/api/types/v1beta2" +) + +// FakeFederatedNotificationConfigs implements FederatedNotificationConfigInterface +type FakeFederatedNotificationConfigs struct { + Fake *FakeTypesV1beta2 +} + +var federatednotificationconfigsResource = schema.GroupVersionResource{Group: "types.kubefed.io", Version: "v1beta2", Resource: "federatednotificationconfigs"} + +var federatednotificationconfigsKind = schema.GroupVersionKind{Group: "types.kubefed.io", Version: "v1beta2", Kind: "FederatedNotificationConfig"} + +// Get takes name of the federatedNotificationConfig, and returns the corresponding federatedNotificationConfig object, and an error if there is any. +func (c *FakeFederatedNotificationConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.FederatedNotificationConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(federatednotificationconfigsResource, name), &v1beta2.FederatedNotificationConfig{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationConfig), err +} + +// List takes label and field selectors, and returns the list of FederatedNotificationConfigs that match those selectors. +func (c *FakeFederatedNotificationConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FederatedNotificationConfigList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(federatednotificationconfigsResource, federatednotificationconfigsKind, opts), &v1beta2.FederatedNotificationConfigList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.FederatedNotificationConfigList{ListMeta: obj.(*v1beta2.FederatedNotificationConfigList).ListMeta} + for _, item := range obj.(*v1beta2.FederatedNotificationConfigList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested federatedNotificationConfigs. +func (c *FakeFederatedNotificationConfigs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(federatednotificationconfigsResource, opts)) +} + +// Create takes the representation of a federatedNotificationConfig and creates it. Returns the server's representation of the federatedNotificationConfig, and an error, if there is any. +func (c *FakeFederatedNotificationConfigs) Create(ctx context.Context, federatedNotificationConfig *v1beta2.FederatedNotificationConfig, opts v1.CreateOptions) (result *v1beta2.FederatedNotificationConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(federatednotificationconfigsResource, federatedNotificationConfig), &v1beta2.FederatedNotificationConfig{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationConfig), err +} + +// Update takes the representation of a federatedNotificationConfig and updates it. Returns the server's representation of the federatedNotificationConfig, and an error, if there is any. +func (c *FakeFederatedNotificationConfigs) Update(ctx context.Context, federatedNotificationConfig *v1beta2.FederatedNotificationConfig, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(federatednotificationconfigsResource, federatedNotificationConfig), &v1beta2.FederatedNotificationConfig{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationConfig), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeFederatedNotificationConfigs) UpdateStatus(ctx context.Context, federatedNotificationConfig *v1beta2.FederatedNotificationConfig, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationConfig, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(federatednotificationconfigsResource, "status", federatedNotificationConfig), &v1beta2.FederatedNotificationConfig{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationConfig), err +} + +// Delete takes name of the federatedNotificationConfig and deletes it. Returns an error if one occurs. +func (c *FakeFederatedNotificationConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(federatednotificationconfigsResource, name), &v1beta2.FederatedNotificationConfig{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeFederatedNotificationConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(federatednotificationconfigsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.FederatedNotificationConfigList{}) + return err +} + +// Patch applies the patch and returns the patched federatedNotificationConfig. +func (c *FakeFederatedNotificationConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(federatednotificationconfigsResource, name, pt, data, subresources...), &v1beta2.FederatedNotificationConfig{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationConfig), err +} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationmanager.go b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationmanager.go new file mode 100644 index 000000000..35eda2884 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationmanager.go @@ -0,0 +1,133 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1beta2 "kubesphere.io/api/types/v1beta2" +) + +// FakeFederatedNotificationManagers implements FederatedNotificationManagerInterface +type FakeFederatedNotificationManagers struct { + Fake *FakeTypesV1beta2 +} + +var federatednotificationmanagersResource = schema.GroupVersionResource{Group: "types.kubefed.io", Version: "v1beta2", Resource: "federatednotificationmanagers"} + +var federatednotificationmanagersKind = schema.GroupVersionKind{Group: "types.kubefed.io", Version: "v1beta2", Kind: "FederatedNotificationManager"} + +// Get takes name of the federatedNotificationManager, and returns the corresponding federatedNotificationManager object, and an error if there is any. +func (c *FakeFederatedNotificationManagers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.FederatedNotificationManager, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(federatednotificationmanagersResource, name), &v1beta2.FederatedNotificationManager{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationManager), err +} + +// List takes label and field selectors, and returns the list of FederatedNotificationManagers that match those selectors. +func (c *FakeFederatedNotificationManagers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FederatedNotificationManagerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(federatednotificationmanagersResource, federatednotificationmanagersKind, opts), &v1beta2.FederatedNotificationManagerList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.FederatedNotificationManagerList{ListMeta: obj.(*v1beta2.FederatedNotificationManagerList).ListMeta} + for _, item := range obj.(*v1beta2.FederatedNotificationManagerList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested federatedNotificationManagers. +func (c *FakeFederatedNotificationManagers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(federatednotificationmanagersResource, opts)) +} + +// Create takes the representation of a federatedNotificationManager and creates it. Returns the server's representation of the federatedNotificationManager, and an error, if there is any. +func (c *FakeFederatedNotificationManagers) Create(ctx context.Context, federatedNotificationManager *v1beta2.FederatedNotificationManager, opts v1.CreateOptions) (result *v1beta2.FederatedNotificationManager, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(federatednotificationmanagersResource, federatedNotificationManager), &v1beta2.FederatedNotificationManager{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationManager), err +} + +// Update takes the representation of a federatedNotificationManager and updates it. Returns the server's representation of the federatedNotificationManager, and an error, if there is any. +func (c *FakeFederatedNotificationManagers) Update(ctx context.Context, federatedNotificationManager *v1beta2.FederatedNotificationManager, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationManager, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(federatednotificationmanagersResource, federatedNotificationManager), &v1beta2.FederatedNotificationManager{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationManager), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeFederatedNotificationManagers) UpdateStatus(ctx context.Context, federatedNotificationManager *v1beta2.FederatedNotificationManager, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationManager, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(federatednotificationmanagersResource, "status", federatedNotificationManager), &v1beta2.FederatedNotificationManager{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationManager), err +} + +// Delete takes name of the federatedNotificationManager and deletes it. Returns an error if one occurs. +func (c *FakeFederatedNotificationManagers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(federatednotificationmanagersResource, name), &v1beta2.FederatedNotificationManager{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeFederatedNotificationManagers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(federatednotificationmanagersResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.FederatedNotificationManagerList{}) + return err +} + +// Patch applies the patch and returns the patched federatedNotificationManager. +func (c *FakeFederatedNotificationManagers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationManager, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(federatednotificationmanagersResource, name, pt, data, subresources...), &v1beta2.FederatedNotificationManager{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationManager), err +} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationreceiver.go b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationreceiver.go new file mode 100644 index 000000000..53a1350fd --- /dev/null +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationreceiver.go @@ -0,0 +1,133 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1beta2 "kubesphere.io/api/types/v1beta2" +) + +// FakeFederatedNotificationReceivers implements FederatedNotificationReceiverInterface +type FakeFederatedNotificationReceivers struct { + Fake *FakeTypesV1beta2 +} + +var federatednotificationreceiversResource = schema.GroupVersionResource{Group: "types.kubefed.io", Version: "v1beta2", Resource: "federatednotificationreceivers"} + +var federatednotificationreceiversKind = schema.GroupVersionKind{Group: "types.kubefed.io", Version: "v1beta2", Kind: "FederatedNotificationReceiver"} + +// Get takes name of the federatedNotificationReceiver, and returns the corresponding federatedNotificationReceiver object, and an error if there is any. +func (c *FakeFederatedNotificationReceivers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.FederatedNotificationReceiver, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(federatednotificationreceiversResource, name), &v1beta2.FederatedNotificationReceiver{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationReceiver), err +} + +// List takes label and field selectors, and returns the list of FederatedNotificationReceivers that match those selectors. +func (c *FakeFederatedNotificationReceivers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FederatedNotificationReceiverList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(federatednotificationreceiversResource, federatednotificationreceiversKind, opts), &v1beta2.FederatedNotificationReceiverList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.FederatedNotificationReceiverList{ListMeta: obj.(*v1beta2.FederatedNotificationReceiverList).ListMeta} + for _, item := range obj.(*v1beta2.FederatedNotificationReceiverList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested federatedNotificationReceivers. +func (c *FakeFederatedNotificationReceivers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(federatednotificationreceiversResource, opts)) +} + +// Create takes the representation of a federatedNotificationReceiver and creates it. Returns the server's representation of the federatedNotificationReceiver, and an error, if there is any. +func (c *FakeFederatedNotificationReceivers) Create(ctx context.Context, federatedNotificationReceiver *v1beta2.FederatedNotificationReceiver, opts v1.CreateOptions) (result *v1beta2.FederatedNotificationReceiver, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(federatednotificationreceiversResource, federatedNotificationReceiver), &v1beta2.FederatedNotificationReceiver{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationReceiver), err +} + +// Update takes the representation of a federatedNotificationReceiver and updates it. Returns the server's representation of the federatedNotificationReceiver, and an error, if there is any. +func (c *FakeFederatedNotificationReceivers) Update(ctx context.Context, federatedNotificationReceiver *v1beta2.FederatedNotificationReceiver, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationReceiver, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(federatednotificationreceiversResource, federatedNotificationReceiver), &v1beta2.FederatedNotificationReceiver{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationReceiver), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeFederatedNotificationReceivers) UpdateStatus(ctx context.Context, federatedNotificationReceiver *v1beta2.FederatedNotificationReceiver, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationReceiver, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(federatednotificationreceiversResource, "status", federatedNotificationReceiver), &v1beta2.FederatedNotificationReceiver{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationReceiver), err +} + +// Delete takes name of the federatedNotificationReceiver and deletes it. Returns an error if one occurs. +func (c *FakeFederatedNotificationReceivers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(federatednotificationreceiversResource, name), &v1beta2.FederatedNotificationReceiver{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeFederatedNotificationReceivers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(federatednotificationreceiversResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.FederatedNotificationReceiverList{}) + return err +} + +// Patch applies the patch and returns the patched federatedNotificationReceiver. +func (c *FakeFederatedNotificationReceivers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationReceiver, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(federatednotificationreceiversResource, name, pt, data, subresources...), &v1beta2.FederatedNotificationReceiver{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationReceiver), err +} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationrouter.go b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationrouter.go new file mode 100644 index 000000000..c10e405e8 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationrouter.go @@ -0,0 +1,133 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1beta2 "kubesphere.io/api/types/v1beta2" +) + +// FakeFederatedNotificationRouters implements FederatedNotificationRouterInterface +type FakeFederatedNotificationRouters struct { + Fake *FakeTypesV1beta2 +} + +var federatednotificationroutersResource = schema.GroupVersionResource{Group: "types.kubefed.io", Version: "v1beta2", Resource: "federatednotificationrouters"} + +var federatednotificationroutersKind = schema.GroupVersionKind{Group: "types.kubefed.io", Version: "v1beta2", Kind: "FederatedNotificationRouter"} + +// Get takes name of the federatedNotificationRouter, and returns the corresponding federatedNotificationRouter object, and an error if there is any. +func (c *FakeFederatedNotificationRouters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.FederatedNotificationRouter, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(federatednotificationroutersResource, name), &v1beta2.FederatedNotificationRouter{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationRouter), err +} + +// List takes label and field selectors, and returns the list of FederatedNotificationRouters that match those selectors. +func (c *FakeFederatedNotificationRouters) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FederatedNotificationRouterList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(federatednotificationroutersResource, federatednotificationroutersKind, opts), &v1beta2.FederatedNotificationRouterList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.FederatedNotificationRouterList{ListMeta: obj.(*v1beta2.FederatedNotificationRouterList).ListMeta} + for _, item := range obj.(*v1beta2.FederatedNotificationRouterList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested federatedNotificationRouters. +func (c *FakeFederatedNotificationRouters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(federatednotificationroutersResource, opts)) +} + +// Create takes the representation of a federatedNotificationRouter and creates it. Returns the server's representation of the federatedNotificationRouter, and an error, if there is any. +func (c *FakeFederatedNotificationRouters) Create(ctx context.Context, federatedNotificationRouter *v1beta2.FederatedNotificationRouter, opts v1.CreateOptions) (result *v1beta2.FederatedNotificationRouter, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(federatednotificationroutersResource, federatedNotificationRouter), &v1beta2.FederatedNotificationRouter{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationRouter), err +} + +// Update takes the representation of a federatedNotificationRouter and updates it. Returns the server's representation of the federatedNotificationRouter, and an error, if there is any. +func (c *FakeFederatedNotificationRouters) Update(ctx context.Context, federatedNotificationRouter *v1beta2.FederatedNotificationRouter, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationRouter, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(federatednotificationroutersResource, federatedNotificationRouter), &v1beta2.FederatedNotificationRouter{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationRouter), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeFederatedNotificationRouters) UpdateStatus(ctx context.Context, federatedNotificationRouter *v1beta2.FederatedNotificationRouter, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationRouter, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(federatednotificationroutersResource, "status", federatedNotificationRouter), &v1beta2.FederatedNotificationRouter{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationRouter), err +} + +// Delete takes name of the federatedNotificationRouter and deletes it. Returns an error if one occurs. +func (c *FakeFederatedNotificationRouters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(federatednotificationroutersResource, name), &v1beta2.FederatedNotificationRouter{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeFederatedNotificationRouters) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(federatednotificationroutersResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.FederatedNotificationRouterList{}) + return err +} + +// Patch applies the patch and returns the patched federatedNotificationRouter. +func (c *FakeFederatedNotificationRouters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationRouter, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(federatednotificationroutersResource, name, pt, data, subresources...), &v1beta2.FederatedNotificationRouter{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationRouter), err +} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationsilence.go b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationsilence.go new file mode 100644 index 000000000..c8e5baa72 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_federatednotificationsilence.go @@ -0,0 +1,133 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1beta2 "kubesphere.io/api/types/v1beta2" +) + +// FakeFederatedNotificationSilences implements FederatedNotificationSilenceInterface +type FakeFederatedNotificationSilences struct { + Fake *FakeTypesV1beta2 +} + +var federatednotificationsilencesResource = schema.GroupVersionResource{Group: "types.kubefed.io", Version: "v1beta2", Resource: "federatednotificationsilences"} + +var federatednotificationsilencesKind = schema.GroupVersionKind{Group: "types.kubefed.io", Version: "v1beta2", Kind: "FederatedNotificationSilence"} + +// Get takes name of the federatedNotificationSilence, and returns the corresponding federatedNotificationSilence object, and an error if there is any. +func (c *FakeFederatedNotificationSilences) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.FederatedNotificationSilence, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(federatednotificationsilencesResource, name), &v1beta2.FederatedNotificationSilence{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationSilence), err +} + +// List takes label and field selectors, and returns the list of FederatedNotificationSilences that match those selectors. +func (c *FakeFederatedNotificationSilences) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FederatedNotificationSilenceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(federatednotificationsilencesResource, federatednotificationsilencesKind, opts), &v1beta2.FederatedNotificationSilenceList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta2.FederatedNotificationSilenceList{ListMeta: obj.(*v1beta2.FederatedNotificationSilenceList).ListMeta} + for _, item := range obj.(*v1beta2.FederatedNotificationSilenceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested federatedNotificationSilences. +func (c *FakeFederatedNotificationSilences) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(federatednotificationsilencesResource, opts)) +} + +// Create takes the representation of a federatedNotificationSilence and creates it. Returns the server's representation of the federatedNotificationSilence, and an error, if there is any. +func (c *FakeFederatedNotificationSilences) Create(ctx context.Context, federatedNotificationSilence *v1beta2.FederatedNotificationSilence, opts v1.CreateOptions) (result *v1beta2.FederatedNotificationSilence, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(federatednotificationsilencesResource, federatedNotificationSilence), &v1beta2.FederatedNotificationSilence{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationSilence), err +} + +// Update takes the representation of a federatedNotificationSilence and updates it. Returns the server's representation of the federatedNotificationSilence, and an error, if there is any. +func (c *FakeFederatedNotificationSilences) Update(ctx context.Context, federatedNotificationSilence *v1beta2.FederatedNotificationSilence, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationSilence, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(federatednotificationsilencesResource, federatedNotificationSilence), &v1beta2.FederatedNotificationSilence{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationSilence), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeFederatedNotificationSilences) UpdateStatus(ctx context.Context, federatedNotificationSilence *v1beta2.FederatedNotificationSilence, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationSilence, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(federatednotificationsilencesResource, "status", federatedNotificationSilence), &v1beta2.FederatedNotificationSilence{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationSilence), err +} + +// Delete takes name of the federatedNotificationSilence and deletes it. Returns an error if one occurs. +func (c *FakeFederatedNotificationSilences) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(federatednotificationsilencesResource, name), &v1beta2.FederatedNotificationSilence{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeFederatedNotificationSilences) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(federatednotificationsilencesResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta2.FederatedNotificationSilenceList{}) + return err +} + +// Patch applies the patch and returns the patched federatedNotificationSilence. +func (c *FakeFederatedNotificationSilences) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationSilence, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(federatednotificationsilencesResource, name, pt, data, subresources...), &v1beta2.FederatedNotificationSilence{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta2.FederatedNotificationSilence), err +} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_types_client.go b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_types_client.go index 800facdc2..326c123c8 100644 --- a/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_types_client.go +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/fake/fake_types_client.go @@ -21,12 +21,33 @@ package fake import ( rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" + v1beta2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/types/v1beta2" ) type FakeTypesV1beta2 struct { *testing.Fake } +func (c *FakeTypesV1beta2) FederatedNotificationConfigs() v1beta2.FederatedNotificationConfigInterface { + return &FakeFederatedNotificationConfigs{c} +} + +func (c *FakeTypesV1beta2) FederatedNotificationManagers() v1beta2.FederatedNotificationManagerInterface { + return &FakeFederatedNotificationManagers{c} +} + +func (c *FakeTypesV1beta2) FederatedNotificationReceivers() v1beta2.FederatedNotificationReceiverInterface { + return &FakeFederatedNotificationReceivers{c} +} + +func (c *FakeTypesV1beta2) FederatedNotificationRouters() v1beta2.FederatedNotificationRouterInterface { + return &FakeFederatedNotificationRouters{c} +} + +func (c *FakeTypesV1beta2) FederatedNotificationSilences() v1beta2.FederatedNotificationSilenceInterface { + return &FakeFederatedNotificationSilences{c} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeTypesV1beta2) RESTClient() rest.Interface { diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationconfig.go b/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationconfig.go new file mode 100644 index 000000000..c792087ab --- /dev/null +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationconfig.go @@ -0,0 +1,184 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1beta2 "kubesphere.io/api/types/v1beta2" + scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme" +) + +// FederatedNotificationConfigsGetter has a method to return a FederatedNotificationConfigInterface. +// A group's client should implement this interface. +type FederatedNotificationConfigsGetter interface { + FederatedNotificationConfigs() FederatedNotificationConfigInterface +} + +// FederatedNotificationConfigInterface has methods to work with FederatedNotificationConfig resources. +type FederatedNotificationConfigInterface interface { + Create(ctx context.Context, federatedNotificationConfig *v1beta2.FederatedNotificationConfig, opts v1.CreateOptions) (*v1beta2.FederatedNotificationConfig, error) + Update(ctx context.Context, federatedNotificationConfig *v1beta2.FederatedNotificationConfig, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationConfig, error) + UpdateStatus(ctx context.Context, federatedNotificationConfig *v1beta2.FederatedNotificationConfig, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationConfig, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.FederatedNotificationConfig, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta2.FederatedNotificationConfigList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationConfig, err error) + FederatedNotificationConfigExpansion +} + +// federatedNotificationConfigs implements FederatedNotificationConfigInterface +type federatedNotificationConfigs struct { + client rest.Interface +} + +// newFederatedNotificationConfigs returns a FederatedNotificationConfigs +func newFederatedNotificationConfigs(c *TypesV1beta2Client) *federatedNotificationConfigs { + return &federatedNotificationConfigs{ + client: c.RESTClient(), + } +} + +// Get takes name of the federatedNotificationConfig, and returns the corresponding federatedNotificationConfig object, and an error if there is any. +func (c *federatedNotificationConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.FederatedNotificationConfig, err error) { + result = &v1beta2.FederatedNotificationConfig{} + err = c.client.Get(). + Resource("federatednotificationconfigs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of FederatedNotificationConfigs that match those selectors. +func (c *federatedNotificationConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FederatedNotificationConfigList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.FederatedNotificationConfigList{} + err = c.client.Get(). + Resource("federatednotificationconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested federatedNotificationConfigs. +func (c *federatedNotificationConfigs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("federatednotificationconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a federatedNotificationConfig and creates it. Returns the server's representation of the federatedNotificationConfig, and an error, if there is any. +func (c *federatedNotificationConfigs) Create(ctx context.Context, federatedNotificationConfig *v1beta2.FederatedNotificationConfig, opts v1.CreateOptions) (result *v1beta2.FederatedNotificationConfig, err error) { + result = &v1beta2.FederatedNotificationConfig{} + err = c.client.Post(). + Resource("federatednotificationconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationConfig). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a federatedNotificationConfig and updates it. Returns the server's representation of the federatedNotificationConfig, and an error, if there is any. +func (c *federatedNotificationConfigs) Update(ctx context.Context, federatedNotificationConfig *v1beta2.FederatedNotificationConfig, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationConfig, err error) { + result = &v1beta2.FederatedNotificationConfig{} + err = c.client.Put(). + Resource("federatednotificationconfigs"). + Name(federatedNotificationConfig.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationConfig). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *federatedNotificationConfigs) UpdateStatus(ctx context.Context, federatedNotificationConfig *v1beta2.FederatedNotificationConfig, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationConfig, err error) { + result = &v1beta2.FederatedNotificationConfig{} + err = c.client.Put(). + Resource("federatednotificationconfigs"). + Name(federatedNotificationConfig.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationConfig). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the federatedNotificationConfig and deletes it. Returns an error if one occurs. +func (c *federatedNotificationConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("federatednotificationconfigs"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *federatedNotificationConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("federatednotificationconfigs"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched federatedNotificationConfig. +func (c *federatedNotificationConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationConfig, err error) { + result = &v1beta2.FederatedNotificationConfig{} + err = c.client.Patch(pt). + Resource("federatednotificationconfigs"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationmanager.go b/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationmanager.go new file mode 100644 index 000000000..4d9a483be --- /dev/null +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationmanager.go @@ -0,0 +1,184 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1beta2 "kubesphere.io/api/types/v1beta2" + scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme" +) + +// FederatedNotificationManagersGetter has a method to return a FederatedNotificationManagerInterface. +// A group's client should implement this interface. +type FederatedNotificationManagersGetter interface { + FederatedNotificationManagers() FederatedNotificationManagerInterface +} + +// FederatedNotificationManagerInterface has methods to work with FederatedNotificationManager resources. +type FederatedNotificationManagerInterface interface { + Create(ctx context.Context, federatedNotificationManager *v1beta2.FederatedNotificationManager, opts v1.CreateOptions) (*v1beta2.FederatedNotificationManager, error) + Update(ctx context.Context, federatedNotificationManager *v1beta2.FederatedNotificationManager, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationManager, error) + UpdateStatus(ctx context.Context, federatedNotificationManager *v1beta2.FederatedNotificationManager, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationManager, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.FederatedNotificationManager, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta2.FederatedNotificationManagerList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationManager, err error) + FederatedNotificationManagerExpansion +} + +// federatedNotificationManagers implements FederatedNotificationManagerInterface +type federatedNotificationManagers struct { + client rest.Interface +} + +// newFederatedNotificationManagers returns a FederatedNotificationManagers +func newFederatedNotificationManagers(c *TypesV1beta2Client) *federatedNotificationManagers { + return &federatedNotificationManagers{ + client: c.RESTClient(), + } +} + +// Get takes name of the federatedNotificationManager, and returns the corresponding federatedNotificationManager object, and an error if there is any. +func (c *federatedNotificationManagers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.FederatedNotificationManager, err error) { + result = &v1beta2.FederatedNotificationManager{} + err = c.client.Get(). + Resource("federatednotificationmanagers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of FederatedNotificationManagers that match those selectors. +func (c *federatedNotificationManagers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FederatedNotificationManagerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.FederatedNotificationManagerList{} + err = c.client.Get(). + Resource("federatednotificationmanagers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested federatedNotificationManagers. +func (c *federatedNotificationManagers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("federatednotificationmanagers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a federatedNotificationManager and creates it. Returns the server's representation of the federatedNotificationManager, and an error, if there is any. +func (c *federatedNotificationManagers) Create(ctx context.Context, federatedNotificationManager *v1beta2.FederatedNotificationManager, opts v1.CreateOptions) (result *v1beta2.FederatedNotificationManager, err error) { + result = &v1beta2.FederatedNotificationManager{} + err = c.client.Post(). + Resource("federatednotificationmanagers"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationManager). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a federatedNotificationManager and updates it. Returns the server's representation of the federatedNotificationManager, and an error, if there is any. +func (c *federatedNotificationManagers) Update(ctx context.Context, federatedNotificationManager *v1beta2.FederatedNotificationManager, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationManager, err error) { + result = &v1beta2.FederatedNotificationManager{} + err = c.client.Put(). + Resource("federatednotificationmanagers"). + Name(federatedNotificationManager.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationManager). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *federatedNotificationManagers) UpdateStatus(ctx context.Context, federatedNotificationManager *v1beta2.FederatedNotificationManager, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationManager, err error) { + result = &v1beta2.FederatedNotificationManager{} + err = c.client.Put(). + Resource("federatednotificationmanagers"). + Name(federatedNotificationManager.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationManager). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the federatedNotificationManager and deletes it. Returns an error if one occurs. +func (c *federatedNotificationManagers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("federatednotificationmanagers"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *federatedNotificationManagers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("federatednotificationmanagers"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched federatedNotificationManager. +func (c *federatedNotificationManagers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationManager, err error) { + result = &v1beta2.FederatedNotificationManager{} + err = c.client.Patch(pt). + Resource("federatednotificationmanagers"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationreceiver.go b/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationreceiver.go new file mode 100644 index 000000000..bb932ec3d --- /dev/null +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationreceiver.go @@ -0,0 +1,184 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1beta2 "kubesphere.io/api/types/v1beta2" + scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme" +) + +// FederatedNotificationReceiversGetter has a method to return a FederatedNotificationReceiverInterface. +// A group's client should implement this interface. +type FederatedNotificationReceiversGetter interface { + FederatedNotificationReceivers() FederatedNotificationReceiverInterface +} + +// FederatedNotificationReceiverInterface has methods to work with FederatedNotificationReceiver resources. +type FederatedNotificationReceiverInterface interface { + Create(ctx context.Context, federatedNotificationReceiver *v1beta2.FederatedNotificationReceiver, opts v1.CreateOptions) (*v1beta2.FederatedNotificationReceiver, error) + Update(ctx context.Context, federatedNotificationReceiver *v1beta2.FederatedNotificationReceiver, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationReceiver, error) + UpdateStatus(ctx context.Context, federatedNotificationReceiver *v1beta2.FederatedNotificationReceiver, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationReceiver, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.FederatedNotificationReceiver, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta2.FederatedNotificationReceiverList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationReceiver, err error) + FederatedNotificationReceiverExpansion +} + +// federatedNotificationReceivers implements FederatedNotificationReceiverInterface +type federatedNotificationReceivers struct { + client rest.Interface +} + +// newFederatedNotificationReceivers returns a FederatedNotificationReceivers +func newFederatedNotificationReceivers(c *TypesV1beta2Client) *federatedNotificationReceivers { + return &federatedNotificationReceivers{ + client: c.RESTClient(), + } +} + +// Get takes name of the federatedNotificationReceiver, and returns the corresponding federatedNotificationReceiver object, and an error if there is any. +func (c *federatedNotificationReceivers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.FederatedNotificationReceiver, err error) { + result = &v1beta2.FederatedNotificationReceiver{} + err = c.client.Get(). + Resource("federatednotificationreceivers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of FederatedNotificationReceivers that match those selectors. +func (c *federatedNotificationReceivers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FederatedNotificationReceiverList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.FederatedNotificationReceiverList{} + err = c.client.Get(). + Resource("federatednotificationreceivers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested federatedNotificationReceivers. +func (c *federatedNotificationReceivers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("federatednotificationreceivers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a federatedNotificationReceiver and creates it. Returns the server's representation of the federatedNotificationReceiver, and an error, if there is any. +func (c *federatedNotificationReceivers) Create(ctx context.Context, federatedNotificationReceiver *v1beta2.FederatedNotificationReceiver, opts v1.CreateOptions) (result *v1beta2.FederatedNotificationReceiver, err error) { + result = &v1beta2.FederatedNotificationReceiver{} + err = c.client.Post(). + Resource("federatednotificationreceivers"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationReceiver). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a federatedNotificationReceiver and updates it. Returns the server's representation of the federatedNotificationReceiver, and an error, if there is any. +func (c *federatedNotificationReceivers) Update(ctx context.Context, federatedNotificationReceiver *v1beta2.FederatedNotificationReceiver, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationReceiver, err error) { + result = &v1beta2.FederatedNotificationReceiver{} + err = c.client.Put(). + Resource("federatednotificationreceivers"). + Name(federatedNotificationReceiver.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationReceiver). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *federatedNotificationReceivers) UpdateStatus(ctx context.Context, federatedNotificationReceiver *v1beta2.FederatedNotificationReceiver, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationReceiver, err error) { + result = &v1beta2.FederatedNotificationReceiver{} + err = c.client.Put(). + Resource("federatednotificationreceivers"). + Name(federatedNotificationReceiver.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationReceiver). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the federatedNotificationReceiver and deletes it. Returns an error if one occurs. +func (c *federatedNotificationReceivers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("federatednotificationreceivers"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *federatedNotificationReceivers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("federatednotificationreceivers"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched federatedNotificationReceiver. +func (c *federatedNotificationReceivers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationReceiver, err error) { + result = &v1beta2.FederatedNotificationReceiver{} + err = c.client.Patch(pt). + Resource("federatednotificationreceivers"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationrouter.go b/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationrouter.go new file mode 100644 index 000000000..5d61d72fb --- /dev/null +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationrouter.go @@ -0,0 +1,184 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1beta2 "kubesphere.io/api/types/v1beta2" + scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme" +) + +// FederatedNotificationRoutersGetter has a method to return a FederatedNotificationRouterInterface. +// A group's client should implement this interface. +type FederatedNotificationRoutersGetter interface { + FederatedNotificationRouters() FederatedNotificationRouterInterface +} + +// FederatedNotificationRouterInterface has methods to work with FederatedNotificationRouter resources. +type FederatedNotificationRouterInterface interface { + Create(ctx context.Context, federatedNotificationRouter *v1beta2.FederatedNotificationRouter, opts v1.CreateOptions) (*v1beta2.FederatedNotificationRouter, error) + Update(ctx context.Context, federatedNotificationRouter *v1beta2.FederatedNotificationRouter, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationRouter, error) + UpdateStatus(ctx context.Context, federatedNotificationRouter *v1beta2.FederatedNotificationRouter, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationRouter, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.FederatedNotificationRouter, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta2.FederatedNotificationRouterList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationRouter, err error) + FederatedNotificationRouterExpansion +} + +// federatedNotificationRouters implements FederatedNotificationRouterInterface +type federatedNotificationRouters struct { + client rest.Interface +} + +// newFederatedNotificationRouters returns a FederatedNotificationRouters +func newFederatedNotificationRouters(c *TypesV1beta2Client) *federatedNotificationRouters { + return &federatedNotificationRouters{ + client: c.RESTClient(), + } +} + +// Get takes name of the federatedNotificationRouter, and returns the corresponding federatedNotificationRouter object, and an error if there is any. +func (c *federatedNotificationRouters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.FederatedNotificationRouter, err error) { + result = &v1beta2.FederatedNotificationRouter{} + err = c.client.Get(). + Resource("federatednotificationrouters"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of FederatedNotificationRouters that match those selectors. +func (c *federatedNotificationRouters) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FederatedNotificationRouterList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.FederatedNotificationRouterList{} + err = c.client.Get(). + Resource("federatednotificationrouters"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested federatedNotificationRouters. +func (c *federatedNotificationRouters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("federatednotificationrouters"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a federatedNotificationRouter and creates it. Returns the server's representation of the federatedNotificationRouter, and an error, if there is any. +func (c *federatedNotificationRouters) Create(ctx context.Context, federatedNotificationRouter *v1beta2.FederatedNotificationRouter, opts v1.CreateOptions) (result *v1beta2.FederatedNotificationRouter, err error) { + result = &v1beta2.FederatedNotificationRouter{} + err = c.client.Post(). + Resource("federatednotificationrouters"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationRouter). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a federatedNotificationRouter and updates it. Returns the server's representation of the federatedNotificationRouter, and an error, if there is any. +func (c *federatedNotificationRouters) Update(ctx context.Context, federatedNotificationRouter *v1beta2.FederatedNotificationRouter, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationRouter, err error) { + result = &v1beta2.FederatedNotificationRouter{} + err = c.client.Put(). + Resource("federatednotificationrouters"). + Name(federatedNotificationRouter.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationRouter). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *federatedNotificationRouters) UpdateStatus(ctx context.Context, federatedNotificationRouter *v1beta2.FederatedNotificationRouter, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationRouter, err error) { + result = &v1beta2.FederatedNotificationRouter{} + err = c.client.Put(). + Resource("federatednotificationrouters"). + Name(federatedNotificationRouter.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationRouter). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the federatedNotificationRouter and deletes it. Returns an error if one occurs. +func (c *federatedNotificationRouters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("federatednotificationrouters"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *federatedNotificationRouters) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("federatednotificationrouters"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched federatedNotificationRouter. +func (c *federatedNotificationRouters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationRouter, err error) { + result = &v1beta2.FederatedNotificationRouter{} + err = c.client.Patch(pt). + Resource("federatednotificationrouters"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationsilence.go b/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationsilence.go new file mode 100644 index 000000000..634ea0e80 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/federatednotificationsilence.go @@ -0,0 +1,184 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1beta2 "kubesphere.io/api/types/v1beta2" + scheme "kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme" +) + +// FederatedNotificationSilencesGetter has a method to return a FederatedNotificationSilenceInterface. +// A group's client should implement this interface. +type FederatedNotificationSilencesGetter interface { + FederatedNotificationSilences() FederatedNotificationSilenceInterface +} + +// FederatedNotificationSilenceInterface has methods to work with FederatedNotificationSilence resources. +type FederatedNotificationSilenceInterface interface { + Create(ctx context.Context, federatedNotificationSilence *v1beta2.FederatedNotificationSilence, opts v1.CreateOptions) (*v1beta2.FederatedNotificationSilence, error) + Update(ctx context.Context, federatedNotificationSilence *v1beta2.FederatedNotificationSilence, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationSilence, error) + UpdateStatus(ctx context.Context, federatedNotificationSilence *v1beta2.FederatedNotificationSilence, opts v1.UpdateOptions) (*v1beta2.FederatedNotificationSilence, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.FederatedNotificationSilence, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta2.FederatedNotificationSilenceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationSilence, err error) + FederatedNotificationSilenceExpansion +} + +// federatedNotificationSilences implements FederatedNotificationSilenceInterface +type federatedNotificationSilences struct { + client rest.Interface +} + +// newFederatedNotificationSilences returns a FederatedNotificationSilences +func newFederatedNotificationSilences(c *TypesV1beta2Client) *federatedNotificationSilences { + return &federatedNotificationSilences{ + client: c.RESTClient(), + } +} + +// Get takes name of the federatedNotificationSilence, and returns the corresponding federatedNotificationSilence object, and an error if there is any. +func (c *federatedNotificationSilences) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.FederatedNotificationSilence, err error) { + result = &v1beta2.FederatedNotificationSilence{} + err = c.client.Get(). + Resource("federatednotificationsilences"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of FederatedNotificationSilences that match those selectors. +func (c *federatedNotificationSilences) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FederatedNotificationSilenceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.FederatedNotificationSilenceList{} + err = c.client.Get(). + Resource("federatednotificationsilences"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested federatedNotificationSilences. +func (c *federatedNotificationSilences) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("federatednotificationsilences"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a federatedNotificationSilence and creates it. Returns the server's representation of the federatedNotificationSilence, and an error, if there is any. +func (c *federatedNotificationSilences) Create(ctx context.Context, federatedNotificationSilence *v1beta2.FederatedNotificationSilence, opts v1.CreateOptions) (result *v1beta2.FederatedNotificationSilence, err error) { + result = &v1beta2.FederatedNotificationSilence{} + err = c.client.Post(). + Resource("federatednotificationsilences"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationSilence). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a federatedNotificationSilence and updates it. Returns the server's representation of the federatedNotificationSilence, and an error, if there is any. +func (c *federatedNotificationSilences) Update(ctx context.Context, federatedNotificationSilence *v1beta2.FederatedNotificationSilence, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationSilence, err error) { + result = &v1beta2.FederatedNotificationSilence{} + err = c.client.Put(). + Resource("federatednotificationsilences"). + Name(federatedNotificationSilence.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationSilence). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *federatedNotificationSilences) UpdateStatus(ctx context.Context, federatedNotificationSilence *v1beta2.FederatedNotificationSilence, opts v1.UpdateOptions) (result *v1beta2.FederatedNotificationSilence, err error) { + result = &v1beta2.FederatedNotificationSilence{} + err = c.client.Put(). + Resource("federatednotificationsilences"). + Name(federatedNotificationSilence.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(federatedNotificationSilence). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the federatedNotificationSilence and deletes it. Returns an error if one occurs. +func (c *federatedNotificationSilences) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("federatednotificationsilences"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *federatedNotificationSilences) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("federatednotificationsilences"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched federatedNotificationSilence. +func (c *federatedNotificationSilences) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.FederatedNotificationSilence, err error) { + result = &v1beta2.FederatedNotificationSilence{} + err = c.client.Patch(pt). + Resource("federatednotificationsilences"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/generated_expansion.go b/pkg/client/clientset/versioned/typed/types/v1beta2/generated_expansion.go index 924a63f0b..942e326d2 100644 --- a/pkg/client/clientset/versioned/typed/types/v1beta2/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/generated_expansion.go @@ -17,3 +17,13 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. package v1beta2 + +type FederatedNotificationConfigExpansion interface{} + +type FederatedNotificationManagerExpansion interface{} + +type FederatedNotificationReceiverExpansion interface{} + +type FederatedNotificationRouterExpansion interface{} + +type FederatedNotificationSilenceExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/types/v1beta2/types_client.go b/pkg/client/clientset/versioned/typed/types/v1beta2/types_client.go index 4040608b5..1704e827e 100644 --- a/pkg/client/clientset/versioned/typed/types/v1beta2/types_client.go +++ b/pkg/client/clientset/versioned/typed/types/v1beta2/types_client.go @@ -26,6 +26,11 @@ import ( type TypesV1beta2Interface interface { RESTClient() rest.Interface + FederatedNotificationConfigsGetter + FederatedNotificationManagersGetter + FederatedNotificationReceiversGetter + FederatedNotificationRoutersGetter + FederatedNotificationSilencesGetter } // TypesV1beta2Client is used to interact with features provided by the types.kubefed.io group. @@ -33,6 +38,26 @@ type TypesV1beta2Client struct { restClient rest.Interface } +func (c *TypesV1beta2Client) FederatedNotificationConfigs() FederatedNotificationConfigInterface { + return newFederatedNotificationConfigs(c) +} + +func (c *TypesV1beta2Client) FederatedNotificationManagers() FederatedNotificationManagerInterface { + return newFederatedNotificationManagers(c) +} + +func (c *TypesV1beta2Client) FederatedNotificationReceivers() FederatedNotificationReceiverInterface { + return newFederatedNotificationReceivers(c) +} + +func (c *TypesV1beta2Client) FederatedNotificationRouters() FederatedNotificationRouterInterface { + return newFederatedNotificationRouters(c) +} + +func (c *TypesV1beta2Client) FederatedNotificationSilences() FederatedNotificationSilenceInterface { + return newFederatedNotificationSilences(c) +} + // NewForConfig creates a new TypesV1beta2Client for the given config. func NewForConfig(c *rest.Config) (*TypesV1beta2Client, error) { config := *c diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 4e607c635..aedcb170a 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -38,6 +38,7 @@ import ( tenantv1alpha1 "kubesphere.io/api/tenant/v1alpha1" tenantv1alpha2 "kubesphere.io/api/tenant/v1alpha2" v1beta1 "kubesphere.io/api/types/v1beta1" + v1beta2 "kubesphere.io/api/types/v1beta2" ) // GenericInformer is type of SharedIndexInformer which will locate and delegate to other @@ -143,6 +144,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource // Group=notification.kubesphere.io, Version=v2beta2 case v2beta2.SchemeGroupVersion.WithResource("configs"): return &genericInformer{resource: resource.GroupResource(), informer: f.Notification().V2beta2().Configs().Informer()}, nil + case v2beta2.SchemeGroupVersion.WithResource("notificationmanagers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Notification().V2beta2().NotificationManagers().Informer()}, nil case v2beta2.SchemeGroupVersion.WithResource("receivers"): return &genericInformer{resource: resource.GroupResource(), informer: f.Notification().V2beta2().Receivers().Informer()}, nil case v2beta2.SchemeGroupVersion.WithResource("routers"): @@ -206,6 +209,18 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1beta1.SchemeGroupVersion.WithResource("federatedstatefulsets"): return &genericInformer{resource: resource.GroupResource(), informer: f.Types().V1beta1().FederatedStatefulSets().Informer()}, nil + // Group=types.kubefed.io, Version=v1beta2 + case v1beta2.SchemeGroupVersion.WithResource("federatednotificationconfigs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Types().V1beta2().FederatedNotificationConfigs().Informer()}, nil + case v1beta2.SchemeGroupVersion.WithResource("federatednotificationmanagers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Types().V1beta2().FederatedNotificationManagers().Informer()}, nil + case v1beta2.SchemeGroupVersion.WithResource("federatednotificationreceivers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Types().V1beta2().FederatedNotificationReceivers().Informer()}, nil + case v1beta2.SchemeGroupVersion.WithResource("federatednotificationrouters"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Types().V1beta2().FederatedNotificationRouters().Informer()}, nil + case v1beta2.SchemeGroupVersion.WithResource("federatednotificationsilences"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Types().V1beta2().FederatedNotificationSilences().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/client/informers/externalversions/notification/v2beta2/interface.go b/pkg/client/informers/externalversions/notification/v2beta2/interface.go index 052adede6..053b58d3b 100644 --- a/pkg/client/informers/externalversions/notification/v2beta2/interface.go +++ b/pkg/client/informers/externalversions/notification/v2beta2/interface.go @@ -26,6 +26,8 @@ import ( type Interface interface { // Configs returns a ConfigInformer. Configs() ConfigInformer + // NotificationManagers returns a NotificationManagerInformer. + NotificationManagers() NotificationManagerInformer // Receivers returns a ReceiverInformer. Receivers() ReceiverInformer // Routers returns a RouterInformer. @@ -50,6 +52,11 @@ func (v *version) Configs() ConfigInformer { return &configInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } +// NotificationManagers returns a NotificationManagerInformer. +func (v *version) NotificationManagers() NotificationManagerInformer { + return ¬ificationManagerInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + // Receivers returns a ReceiverInformer. func (v *version) Receivers() ReceiverInformer { return &receiverInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/notification/v2beta2/notificationmanager.go b/pkg/client/informers/externalversions/notification/v2beta2/notificationmanager.go new file mode 100644 index 000000000..03c6add1a --- /dev/null +++ b/pkg/client/informers/externalversions/notification/v2beta2/notificationmanager.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v2beta2 + +import ( + "context" + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + notificationv2beta2 "kubesphere.io/api/notification/v2beta2" + versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned" + internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces" + v2beta2 "kubesphere.io/kubesphere/pkg/client/listers/notification/v2beta2" +) + +// NotificationManagerInformer provides access to a shared informer and lister for +// NotificationManagers. +type NotificationManagerInformer interface { + Informer() cache.SharedIndexInformer + Lister() v2beta2.NotificationManagerLister +} + +type notificationManagerInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewNotificationManagerInformer constructs a new informer for NotificationManager type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewNotificationManagerInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredNotificationManagerInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredNotificationManagerInformer constructs a new informer for NotificationManager type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredNotificationManagerInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NotificationV2beta2().NotificationManagers().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NotificationV2beta2().NotificationManagers().Watch(context.TODO(), options) + }, + }, + ¬ificationv2beta2.NotificationManager{}, + resyncPeriod, + indexers, + ) +} + +func (f *notificationManagerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredNotificationManagerInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *notificationManagerInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(¬ificationv2beta2.NotificationManager{}, f.defaultInformer) +} + +func (f *notificationManagerInformer) Lister() v2beta2.NotificationManagerLister { + return v2beta2.NewNotificationManagerLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/types/interface.go b/pkg/client/informers/externalversions/types/interface.go index 4fa20e66a..1775be65d 100644 --- a/pkg/client/informers/externalversions/types/interface.go +++ b/pkg/client/informers/externalversions/types/interface.go @@ -21,12 +21,15 @@ package types import ( internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces" v1beta1 "kubesphere.io/kubesphere/pkg/client/informers/externalversions/types/v1beta1" + v1beta2 "kubesphere.io/kubesphere/pkg/client/informers/externalversions/types/v1beta2" ) // Interface provides access to each of this group's versions. type Interface interface { // V1beta1 provides access to shared informers for resources in V1beta1. V1beta1() v1beta1.Interface + // V1beta2 provides access to shared informers for resources in V1beta2. + V1beta2() v1beta2.Interface } type group struct { @@ -44,3 +47,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (g *group) V1beta1() v1beta1.Interface { return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1beta2 returns a new v1beta2.Interface. +func (g *group) V1beta2() v1beta2.Interface { + return v1beta2.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/types/v1beta2/federatednotificationconfig.go b/pkg/client/informers/externalversions/types/v1beta2/federatednotificationconfig.go new file mode 100644 index 000000000..b252313e7 --- /dev/null +++ b/pkg/client/informers/externalversions/types/v1beta2/federatednotificationconfig.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + typesv1beta2 "kubesphere.io/api/types/v1beta2" + versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned" + internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces" + v1beta2 "kubesphere.io/kubesphere/pkg/client/listers/types/v1beta2" +) + +// FederatedNotificationConfigInformer provides access to a shared informer and lister for +// FederatedNotificationConfigs. +type FederatedNotificationConfigInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta2.FederatedNotificationConfigLister +} + +type federatedNotificationConfigInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewFederatedNotificationConfigInformer constructs a new informer for FederatedNotificationConfig type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFederatedNotificationConfigInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredFederatedNotificationConfigInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredFederatedNotificationConfigInformer constructs a new informer for FederatedNotificationConfig type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredFederatedNotificationConfigInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TypesV1beta2().FederatedNotificationConfigs().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TypesV1beta2().FederatedNotificationConfigs().Watch(context.TODO(), options) + }, + }, + &typesv1beta2.FederatedNotificationConfig{}, + resyncPeriod, + indexers, + ) +} + +func (f *federatedNotificationConfigInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredFederatedNotificationConfigInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *federatedNotificationConfigInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&typesv1beta2.FederatedNotificationConfig{}, f.defaultInformer) +} + +func (f *federatedNotificationConfigInformer) Lister() v1beta2.FederatedNotificationConfigLister { + return v1beta2.NewFederatedNotificationConfigLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/types/v1beta2/federatednotificationmanager.go b/pkg/client/informers/externalversions/types/v1beta2/federatednotificationmanager.go new file mode 100644 index 000000000..f8df75acd --- /dev/null +++ b/pkg/client/informers/externalversions/types/v1beta2/federatednotificationmanager.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + typesv1beta2 "kubesphere.io/api/types/v1beta2" + versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned" + internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces" + v1beta2 "kubesphere.io/kubesphere/pkg/client/listers/types/v1beta2" +) + +// FederatedNotificationManagerInformer provides access to a shared informer and lister for +// FederatedNotificationManagers. +type FederatedNotificationManagerInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta2.FederatedNotificationManagerLister +} + +type federatedNotificationManagerInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewFederatedNotificationManagerInformer constructs a new informer for FederatedNotificationManager type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFederatedNotificationManagerInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredFederatedNotificationManagerInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredFederatedNotificationManagerInformer constructs a new informer for FederatedNotificationManager type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredFederatedNotificationManagerInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TypesV1beta2().FederatedNotificationManagers().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TypesV1beta2().FederatedNotificationManagers().Watch(context.TODO(), options) + }, + }, + &typesv1beta2.FederatedNotificationManager{}, + resyncPeriod, + indexers, + ) +} + +func (f *federatedNotificationManagerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredFederatedNotificationManagerInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *federatedNotificationManagerInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&typesv1beta2.FederatedNotificationManager{}, f.defaultInformer) +} + +func (f *federatedNotificationManagerInformer) Lister() v1beta2.FederatedNotificationManagerLister { + return v1beta2.NewFederatedNotificationManagerLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/types/v1beta2/federatednotificationreceiver.go b/pkg/client/informers/externalversions/types/v1beta2/federatednotificationreceiver.go new file mode 100644 index 000000000..6a6759dac --- /dev/null +++ b/pkg/client/informers/externalversions/types/v1beta2/federatednotificationreceiver.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + typesv1beta2 "kubesphere.io/api/types/v1beta2" + versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned" + internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces" + v1beta2 "kubesphere.io/kubesphere/pkg/client/listers/types/v1beta2" +) + +// FederatedNotificationReceiverInformer provides access to a shared informer and lister for +// FederatedNotificationReceivers. +type FederatedNotificationReceiverInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta2.FederatedNotificationReceiverLister +} + +type federatedNotificationReceiverInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewFederatedNotificationReceiverInformer constructs a new informer for FederatedNotificationReceiver type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFederatedNotificationReceiverInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredFederatedNotificationReceiverInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredFederatedNotificationReceiverInformer constructs a new informer for FederatedNotificationReceiver type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredFederatedNotificationReceiverInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TypesV1beta2().FederatedNotificationReceivers().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TypesV1beta2().FederatedNotificationReceivers().Watch(context.TODO(), options) + }, + }, + &typesv1beta2.FederatedNotificationReceiver{}, + resyncPeriod, + indexers, + ) +} + +func (f *federatedNotificationReceiverInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredFederatedNotificationReceiverInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *federatedNotificationReceiverInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&typesv1beta2.FederatedNotificationReceiver{}, f.defaultInformer) +} + +func (f *federatedNotificationReceiverInformer) Lister() v1beta2.FederatedNotificationReceiverLister { + return v1beta2.NewFederatedNotificationReceiverLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/types/v1beta2/federatednotificationrouter.go b/pkg/client/informers/externalversions/types/v1beta2/federatednotificationrouter.go new file mode 100644 index 000000000..d4ae35bba --- /dev/null +++ b/pkg/client/informers/externalversions/types/v1beta2/federatednotificationrouter.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + typesv1beta2 "kubesphere.io/api/types/v1beta2" + versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned" + internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces" + v1beta2 "kubesphere.io/kubesphere/pkg/client/listers/types/v1beta2" +) + +// FederatedNotificationRouterInformer provides access to a shared informer and lister for +// FederatedNotificationRouters. +type FederatedNotificationRouterInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta2.FederatedNotificationRouterLister +} + +type federatedNotificationRouterInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewFederatedNotificationRouterInformer constructs a new informer for FederatedNotificationRouter type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFederatedNotificationRouterInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredFederatedNotificationRouterInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredFederatedNotificationRouterInformer constructs a new informer for FederatedNotificationRouter type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredFederatedNotificationRouterInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TypesV1beta2().FederatedNotificationRouters().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TypesV1beta2().FederatedNotificationRouters().Watch(context.TODO(), options) + }, + }, + &typesv1beta2.FederatedNotificationRouter{}, + resyncPeriod, + indexers, + ) +} + +func (f *federatedNotificationRouterInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredFederatedNotificationRouterInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *federatedNotificationRouterInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&typesv1beta2.FederatedNotificationRouter{}, f.defaultInformer) +} + +func (f *federatedNotificationRouterInformer) Lister() v1beta2.FederatedNotificationRouterLister { + return v1beta2.NewFederatedNotificationRouterLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/types/v1beta2/federatednotificationsilence.go b/pkg/client/informers/externalversions/types/v1beta2/federatednotificationsilence.go new file mode 100644 index 000000000..55964dd8f --- /dev/null +++ b/pkg/client/informers/externalversions/types/v1beta2/federatednotificationsilence.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "context" + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + typesv1beta2 "kubesphere.io/api/types/v1beta2" + versioned "kubesphere.io/kubesphere/pkg/client/clientset/versioned" + internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces" + v1beta2 "kubesphere.io/kubesphere/pkg/client/listers/types/v1beta2" +) + +// FederatedNotificationSilenceInformer provides access to a shared informer and lister for +// FederatedNotificationSilences. +type FederatedNotificationSilenceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta2.FederatedNotificationSilenceLister +} + +type federatedNotificationSilenceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewFederatedNotificationSilenceInformer constructs a new informer for FederatedNotificationSilence type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFederatedNotificationSilenceInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredFederatedNotificationSilenceInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredFederatedNotificationSilenceInformer constructs a new informer for FederatedNotificationSilence type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredFederatedNotificationSilenceInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TypesV1beta2().FederatedNotificationSilences().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.TypesV1beta2().FederatedNotificationSilences().Watch(context.TODO(), options) + }, + }, + &typesv1beta2.FederatedNotificationSilence{}, + resyncPeriod, + indexers, + ) +} + +func (f *federatedNotificationSilenceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredFederatedNotificationSilenceInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *federatedNotificationSilenceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&typesv1beta2.FederatedNotificationSilence{}, f.defaultInformer) +} + +func (f *federatedNotificationSilenceInformer) Lister() v1beta2.FederatedNotificationSilenceLister { + return v1beta2.NewFederatedNotificationSilenceLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/types/v1beta2/interface.go b/pkg/client/informers/externalversions/types/v1beta2/interface.go new file mode 100644 index 000000000..e878d11f6 --- /dev/null +++ b/pkg/client/informers/externalversions/types/v1beta2/interface.go @@ -0,0 +1,73 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta2 + +import ( + internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // FederatedNotificationConfigs returns a FederatedNotificationConfigInformer. + FederatedNotificationConfigs() FederatedNotificationConfigInformer + // FederatedNotificationManagers returns a FederatedNotificationManagerInformer. + FederatedNotificationManagers() FederatedNotificationManagerInformer + // FederatedNotificationReceivers returns a FederatedNotificationReceiverInformer. + FederatedNotificationReceivers() FederatedNotificationReceiverInformer + // FederatedNotificationRouters returns a FederatedNotificationRouterInformer. + FederatedNotificationRouters() FederatedNotificationRouterInformer + // FederatedNotificationSilences returns a FederatedNotificationSilenceInformer. + FederatedNotificationSilences() FederatedNotificationSilenceInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// FederatedNotificationConfigs returns a FederatedNotificationConfigInformer. +func (v *version) FederatedNotificationConfigs() FederatedNotificationConfigInformer { + return &federatedNotificationConfigInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// FederatedNotificationManagers returns a FederatedNotificationManagerInformer. +func (v *version) FederatedNotificationManagers() FederatedNotificationManagerInformer { + return &federatedNotificationManagerInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// FederatedNotificationReceivers returns a FederatedNotificationReceiverInformer. +func (v *version) FederatedNotificationReceivers() FederatedNotificationReceiverInformer { + return &federatedNotificationReceiverInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// FederatedNotificationRouters returns a FederatedNotificationRouterInformer. +func (v *version) FederatedNotificationRouters() FederatedNotificationRouterInformer { + return &federatedNotificationRouterInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + +// FederatedNotificationSilences returns a FederatedNotificationSilenceInformer. +func (v *version) FederatedNotificationSilences() FederatedNotificationSilenceInformer { + return &federatedNotificationSilenceInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/listers/notification/v2beta2/expansion_generated.go b/pkg/client/listers/notification/v2beta2/expansion_generated.go index 63d59d52d..6b5d028e8 100644 --- a/pkg/client/listers/notification/v2beta2/expansion_generated.go +++ b/pkg/client/listers/notification/v2beta2/expansion_generated.go @@ -22,6 +22,10 @@ package v2beta2 // ConfigLister. type ConfigListerExpansion interface{} +// NotificationManagerListerExpansion allows custom methods to be added to +// NotificationManagerLister. +type NotificationManagerListerExpansion interface{} + // ReceiverListerExpansion allows custom methods to be added to // ReceiverLister. type ReceiverListerExpansion interface{} diff --git a/pkg/client/listers/notification/v2beta2/notificationmanager.go b/pkg/client/listers/notification/v2beta2/notificationmanager.go new file mode 100644 index 000000000..63ec2a8ac --- /dev/null +++ b/pkg/client/listers/notification/v2beta2/notificationmanager.go @@ -0,0 +1,68 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v2beta2 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v2beta2 "kubesphere.io/api/notification/v2beta2" +) + +// NotificationManagerLister helps list NotificationManagers. +// All objects returned here must be treated as read-only. +type NotificationManagerLister interface { + // List lists all NotificationManagers in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v2beta2.NotificationManager, err error) + // Get retrieves the NotificationManager from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v2beta2.NotificationManager, error) + NotificationManagerListerExpansion +} + +// notificationManagerLister implements the NotificationManagerLister interface. +type notificationManagerLister struct { + indexer cache.Indexer +} + +// NewNotificationManagerLister returns a new NotificationManagerLister. +func NewNotificationManagerLister(indexer cache.Indexer) NotificationManagerLister { + return ¬ificationManagerLister{indexer: indexer} +} + +// List lists all NotificationManagers in the indexer. +func (s *notificationManagerLister) List(selector labels.Selector) (ret []*v2beta2.NotificationManager, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v2beta2.NotificationManager)) + }) + return ret, err +} + +// Get retrieves the NotificationManager from the index for a given name. +func (s *notificationManagerLister) Get(name string) (*v2beta2.NotificationManager, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v2beta2.Resource("notificationmanager"), name) + } + return obj.(*v2beta2.NotificationManager), nil +} diff --git a/pkg/client/listers/types/v1beta2/expansion_generated.go b/pkg/client/listers/types/v1beta2/expansion_generated.go new file mode 100644 index 000000000..823651ed7 --- /dev/null +++ b/pkg/client/listers/types/v1beta2/expansion_generated.go @@ -0,0 +1,39 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta2 + +// FederatedNotificationConfigListerExpansion allows custom methods to be added to +// FederatedNotificationConfigLister. +type FederatedNotificationConfigListerExpansion interface{} + +// FederatedNotificationManagerListerExpansion allows custom methods to be added to +// FederatedNotificationManagerLister. +type FederatedNotificationManagerListerExpansion interface{} + +// FederatedNotificationReceiverListerExpansion allows custom methods to be added to +// FederatedNotificationReceiverLister. +type FederatedNotificationReceiverListerExpansion interface{} + +// FederatedNotificationRouterListerExpansion allows custom methods to be added to +// FederatedNotificationRouterLister. +type FederatedNotificationRouterListerExpansion interface{} + +// FederatedNotificationSilenceListerExpansion allows custom methods to be added to +// FederatedNotificationSilenceLister. +type FederatedNotificationSilenceListerExpansion interface{} diff --git a/pkg/client/listers/types/v1beta2/federatednotificationconfig.go b/pkg/client/listers/types/v1beta2/federatednotificationconfig.go new file mode 100644 index 000000000..5be650255 --- /dev/null +++ b/pkg/client/listers/types/v1beta2/federatednotificationconfig.go @@ -0,0 +1,68 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta2 "kubesphere.io/api/types/v1beta2" +) + +// FederatedNotificationConfigLister helps list FederatedNotificationConfigs. +// All objects returned here must be treated as read-only. +type FederatedNotificationConfigLister interface { + // List lists all FederatedNotificationConfigs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta2.FederatedNotificationConfig, err error) + // Get retrieves the FederatedNotificationConfig from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta2.FederatedNotificationConfig, error) + FederatedNotificationConfigListerExpansion +} + +// federatedNotificationConfigLister implements the FederatedNotificationConfigLister interface. +type federatedNotificationConfigLister struct { + indexer cache.Indexer +} + +// NewFederatedNotificationConfigLister returns a new FederatedNotificationConfigLister. +func NewFederatedNotificationConfigLister(indexer cache.Indexer) FederatedNotificationConfigLister { + return &federatedNotificationConfigLister{indexer: indexer} +} + +// List lists all FederatedNotificationConfigs in the indexer. +func (s *federatedNotificationConfigLister) List(selector labels.Selector) (ret []*v1beta2.FederatedNotificationConfig, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta2.FederatedNotificationConfig)) + }) + return ret, err +} + +// Get retrieves the FederatedNotificationConfig from the index for a given name. +func (s *federatedNotificationConfigLister) Get(name string) (*v1beta2.FederatedNotificationConfig, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta2.Resource("federatednotificationconfig"), name) + } + return obj.(*v1beta2.FederatedNotificationConfig), nil +} diff --git a/pkg/client/listers/types/v1beta2/federatednotificationmanager.go b/pkg/client/listers/types/v1beta2/federatednotificationmanager.go new file mode 100644 index 000000000..7d5d0960d --- /dev/null +++ b/pkg/client/listers/types/v1beta2/federatednotificationmanager.go @@ -0,0 +1,68 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta2 "kubesphere.io/api/types/v1beta2" +) + +// FederatedNotificationManagerLister helps list FederatedNotificationManagers. +// All objects returned here must be treated as read-only. +type FederatedNotificationManagerLister interface { + // List lists all FederatedNotificationManagers in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta2.FederatedNotificationManager, err error) + // Get retrieves the FederatedNotificationManager from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta2.FederatedNotificationManager, error) + FederatedNotificationManagerListerExpansion +} + +// federatedNotificationManagerLister implements the FederatedNotificationManagerLister interface. +type federatedNotificationManagerLister struct { + indexer cache.Indexer +} + +// NewFederatedNotificationManagerLister returns a new FederatedNotificationManagerLister. +func NewFederatedNotificationManagerLister(indexer cache.Indexer) FederatedNotificationManagerLister { + return &federatedNotificationManagerLister{indexer: indexer} +} + +// List lists all FederatedNotificationManagers in the indexer. +func (s *federatedNotificationManagerLister) List(selector labels.Selector) (ret []*v1beta2.FederatedNotificationManager, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta2.FederatedNotificationManager)) + }) + return ret, err +} + +// Get retrieves the FederatedNotificationManager from the index for a given name. +func (s *federatedNotificationManagerLister) Get(name string) (*v1beta2.FederatedNotificationManager, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta2.Resource("federatednotificationmanager"), name) + } + return obj.(*v1beta2.FederatedNotificationManager), nil +} diff --git a/pkg/client/listers/types/v1beta2/federatednotificationreceiver.go b/pkg/client/listers/types/v1beta2/federatednotificationreceiver.go new file mode 100644 index 000000000..377f2314b --- /dev/null +++ b/pkg/client/listers/types/v1beta2/federatednotificationreceiver.go @@ -0,0 +1,68 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta2 "kubesphere.io/api/types/v1beta2" +) + +// FederatedNotificationReceiverLister helps list FederatedNotificationReceivers. +// All objects returned here must be treated as read-only. +type FederatedNotificationReceiverLister interface { + // List lists all FederatedNotificationReceivers in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta2.FederatedNotificationReceiver, err error) + // Get retrieves the FederatedNotificationReceiver from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta2.FederatedNotificationReceiver, error) + FederatedNotificationReceiverListerExpansion +} + +// federatedNotificationReceiverLister implements the FederatedNotificationReceiverLister interface. +type federatedNotificationReceiverLister struct { + indexer cache.Indexer +} + +// NewFederatedNotificationReceiverLister returns a new FederatedNotificationReceiverLister. +func NewFederatedNotificationReceiverLister(indexer cache.Indexer) FederatedNotificationReceiverLister { + return &federatedNotificationReceiverLister{indexer: indexer} +} + +// List lists all FederatedNotificationReceivers in the indexer. +func (s *federatedNotificationReceiverLister) List(selector labels.Selector) (ret []*v1beta2.FederatedNotificationReceiver, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta2.FederatedNotificationReceiver)) + }) + return ret, err +} + +// Get retrieves the FederatedNotificationReceiver from the index for a given name. +func (s *federatedNotificationReceiverLister) Get(name string) (*v1beta2.FederatedNotificationReceiver, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta2.Resource("federatednotificationreceiver"), name) + } + return obj.(*v1beta2.FederatedNotificationReceiver), nil +} diff --git a/pkg/client/listers/types/v1beta2/federatednotificationrouter.go b/pkg/client/listers/types/v1beta2/federatednotificationrouter.go new file mode 100644 index 000000000..4338e0091 --- /dev/null +++ b/pkg/client/listers/types/v1beta2/federatednotificationrouter.go @@ -0,0 +1,68 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta2 "kubesphere.io/api/types/v1beta2" +) + +// FederatedNotificationRouterLister helps list FederatedNotificationRouters. +// All objects returned here must be treated as read-only. +type FederatedNotificationRouterLister interface { + // List lists all FederatedNotificationRouters in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta2.FederatedNotificationRouter, err error) + // Get retrieves the FederatedNotificationRouter from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta2.FederatedNotificationRouter, error) + FederatedNotificationRouterListerExpansion +} + +// federatedNotificationRouterLister implements the FederatedNotificationRouterLister interface. +type federatedNotificationRouterLister struct { + indexer cache.Indexer +} + +// NewFederatedNotificationRouterLister returns a new FederatedNotificationRouterLister. +func NewFederatedNotificationRouterLister(indexer cache.Indexer) FederatedNotificationRouterLister { + return &federatedNotificationRouterLister{indexer: indexer} +} + +// List lists all FederatedNotificationRouters in the indexer. +func (s *federatedNotificationRouterLister) List(selector labels.Selector) (ret []*v1beta2.FederatedNotificationRouter, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta2.FederatedNotificationRouter)) + }) + return ret, err +} + +// Get retrieves the FederatedNotificationRouter from the index for a given name. +func (s *federatedNotificationRouterLister) Get(name string) (*v1beta2.FederatedNotificationRouter, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta2.Resource("federatednotificationrouter"), name) + } + return obj.(*v1beta2.FederatedNotificationRouter), nil +} diff --git a/pkg/client/listers/types/v1beta2/federatednotificationsilence.go b/pkg/client/listers/types/v1beta2/federatednotificationsilence.go new file mode 100644 index 000000000..1f351e277 --- /dev/null +++ b/pkg/client/listers/types/v1beta2/federatednotificationsilence.go @@ -0,0 +1,68 @@ +/* +Copyright 2020 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta2 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta2 "kubesphere.io/api/types/v1beta2" +) + +// FederatedNotificationSilenceLister helps list FederatedNotificationSilences. +// All objects returned here must be treated as read-only. +type FederatedNotificationSilenceLister interface { + // List lists all FederatedNotificationSilences in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta2.FederatedNotificationSilence, err error) + // Get retrieves the FederatedNotificationSilence from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta2.FederatedNotificationSilence, error) + FederatedNotificationSilenceListerExpansion +} + +// federatedNotificationSilenceLister implements the FederatedNotificationSilenceLister interface. +type federatedNotificationSilenceLister struct { + indexer cache.Indexer +} + +// NewFederatedNotificationSilenceLister returns a new FederatedNotificationSilenceLister. +func NewFederatedNotificationSilenceLister(indexer cache.Indexer) FederatedNotificationSilenceLister { + return &federatedNotificationSilenceLister{indexer: indexer} +} + +// List lists all FederatedNotificationSilences in the indexer. +func (s *federatedNotificationSilenceLister) List(selector labels.Selector) (ret []*v1beta2.FederatedNotificationSilence, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta2.FederatedNotificationSilence)) + }) + return ret, err +} + +// Get retrieves the FederatedNotificationSilence from the index for a given name. +func (s *federatedNotificationSilenceLister) Get(name string) (*v1beta2.FederatedNotificationSilence, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta2.Resource("federatednotificationsilence"), name) + } + return obj.(*v1beta2.FederatedNotificationSilence), nil +} diff --git a/pkg/controller/cluster/cluster_controller.go b/pkg/controller/cluster/cluster_controller.go index cead43158..4b6e3fce2 100644 --- a/pkg/controller/cluster/cluster_controller.go +++ b/pkg/controller/cluster/cluster_controller.go @@ -89,6 +89,10 @@ const ( // mulitcluster configuration name configzMultiCluster = "multicluster" + + NotificationCleanup = "notification.kubesphere.io/cleanup" + notificationAPIFormat = "%s/apis/notification.kubesphere.io/v2beta2/%s/%s" + secretAPIFormat = "%s/api/v1/namespaces/%s/secrets/%s" ) // Cluster template for reconcile host cluster if there is none. @@ -347,6 +351,14 @@ func (c *clusterController) syncCluster(key string) error { klog.Errorf("Failed to sync cluster members for %s: %v", name, err) return err } + + if cluster.Annotations[NotificationCleanup] == "true" { + if err := c.cleanupNotification(cluster); err != nil { + klog.Errorf("Failed to cleanup notification config in cluster %s: %v", name, err) + return err + } + } + // remove our cluster finalizer finalizers := sets.NewString(cluster.ObjectMeta.Finalizers...) finalizers.Delete(clusterv1alpha1.Finalizer) @@ -839,3 +851,110 @@ func (c *clusterController) syncClusterMembers(clusterClient *kubernetes.Clients } return nil } + +func (c *clusterController) cleanupNotification(cluster *clusterv1alpha1.Cluster) error { + + clusterConfig, err := clientcmd.RESTConfigFromKubeConfig(cluster.Spec.Connection.KubeConfig) + if err != nil { + return fmt.Errorf("failed to create cluster config for %s: %s", cluster.Name, err) + } + + proxyTransport, err := rest.TransportFor(clusterConfig) + if err != nil { + return fmt.Errorf("failed to create proxy transport for %s: %s", cluster.Name, err) + } + + client := http.Client{ + Transport: proxyTransport, + Timeout: 5 * time.Second, + } + + doDelete := func(kind, name string) error { + url := fmt.Sprintf(notificationAPIFormat, clusterConfig.Host, kind, name) + req, err := http.NewRequest(http.MethodDelete, url, nil) + if err != nil { + return err + } + + resp, err := client.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("failed to delete notification %s %s in cluster %s, %s", kind, name, cluster.Name, resp.Status) + } + + return nil + } + + if fedConfigs, err := c.ksClient.TypesV1beta2().FederatedNotificationConfigs().List(context.Background(), metav1.ListOptions{}); err != nil { + return err + } else { + for _, fedConfig := range fedConfigs.Items { + if err := doDelete("configs", fedConfig.Name); err != nil { + return err + } + } + } + + if fedReceivers, err := c.ksClient.TypesV1beta2().FederatedNotificationReceivers().List(context.Background(), metav1.ListOptions{}); err != nil { + return err + } else { + for _, fedReceiver := range fedReceivers.Items { + if err := doDelete("receivers", fedReceiver.Name); err != nil { + return err + } + } + } + + if fedRouters, err := c.ksClient.TypesV1beta2().FederatedNotificationRouters().List(context.Background(), metav1.ListOptions{}); err != nil { + return err + } else { + for _, fedRouter := range fedRouters.Items { + if err := doDelete("routers", fedRouter.Name); err != nil { + return err + } + } + } + + if fedSilences, err := c.ksClient.TypesV1beta2().FederatedNotificationSilences().List(context.Background(), metav1.ListOptions{}); err != nil { + return err + } else { + for _, fedSilence := range fedSilences.Items { + if err := doDelete("silences", fedSilence.Name); err != nil { + return err + } + } + } + + selector := metav1.LabelSelector{ + MatchLabels: map[string]string{ + constants.NotificationManagedLabel: "true", + }, + } + if secrets, err := c.k8sClient.CoreV1().Secrets(constants.NotificationSecretNamespace).List(context.Background(), metav1.ListOptions{LabelSelector: metav1.FormatLabelSelector(&selector)}); err != nil { + return err + } else { + for _, secret := range secrets.Items { + url := fmt.Sprintf(secretAPIFormat, clusterConfig.Host, constants.NotificationSecretNamespace, secret.Name) + req, err := http.NewRequest(http.MethodDelete, url, nil) + if err != nil { + return err + } + + resp, err := client.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("failed to delete notification secret %s in cluster %s, %s", secret.Name, cluster.Name, resp.Status) + } + } + } + + return nil +} diff --git a/pkg/controller/notification/notification_controller.go b/pkg/controller/notification/notification_controller.go index 2587362a0..53bd85c88 100644 --- a/pkg/controller/notification/notification_controller.go +++ b/pkg/controller/notification/notification_controller.go @@ -20,7 +20,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "time" corev1 "k8s.io/api/core/v1" @@ -100,11 +99,13 @@ func (c *Controller) setEventHandlers() error { if c.reconciledObjs != nil && len(c.reconciledObjs) > 0 { c.reconciledObjs = c.reconciledObjs[:0] } + c.reconciledObjs = append(c.reconciledObjs, &v2beta2.NotificationManager{}) c.reconciledObjs = append(c.reconciledObjs, &v2beta2.Config{}) c.reconciledObjs = append(c.reconciledObjs, &v2beta2.Receiver{}) c.reconciledObjs = append(c.reconciledObjs, &v2beta2.Router{}) c.reconciledObjs = append(c.reconciledObjs, &v2beta2.Silence{}) c.reconciledObjs = append(c.reconciledObjs, &corev1.Secret{}) + c.reconciledObjs = append(c.reconciledObjs, &corev1.ConfigMap{}) if c.informerSynced != nil && len(c.informerSynced) > 0 { c.informerSynced = c.informerSynced[:0] @@ -224,23 +225,25 @@ func (c *Controller) reconcile(obj interface{}) error { return nil } - // Only reconcile the secret which created by notification manager. - if secret, ok := obj.(*corev1.Secret); ok { - if secret.Namespace != constants.NotificationSecretNamespace || - secret.Labels == nil || secret.Labels[constants.NotificationManagedLabel] != "true" { - klog.V(8).Infof("No need to reconcile secret %s/%s", runtimeObj.GetNamespace(), runtimeObj.GetName()) + // Only reconcile the secret and configmap which created by notification manager. + switch runtimeObj.(type) { + case *corev1.Secret, *corev1.ConfigMap: + if runtimeObj.GetNamespace() != constants.NotificationSecretNamespace || + runtimeObj.GetLabels() == nil || + runtimeObj.GetLabels()[constants.NotificationManagedLabel] != "true" { + klog.V(8).Infof("No need to reconcile %s/%s", runtimeObj.GetNamespace(), runtimeObj.GetName()) return nil } } name := runtimeObj.GetName() - // The notification controller should update the annotations of secrets managed by itself + // The notification controller should update the annotations of secrets and configmaps managed by itself // whenever a cluster is added or deleted. This way, the controller will have a chance to override the secret. if _, ok := obj.(*v1alpha1.Cluster); ok { - err := c.updateSecret() + err := c.updateSecretAndConfigmap() if err != nil { - klog.Errorf("update secret failed, %s", err) + klog.Errorf("update secret and configmap failed, %s", err) return err } @@ -281,360 +284,268 @@ func (c *Controller) multiClusterSync(ctx context.Context, obj client.Object) er return err } + clusterList := &v1alpha1.ClusterList{} + if err := c.ksCache.List(context.Background(), clusterList); err != nil { + return err + } + + var clusters []string + for _, cluster := range clusterList.Items { + if cluster.DeletionTimestamp.IsZero() { + clusters = append(clusters, cluster.Name) + } + } + + var fedObj client.Object + var fn controllerutil.MutateFn switch obj := obj.(type) { + case *v2beta2.NotificationManager: + fedNotificationManager := &v1beta2.FederatedNotificationManager{ + ObjectMeta: metav1.ObjectMeta{ + Name: obj.Name, + }, + } + fn = c.mutateFederatedNotificationManager(fedNotificationManager, obj) + fedObj = fedNotificationManager case *v2beta2.Config: - return c.syncFederatedConfig(obj) + fedConfig := &v1beta2.FederatedNotificationConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: obj.Name, + }, + } + fn = c.mutateFederatedConfig(fedConfig, obj) + fedObj = fedConfig case *v2beta2.Receiver: - return c.syncFederatedReceiver(obj) + fedReceiver := &v1beta2.FederatedNotificationReceiver{ + ObjectMeta: metav1.ObjectMeta{ + Name: obj.Name, + }, + } + fn = c.mutateFederatedReceiver(fedReceiver, obj) + fedObj = fedReceiver case *v2beta2.Router: - return c.syncFederatedRouter(obj) + fedRouter := &v1beta2.FederatedNotificationRouter{ + ObjectMeta: metav1.ObjectMeta{ + Name: obj.Name, + }, + } + fn = c.mutateFederatedRouter(fedRouter, obj) + fedObj = fedRouter case *v2beta2.Silence: - return c.syncFederatedSilence(obj) + fedSilence := &v1beta2.FederatedNotificationSilence{ + ObjectMeta: metav1.ObjectMeta{ + Name: obj.Name, + }, + } + fn = c.mutateFederatedSilence(fedSilence, obj) + fedObj = fedSilence case *corev1.Secret: - return c.syncFederatedSecret(obj) + fedSecret := &v1beta1.FederatedSecret{ + ObjectMeta: metav1.ObjectMeta{ + Name: obj.Name, + Namespace: obj.Namespace, + }, + } + fn = c.mutateFederatedSecret(fedSecret, obj, clusters) + fedObj = fedSecret + case *corev1.ConfigMap: + fedConfigmap := &v1beta1.FederatedConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: obj.Name, + Namespace: obj.Namespace, + }, + } + fn = c.mutateFederatedConfigmap(fedConfigmap, obj, clusters) + fedObj = fedConfigmap default: klog.Errorf("unknown type for notification, %v", obj) return nil } + + res, err := controllerutil.CreateOrUpdate(context.Background(), c.Client, fedObj, fn) + if err != nil { + klog.Errorf("CreateOrUpdate '%s' failed, %s", fedObj.GetName(), err) + } else { + klog.Infof("'%s' %s", fedObj.GetName(), res) + } + + return err } -func (c *Controller) syncFederatedConfig(obj *v2beta2.Config) error { +func (c *Controller) mutateFederatedNotificationManager(fedObj *v1beta2.FederatedNotificationManager, obj *v2beta2.NotificationManager) controllerutil.MutateFn { - fedObj := &v1beta2.FederatedNotificationConfig{} - err := c.Get(context.Background(), client.ObjectKey{Name: obj.Name}, fedObj) - if err != nil { - if errors.IsNotFound(err) { - fedObj = &v1beta2.FederatedNotificationConfig{ - TypeMeta: metav1.TypeMeta{ - Kind: v1beta2.FederatedNotificationConfigKind, - APIVersion: v1beta2.SchemeGroupVersion.String(), - }, + return func() error { + fedObj.Spec = v1beta2.FederatedNotificationManagerSpec{ + Template: v1beta2.NotificationManagerTemplate{ ObjectMeta: metav1.ObjectMeta{ - Name: obj.Name, - }, - Spec: v1beta2.FederatedNotificationConfigSpec{ - Template: v1beta2.NotificationConfigTemplate{ - ObjectMeta: metav1.ObjectMeta{ - Labels: obj.Labels, - }, - Spec: obj.Spec, - }, - Placement: v1beta2.GenericPlacementFields{ - ClusterSelector: &metav1.LabelSelector{}, - }, - }, - } - - err = controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) - if err != nil { - klog.Errorf("FederatedNotificationConfig '%s' SetControllerReference failed, %s", obj.Name, err) - return err - } - - if err = c.Create(context.Background(), fedObj); err != nil { - klog.Errorf("create FederatedNotificationConfig '%s' failed, %s", obj.Name, err) - return err - } - - return nil - } - klog.Errorf("get FederatedNotificationConfig '%s' failed, %s", obj.Name, err) - return err - } - - if !reflect.DeepEqual(fedObj.Spec.Template.Labels, obj.Labels) || !reflect.DeepEqual(fedObj.Spec.Template.Spec, obj.Spec) { - - fedObj.Spec.Template.Spec = obj.Spec - fedObj.Spec.Template.Labels = obj.Labels - - if err := c.Update(context.Background(), fedObj); err != nil { - klog.Errorf("update FederatedNotificationConfig '%s' failed, %s", obj.Name, err) - return err - } - } - - return nil -} - -func (c *Controller) syncFederatedReceiver(obj *v2beta2.Receiver) error { - - fedObj := &v1beta2.FederatedNotificationReceiver{} - err := c.Get(context.Background(), client.ObjectKey{Name: obj.Name}, fedObj) - if err != nil { - if errors.IsNotFound(err) { - fedObj = &v1beta2.FederatedNotificationReceiver{ - TypeMeta: metav1.TypeMeta{ - Kind: v1beta2.FederatedNotificationReceiverKind, - APIVersion: v1beta2.SchemeGroupVersion.String(), - }, - ObjectMeta: metav1.ObjectMeta{ - Name: obj.Name, - }, - Spec: v1beta2.FederatedNotificationReceiverSpec{ - Template: v1beta2.NotificationReceiverTemplate{ - ObjectMeta: metav1.ObjectMeta{ - Labels: obj.Labels, - }, - Spec: obj.Spec, - }, - Placement: v1beta2.GenericPlacementFields{ - ClusterSelector: &metav1.LabelSelector{}, - }, - }, - } - - err = controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) - if err != nil { - klog.Errorf("FederatedNotificationReceiver '%s' SetControllerReference failed, %s", obj.Name, err) - return err - } - - if err = c.Create(context.Background(), fedObj); err != nil { - klog.Errorf("create FederatedNotificationReceiver '%s' failed, %s", obj.Name, err) - return err - } - - return nil - } - klog.Errorf("get FederatedNotificationReceiver '%s' failed, %s", obj.Name, err) - return err - } - - if !reflect.DeepEqual(fedObj.Spec.Template.Labels, obj.Labels) || !reflect.DeepEqual(fedObj.Spec.Template.Spec, obj.Spec) { - - fedObj.Spec.Template.Spec = obj.Spec - fedObj.Spec.Template.Labels = obj.Labels - - if err := c.Update(context.Background(), fedObj); err != nil { - klog.Errorf("update FederatedNotificationReceiver '%s' failed, %s", obj.Name, err) - return err - } - } - - return nil -} - -func (c *Controller) syncFederatedRouter(obj *v2beta2.Router) error { - - fedObj := &v1beta2.FederatedNotificationRouter{} - err := c.Get(context.Background(), client.ObjectKey{Name: obj.Name}, fedObj) - if err != nil { - if errors.IsNotFound(err) { - fedObj = &v1beta2.FederatedNotificationRouter{ - TypeMeta: metav1.TypeMeta{ - Kind: v1beta2.FederatedNotificationReceiverKind, - APIVersion: v1beta2.SchemeGroupVersion.String(), - }, - ObjectMeta: metav1.ObjectMeta{ - Name: obj.Name, - }, - Spec: v1beta2.FederatedNotificationRouterSpec{ - Template: v1beta2.NotificationRouterTemplate{ - ObjectMeta: metav1.ObjectMeta{ - Labels: obj.Labels, - }, - Spec: obj.Spec, - }, - Placement: v1beta2.GenericPlacementFields{ - ClusterSelector: &metav1.LabelSelector{}, - }, - }, - } - - err = controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) - if err != nil { - klog.Errorf("FederatedNotificationRouter '%s' SetControllerReference failed, %s", obj.Name, err) - return err - } - - if err = c.Create(context.Background(), fedObj); err != nil { - klog.Errorf("create FederatedNotificationRouter '%s' failed, %s", obj.Name, err) - return err - } - - return nil - } - klog.Errorf("get FederatedNotificationRouter '%s' failed, %s", obj.Name, err) - return err - } - - if !reflect.DeepEqual(fedObj.Spec.Template.Labels, obj.Labels) || !reflect.DeepEqual(fedObj.Spec.Template.Spec, obj.Spec) { - - fedObj.Spec.Template.Spec = obj.Spec - fedObj.Spec.Template.Labels = obj.Labels - - if err := c.Update(context.Background(), fedObj); err != nil { - klog.Errorf("update FederatedNotificationRouter '%s' failed, %s", obj.Name, err) - return err - } - } - - return nil -} - -func (c *Controller) syncFederatedSilence(obj *v2beta2.Silence) error { - - fedObj := &v1beta2.FederatedNotificationSilence{} - err := c.Get(context.Background(), client.ObjectKey{Name: obj.Name}, fedObj) - if err != nil { - if errors.IsNotFound(err) { - fedObj = &v1beta2.FederatedNotificationSilence{ - TypeMeta: metav1.TypeMeta{ - Kind: v1beta2.FederatedNotificationReceiverKind, - APIVersion: v1beta2.SchemeGroupVersion.String(), - }, - ObjectMeta: metav1.ObjectMeta{ - Name: obj.Name, - }, - Spec: v1beta2.FederatedNotificationSilenceSpec{ - Template: v1beta2.NotificationSilenceTemplate{ - ObjectMeta: metav1.ObjectMeta{ - Labels: obj.Labels, - }, - Spec: obj.Spec, - }, - Placement: v1beta2.GenericPlacementFields{ - ClusterSelector: &metav1.LabelSelector{}, - }, - }, - } - - err = controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) - if err != nil { - klog.Errorf("FederatedNotificationSilence '%s' SetControllerReference failed, %s", obj.Name, err) - return err - } - - if err = c.Create(context.Background(), fedObj); err != nil { - klog.Errorf("create FederatedNotificationSilence '%s' failed, %s", obj.Name, err) - return err - } - - return nil - } - klog.Errorf("get FederatedNotificationSilence '%s' failed, %s", obj.Name, err) - return err - } - - if !reflect.DeepEqual(fedObj.Spec.Template.Labels, obj.Labels) || !reflect.DeepEqual(fedObj.Spec.Template.Spec, obj.Spec) { - - fedObj.Spec.Template.Spec = obj.Spec - fedObj.Spec.Template.Labels = obj.Labels - - if err := c.Update(context.Background(), fedObj); err != nil { - klog.Errorf("update FederatedNotificationSilence '%s' failed, %s", obj.Name, err) - return err - } - } - - return nil -} - -func (c *Controller) syncFederatedSecret(obj *corev1.Secret) error { - - fedObj := &v1beta1.FederatedSecret{} - err := c.Get(context.Background(), client.ObjectKey{Name: obj.Name, Namespace: obj.Namespace}, fedObj) - if err != nil { - if errors.IsNotFound(err) { - fedObj = &v1beta1.FederatedSecret{ - TypeMeta: metav1.TypeMeta{ - Kind: v1beta1.FederatedSecretKind, - APIVersion: v1beta1.SchemeGroupVersion.String(), - }, - ObjectMeta: metav1.ObjectMeta{ - Name: obj.Name, - Namespace: obj.Namespace, - }, - Spec: v1beta1.FederatedSecretSpec{ - Template: v1beta1.SecretTemplate{ - Data: obj.Data, - StringData: obj.StringData, - Type: obj.Type, - }, - Placement: v1beta1.GenericPlacementFields{ - ClusterSelector: &metav1.LabelSelector{}, - }, - }, - } - - err = c.updateOverrides(obj, fedObj) - if err != nil { - klog.Errorf("update FederatedSecret '%s' overrides failed, %s", obj.Name, err) - return err - } - - err = controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) - if err != nil { - klog.Errorf("FederatedSecret '%s' SetControllerReference failed, %s", obj.Name, err) - return err - } - - if err = c.Create(context.Background(), fedObj); err != nil { - klog.Errorf("create FederatedSecret '%s' failed, %s", obj.Name, err) - return err - } - - return nil - } - klog.Errorf("get FederatedSecret '%s' failed, %s", obj.Name, err) - return err - } - - if !reflect.DeepEqual(fedObj.Spec.Template.Data, obj.Data) || - !reflect.DeepEqual(fedObj.Spec.Template.StringData, obj.StringData) || - !reflect.DeepEqual(fedObj.Spec.Template.Type, obj.Type) { - - fedObj.Spec.Template.Data = obj.Data - fedObj.Spec.Template.StringData = obj.StringData - fedObj.Spec.Template.Type = obj.Type - } - - err = c.updateOverrides(obj, fedObj) - if err != nil { - klog.Errorf("update FederatedSecret '%s' overrides failed, %s", obj.Name, err) - return err - } - - if err := c.Update(context.Background(), fedObj); err != nil { - klog.Errorf("update FederatedSecret '%s' failed, %s", obj.Name, err) - return err - } - - return nil -} - -func (c *Controller) updateOverrides(obj *corev1.Secret, fedSecret *v1beta1.FederatedSecret) error { - clusterList := &v1alpha1.ClusterList{} - err := c.ksCache.List(context.Background(), clusterList) - if err != nil { - return err - } - - bs, err := json.Marshal(obj.Labels) - if err != nil { - return err - } - - fedSecret.Spec.Overrides = fedSecret.Spec.Overrides[:0] - for _, cluster := range clusterList.Items { - fedSecret.Spec.Overrides = append(fedSecret.Spec.Overrides, v1beta1.GenericOverrideItem{ - ClusterName: cluster.Name, - ClusterOverrides: []v1beta1.ClusterOverride{ - { - Path: "/metadata/labels", - Value: runtime.RawExtension{ - Raw: bs, - }, + Labels: obj.Labels, }, + Spec: obj.Spec, }, - }) - } + Placement: v1beta2.GenericPlacementFields{ + ClusterSelector: &metav1.LabelSelector{}, + }, + } - return nil + return controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) + } +} + +func (c *Controller) mutateFederatedConfig(fedObj *v1beta2.FederatedNotificationConfig, obj *v2beta2.Config) controllerutil.MutateFn { + + return func() error { + fedObj.Spec = v1beta2.FederatedNotificationConfigSpec{ + Template: v1beta2.NotificationConfigTemplate{ + ObjectMeta: metav1.ObjectMeta{ + Labels: obj.Labels, + }, + Spec: obj.Spec, + }, + Placement: v1beta2.GenericPlacementFields{ + ClusterSelector: &metav1.LabelSelector{}, + }, + } + + return controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) + } +} + +func (c *Controller) mutateFederatedReceiver(fedObj *v1beta2.FederatedNotificationReceiver, obj *v2beta2.Receiver) controllerutil.MutateFn { + + return func() error { + fedObj.Spec = v1beta2.FederatedNotificationReceiverSpec{ + Template: v1beta2.NotificationReceiverTemplate{ + ObjectMeta: metav1.ObjectMeta{ + Labels: obj.Labels, + }, + Spec: obj.Spec, + }, + Placement: v1beta2.GenericPlacementFields{ + ClusterSelector: &metav1.LabelSelector{}, + }, + } + + return controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) + } +} + +func (c *Controller) mutateFederatedRouter(fedObj *v1beta2.FederatedNotificationRouter, obj *v2beta2.Router) controllerutil.MutateFn { + + return func() error { + fedObj.Spec = v1beta2.FederatedNotificationRouterSpec{ + Template: v1beta2.NotificationRouterTemplate{ + ObjectMeta: metav1.ObjectMeta{ + Labels: obj.Labels, + }, + Spec: obj.Spec, + }, + Placement: v1beta2.GenericPlacementFields{ + ClusterSelector: &metav1.LabelSelector{}, + }, + } + + return controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) + } +} + +func (c *Controller) mutateFederatedSilence(fedObj *v1beta2.FederatedNotificationSilence, obj *v2beta2.Silence) controllerutil.MutateFn { + + return func() error { + fedObj.Spec = v1beta2.FederatedNotificationSilenceSpec{ + Template: v1beta2.NotificationSilenceTemplate{ + ObjectMeta: metav1.ObjectMeta{ + Labels: obj.Labels, + }, + Spec: obj.Spec, + }, + Placement: v1beta2.GenericPlacementFields{ + ClusterSelector: &metav1.LabelSelector{}, + }, + } + + return controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) + } +} + +func (c *Controller) mutateFederatedSecret(fedObj *v1beta1.FederatedSecret, obj *corev1.Secret, clusters []string) controllerutil.MutateFn { + + return func() error { + + fedObj.Spec = v1beta1.FederatedSecretSpec{ + Template: v1beta1.SecretTemplate{ + Data: obj.Data, + StringData: obj.StringData, + Type: obj.Type, + }, + Placement: v1beta1.GenericPlacementFields{ + ClusterSelector: &metav1.LabelSelector{}, + }, + } + + bs, err := json.Marshal(obj.Labels) + if err != nil { + return err + } + + fedObj.Spec.Overrides = fedObj.Spec.Overrides[:0] + for _, cluster := range clusters { + fedObj.Spec.Overrides = append(fedObj.Spec.Overrides, v1beta1.GenericOverrideItem{ + ClusterName: cluster, + ClusterOverrides: []v1beta1.ClusterOverride{ + { + Path: "/metadata/labels", + Value: runtime.RawExtension{ + Raw: bs, + }, + }, + }, + }) + } + + return controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) + } +} + +func (c *Controller) mutateFederatedConfigmap(fedObj *v1beta1.FederatedConfigMap, obj *corev1.ConfigMap, clusters []string) controllerutil.MutateFn { + + return func() error { + + fedObj.Spec = v1beta1.FederatedConfigMapSpec{ + Template: v1beta1.ConfigMapTemplate{ + Data: obj.Data, + BinaryData: obj.BinaryData, + }, + Placement: v1beta1.GenericPlacementFields{ + ClusterSelector: &metav1.LabelSelector{}, + }, + } + + bs, err := json.Marshal(obj.Labels) + if err != nil { + return err + } + + fedObj.Spec.Overrides = fedObj.Spec.Overrides[:0] + for _, cluster := range clusters { + fedObj.Spec.Overrides = append(fedObj.Spec.Overrides, v1beta1.GenericOverrideItem{ + ClusterName: cluster, + ClusterOverrides: []v1beta1.ClusterOverride{ + { + Path: "/metadata/labels", + Value: runtime.RawExtension{ + Raw: bs, + }, + }, + }, + }) + } + + return controllerutil.SetControllerReference(obj, fedObj, scheme.Scheme) + } } // Update the annotations of secrets managed by the notification controller to trigger a reconcile. -func (c *Controller) updateSecret() error { +func (c *Controller) updateSecretAndConfigmap() error { secretList := &corev1.SecretList{} err := c.ksCache.List(context.Background(), secretList, @@ -657,6 +568,27 @@ func (c *Controller) updateSecret() error { } } + configmapList := &corev1.ConfigMapList{} + err = c.ksCache.List(context.Background(), configmapList, + client.InNamespace(constants.NotificationSecretNamespace), + client.MatchingLabels{ + constants.NotificationManagedLabel: "true", + }) + if err != nil { + return err + } + + for _, configmap := range configmapList.Items { + if configmap.Annotations == nil { + configmap.Annotations = make(map[string]string) + } + + configmap.Annotations["reloadtimestamp"] = time.Now().String() + if err := c.Update(context.Background(), &configmap); err != nil { + return err + } + } + return nil } diff --git a/pkg/kapis/notification/v2beta2/register.go b/pkg/kapis/notification/v2beta2/register.go index 99524842c..527148276 100644 --- a/pkg/kapis/notification/v2beta2/register.go +++ b/pkg/kapis/notification/v2beta2/register.go @@ -67,9 +67,9 @@ func AddToContainer( // apis for global notification config, receiver, and secret ws.Route(ws.GET("/{resources}"). To(h.ListResource). - Doc("list the notification configs or receivers"). + Doc("list the notification resources"). Metadata(KeyOpenAPITags, []string{constants.NotificationTag}). - Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences")). + Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences, configmaps")). Param(ws.QueryParameter(query.ParameterName, "name used for filtering").Required(false)). Param(ws.QueryParameter(query.ParameterLabelSelector, "label selector used for filtering").Required(false)). Param(ws.QueryParameter("type", "config or receiver type, known values include dingtalk, email, feishu, slack, webhook, wechat").Required(false)). @@ -81,43 +81,43 @@ func AddToContainer( ws.Route(ws.GET("/{resources}/{name}"). To(h.GetResource). - Doc("get the specified notification config or receiver"). + Doc("get the specified notification resources"). Metadata(KeyOpenAPITags, []string{constants.NotificationTag}). - Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences")). + Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences, configmaps")). Param(ws.PathParameter(query.ParameterName, "the name of the resource")). Param(ws.QueryParameter("type", "config or receiver type, known values include dingtalk, feishu, email, slack, webhook, wechat").Required(false)). Returns(http.StatusOK, api.StatusOK, nil)) ws.Route(ws.POST("/{resources}"). To(h.CreateResource). - Doc("create a notification config or receiver"). + Doc("create a notification resources"). Metadata(KeyOpenAPITags, []string{constants.NotificationTag}). - Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences")). + Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences, configmaps")). Returns(http.StatusOK, api.StatusOK, nil)) ws.Route(ws.PUT("/{resources}/{name}"). To(h.UpdateResource). - Doc("update the specified notification config or receiver"). + Doc("update the specified notification resources"). Metadata(KeyOpenAPITags, []string{constants.NotificationTag}). - Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences")). + Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences, configmaps")). Param(ws.PathParameter(query.ParameterName, "the name of the resource")). Returns(http.StatusOK, api.StatusOK, nil)) ws.Route(ws.DELETE("/{resources}/{name}"). To(h.DeleteResource). - Doc("delete the specified notification config or receiver"). + Doc("delete the specified notification resources"). Metadata(KeyOpenAPITags, []string{constants.NotificationTag}). - Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences")). + Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences, configmaps")). Param(ws.PathParameter(query.ParameterName, "the name of the resource")). Returns(http.StatusOK, api.StatusOK, errors.None)) // apis for tenant notification config and receiver ws.Route(ws.GET("/users/{user}/{resources}"). To(h.ListResource). - Doc("list the notification configs or receivers"). + Doc("list the notification resources"). Metadata(KeyOpenAPITags, []string{constants.NotificationTag}). Param(ws.PathParameter("user", "user name")). - Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences")). + Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences, configmaps")). Param(ws.QueryParameter(query.ParameterName, "name used for filtering").Required(false)). Param(ws.QueryParameter(query.ParameterLabelSelector, "label selector used for filtering").Required(false)). Param(ws.QueryParameter("type", "config or receiver type, known values include dingtalk, email, feishu, slack, webhook, wechat").Required(false)). @@ -129,37 +129,37 @@ func AddToContainer( ws.Route(ws.GET("/users/{user}/{resources}/{name}"). To(h.GetResource). - Doc("get the specified notification config or receiver"). + Doc("get the specified notification resources"). Metadata(KeyOpenAPITags, []string{constants.NotificationTag}). Param(ws.PathParameter("user", "user name")). - Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences")). + Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences, configmaps")). Param(ws.PathParameter(query.ParameterName, "the name of the resource")). Param(ws.QueryParameter("type", "config or receiver type, known values include dingtalk, email, feishu, slack, webhook, wechat").Required(false)). Returns(http.StatusOK, api.StatusOK, nil)) ws.Route(ws.POST("/users/{user}/{resources}"). To(h.CreateResource). - Doc("create the specified notification config or receiver"). + Doc("create the specified notification resources"). Metadata(KeyOpenAPITags, []string{constants.NotificationTag}). Param(ws.PathParameter("user", "user name")). - Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences")). + Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences, configmaps")). Returns(http.StatusOK, api.StatusOK, nil)) ws.Route(ws.PUT("/users/{user}/{resources}/{name}"). To(h.UpdateResource). - Doc("update the specified notification config or receiver"). + Doc("update the specified notification resources"). Metadata(KeyOpenAPITags, []string{constants.NotificationTag}). Param(ws.PathParameter("user", "user name")). - Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences")). + Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences, configmaps")). Param(ws.PathParameter(query.ParameterName, "the name of the resource")). Returns(http.StatusOK, api.StatusOK, nil)) ws.Route(ws.DELETE("/users/{user}/{resources}/{name}"). To(h.DeleteResource). - Doc("delete the specified notification config or receiver"). + Doc("delete the specified notification resources"). Metadata(KeyOpenAPITags, []string{constants.NotificationTag}). Param(ws.PathParameter("user", "user name")). - Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences")). + Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences, configmaps")). Param(ws.PathParameter(query.ParameterName, "the name of the resource")). Returns(http.StatusOK, api.StatusOK, errors.None)) diff --git a/pkg/models/notification/notification.go b/pkg/models/notification/notification.go index 5683f21a0..d830b2d97 100644 --- a/pkg/models/notification/notification.go +++ b/pkg/models/notification/notification.go @@ -47,6 +47,7 @@ import ( const ( Secret = "secrets" + ConfigMap = "configmaps" VerificationAPIPath = "/api/v2/verify" V2beta1 = "v2beta1" @@ -144,7 +145,7 @@ func (o *operator) list(user, resource, version, subresource string, q *query.Qu q.LabelSelector = q.LabelSelector + filter ns := "" - if resource == Secret { + if resource == Secret || resource == ConfigMap { ns = constants.NotificationSecretNamespace } @@ -193,7 +194,7 @@ func (o *operator) get(user, resource, version, name, subresource string) (runti } ns := "" - if resource == Secret { + if resource == Secret || resource == ConfigMap { ns = constants.NotificationSecretNamespace } @@ -208,7 +209,7 @@ func (o *operator) get(user, resource, version, name, subresource string) (runti return nil, err } - if subresource == "" || resource == Secret { + if subresource == "" || resource == Secret || resource == ConfigMap { return obj, nil } @@ -264,8 +265,10 @@ func (o *operator) create(user, resource, version string, obj runtime.Object) (r return o.ksClient.NotificationV2beta2().Routers().Create(context.Background(), obj.(*v2beta2.Router), v1.CreateOptions{}) case v2beta2.ResourcesPluralSilence: return o.ksClient.NotificationV2beta2().Silences().Create(context.Background(), obj.(*v2beta2.Silence), v1.CreateOptions{}) - case "secrets": + case Secret: return o.k8sClient.CoreV1().Secrets(constants.NotificationSecretNamespace).Create(context.Background(), obj.(*corev1.Secret), v1.CreateOptions{}) + case ConfigMap: + return o.k8sClient.CoreV1().ConfigMaps(constants.NotificationSecretNamespace).Create(context.Background(), obj.(*corev1.ConfigMap), v1.CreateOptions{}) default: return nil, errors.NewInternalError(nil) } @@ -309,8 +312,10 @@ func (o *operator) delete(user, resource, name string) error { return o.ksClient.NotificationV2beta2().Routers().Delete(context.Background(), name, v1.DeleteOptions{}) case v2beta2.ResourcesPluralSilence: return o.ksClient.NotificationV2beta2().Silences().Delete(context.Background(), name, v1.DeleteOptions{}) - case "secrets": + case Secret: return o.k8sClient.CoreV1().Secrets(constants.NotificationSecretNamespace).Delete(context.Background(), name, v1.DeleteOptions{}) + case ConfigMap: + return o.k8sClient.CoreV1().ConfigMaps(constants.NotificationSecretNamespace).Delete(context.Background(), name, v1.DeleteOptions{}) default: return errors.NewInternalError(nil) } @@ -366,8 +371,10 @@ func (o *operator) update(user, resource, version, name string, obj runtime.Obje return o.ksClient.NotificationV2beta2().Routers().Update(context.Background(), obj.(*v2beta2.Router), v1.UpdateOptions{}) case v2beta2.ResourcesPluralSilence: return o.ksClient.NotificationV2beta2().Silences().Update(context.Background(), obj.(*v2beta2.Silence), v1.UpdateOptions{}) - case "secrets": + case Secret: return o.k8sClient.CoreV1().Secrets(constants.NotificationSecretNamespace).Update(context.Background(), obj.(*corev1.Secret), v1.UpdateOptions{}) + case ConfigMap: + return o.k8sClient.CoreV1().ConfigMaps(constants.NotificationSecretNamespace).Update(context.Background(), obj.(*corev1.ConfigMap), v1.UpdateOptions{}) default: return nil, errors.NewInternalError(nil) } @@ -400,6 +407,8 @@ func (o *operator) GetObject(resource, version string) runtime.Object { return &v2beta2.Silence{} case Secret: return &corev1.Secret{} + case ConfigMap: + return &corev1.ConfigMap{} default: return nil } @@ -559,7 +568,7 @@ func appendLabel(user, resource string, obj runtime.Object) error { labels = make(map[string]string) } - if resource == Secret { + if resource == Secret || resource == ConfigMap { labels[constants.NotificationManagedLabel] = "true" } diff --git a/staging/src/kubesphere.io/api/notification/v2beta2/notificationmanager_types.go b/staging/src/kubesphere.io/api/notification/v2beta2/notificationmanager_types.go index 61de7b08c..a2317edcc 100644 --- a/staging/src/kubesphere.io/api/notification/v2beta2/notificationmanager_types.go +++ b/staging/src/kubesphere.io/api/notification/v2beta2/notificationmanager_types.go @@ -313,10 +313,10 @@ type Options struct { type NotificationManagerStatus struct { } -// +kubebuilder:object:root=true -// +kubebuilder:resource:scope=Cluster,shortName=nm,categories=notification-manager -// +kubebuilder:subresource:status -// +kubebuilder:storageversion +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true // NotificationManager is the Schema for the notificationmanagers API type NotificationManager struct { @@ -327,7 +327,8 @@ type NotificationManager struct { Status NotificationManagerStatus `json:"status,omitempty"` } -// +kubebuilder:object:root=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true // NotificationManagerList contains a list of NotificationManager type NotificationManagerList struct { diff --git a/staging/src/kubesphere.io/api/notification/v2beta2/types.go b/staging/src/kubesphere.io/api/notification/v2beta2/types.go index 2f929381d..809f52530 100644 --- a/staging/src/kubesphere.io/api/notification/v2beta2/types.go +++ b/staging/src/kubesphere.io/api/notification/v2beta2/types.go @@ -17,6 +17,10 @@ limitations under the License. package v2beta2 const ( + ResourceKindNotificationManager = "NotificationManagers" + ResourcesSingularNotificationManager = "notificationmanager" + ResourcesPluralNotificationManager = "notificationmanagers" + ResourceKindConfig = "Configs" ResourcesSingularConfig = "config" ResourcesPluralConfig = "configs" diff --git a/staging/src/kubesphere.io/api/types/v1beta2/doc.go b/staging/src/kubesphere.io/api/types/v1beta2/doc.go new file mode 100644 index 000000000..d2bba2abd --- /dev/null +++ b/staging/src/kubesphere.io/api/types/v1beta2/doc.go @@ -0,0 +1,22 @@ +/* +Copyright 2019 The KubeSphere Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:conversion-gen=kubesphere.io/api/types +// +k8s:defaulter-gen=TypeMeta +// +groupName=types.kubefed.io +package v1beta2 diff --git a/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationconfig_types.go b/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationconfig_types.go index e4a539151..38812f7cf 100644 --- a/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationconfig_types.go +++ b/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationconfig_types.go @@ -30,13 +30,13 @@ const ( FederatedNotificationConfigKind = "FederatedNotificationConfig" ) +// +genclient // +genclient:nonNamespaced -// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true // +kubebuilder:resource:scope=Cluster // +kubebuilder:subresource:status -// +kubebuilder:storageversion + type FederatedNotificationConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -57,8 +57,8 @@ type NotificationConfigTemplate struct { Spec v2beta2.ConfigSpec `json:"spec,omitempty"` } -// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true // FederatedNotificationConfigList contains a list of federatednotificationconfiglists type FederatedNotificationConfigList struct { diff --git a/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationmanager_types.go b/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationmanager_types.go new file mode 100644 index 000000000..56fea07bd --- /dev/null +++ b/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationmanager_types.go @@ -0,0 +1,65 @@ +/* +Copyright 2020 KubeSphere Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "kubesphere.io/api/notification/v2beta2" +) + +const ( + ResourcePluralFederatedNotificationManager = "federatednotificationmanagers" + ResourceSingularFederatedNotificationManager = "federatednotificationmanager" + FederatedNotificationManagerKind = "FederatedNotificationManager" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true +// +kubebuilder:resource:scope=Cluster +// +kubebuilder:subresource:status + +type FederatedNotificationManager struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec FederatedNotificationManagerSpec `json:"spec"` + + Status *GenericFederatedStatus `json:"status,omitempty"` +} + +type FederatedNotificationManagerSpec struct { + Template NotificationManagerTemplate `json:"template"` + Placement GenericPlacementFields `json:"placement"` + Overrides []GenericOverrideItem `json:"overrides,omitempty"` +} + +type NotificationManagerTemplate struct { + // +kubebuilder:pruning:PreserveUnknownFields + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec v2beta2.NotificationManagerSpec `json:"spec,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true + +// FederatedNotificationManagerList contains a list of federatednotificationmanagerlists +type FederatedNotificationManagerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []FederatedNotificationManager `json:"items"` +} diff --git a/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationreceiver_types.go b/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationreceiver_types.go index 935a39b30..d978846ee 100644 --- a/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationreceiver_types.go +++ b/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationreceiver_types.go @@ -30,12 +30,13 @@ const ( FederatedNotificationReceiverKind = "FederatedNotificationReceiver" ) +// +genclient // +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true // +kubebuilder:resource:scope=Cluster // +kubebuilder:subresource:status -// +kubebuilder:storageversion + type FederatedNotificationReceiver struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -56,8 +57,8 @@ type NotificationReceiverTemplate struct { Spec v2beta2.ReceiverSpec `json:"spec,omitempty"` } -// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true // FederatedNotificationReceiverList contains a list of federatednotificationreceiverlists type FederatedNotificationReceiverList struct { diff --git a/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationrouter_types.go b/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationrouter_types.go index eb37f457f..9124658c5 100644 --- a/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationrouter_types.go +++ b/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationrouter_types.go @@ -27,12 +27,13 @@ const ( FederatedNotificationRouterKind = "FederatedNotificationRouter" ) +// +genclient // +genclient:nonNamespaced -// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true // +kubebuilder:resource:scope=Cluster // +kubebuilder:subresource:status + type FederatedNotificationRouter struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -53,8 +54,8 @@ type NotificationRouterTemplate struct { Spec v2beta2.RouterSpec `json:"spec,omitempty"` } -// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true // FederatedNotificationRouterList contains a list of federatednotificationrouterlists type FederatedNotificationRouterList struct { diff --git a/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationsilence_types.go b/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationsilence_types.go index ffc79899a..161b2d9f3 100644 --- a/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationsilence_types.go +++ b/staging/src/kubesphere.io/api/types/v1beta2/federatednotificationsilence_types.go @@ -27,12 +27,13 @@ const ( FederatedNotificationSilenceKind = "FederatedNotificationSilence" ) +// +genclient // +genclient:nonNamespaced -// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true // +kubebuilder:resource:scope=Cluster // +kubebuilder:subresource:status + type FederatedNotificationSilence struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -53,8 +54,8 @@ type NotificationSilenceTemplate struct { Spec v2beta2.SilenceSpec `json:"spec,omitempty"` } -// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true // FederatedNotificationSilenceList contains a list of federatednotificationsilencelists type FederatedNotificationSilenceList struct { diff --git a/staging/src/kubesphere.io/api/types/v1beta2/register.go b/staging/src/kubesphere.io/api/types/v1beta2/register.go index 932822179..9546333a1 100644 --- a/staging/src/kubesphere.io/api/types/v1beta2/register.go +++ b/staging/src/kubesphere.io/api/types/v1beta2/register.go @@ -45,6 +45,8 @@ func Resource(resource string) schema.GroupResource { func init() { SchemeBuilder.Register( + &FederatedNotificationManager{}, + &FederatedNotificationManagerList{}, &FederatedNotificationConfig{}, &FederatedNotificationConfigList{}, &FederatedNotificationReceiver{}, diff --git a/staging/src/kubesphere.io/api/types/v1beta2/zz_generated.deepcopy.go b/staging/src/kubesphere.io/api/types/v1beta2/zz_generated.deepcopy.go index b87fb11b5..36c653698 100644 --- a/staging/src/kubesphere.io/api/types/v1beta2/zz_generated.deepcopy.go +++ b/staging/src/kubesphere.io/api/types/v1beta2/zz_generated.deepcopy.go @@ -129,6 +129,93 @@ func (in *FederatedNotificationConfigSpec) DeepCopy() *FederatedNotificationConf return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FederatedNotificationManager) DeepCopyInto(out *FederatedNotificationManager) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(GenericFederatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationManager. +func (in *FederatedNotificationManager) DeepCopy() *FederatedNotificationManager { + if in == nil { + return nil + } + out := new(FederatedNotificationManager) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FederatedNotificationManager) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FederatedNotificationManagerList) DeepCopyInto(out *FederatedNotificationManagerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]FederatedNotificationManager, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationManagerList. +func (in *FederatedNotificationManagerList) DeepCopy() *FederatedNotificationManagerList { + if in == nil { + return nil + } + out := new(FederatedNotificationManagerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FederatedNotificationManagerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FederatedNotificationManagerSpec) DeepCopyInto(out *FederatedNotificationManagerSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) + in.Placement.DeepCopyInto(&out.Placement) + if in.Overrides != nil { + in, out := &in.Overrides, &out.Overrides + *out = make([]GenericOverrideItem, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationManagerSpec. +func (in *FederatedNotificationManagerSpec) DeepCopy() *FederatedNotificationManagerSpec { + if in == nil { + return nil + } + out := new(FederatedNotificationManagerSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FederatedNotificationReceiver) DeepCopyInto(out *FederatedNotificationReceiver) { *out = *in @@ -630,6 +717,23 @@ func (in *NotificationConfigTemplate) DeepCopy() *NotificationConfigTemplate { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NotificationManagerTemplate) DeepCopyInto(out *NotificationManagerTemplate) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotificationManagerTemplate. +func (in *NotificationManagerTemplate) DeepCopy() *NotificationManagerTemplate { + if in == nil { + return nil + } + out := new(NotificationManagerTemplate) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NotificationReceiverTemplate) DeepCopyInto(out *NotificationReceiverTemplate) { *out = *in