update notification manager to v2.0 (#5030)

Signed-off-by: wanjunlei <wanjunlei@kubesphere.io>
This commit is contained in:
wanjunlei
2022-07-05 16:04:33 +08:00
committed by GitHub
parent 8e00ba29ca
commit 5cead172cd
87 changed files with 7877 additions and 253 deletions

View File

@@ -41,6 +41,7 @@ import (
clusterv1alpha1 "kubesphere.io/api/cluster/v1alpha1"
iamv1alpha2 "kubesphere.io/api/iam/v1alpha2"
notificationv2beta1 "kubesphere.io/api/notification/v2beta1"
notificationv2beta2 "kubesphere.io/api/notification/v2beta2"
tenantv1alpha1 "kubesphere.io/api/tenant/v1alpha1"
typesv1beta1 "kubesphere.io/api/types/v1beta1"
runtimecache "sigs.k8s.io/controller-runtime/pkg/cache"
@@ -268,7 +269,8 @@ func (s *APIServer) installKubeSphereAPIs(stopCh <-chan struct{}) {
urlruntime.Must(edgeruntimev1alpha1.AddToContainer(s.container, s.Config.EdgeRuntimeOptions.Endpoint))
urlruntime.Must(notificationkapisv2beta1.AddToContainer(s.container, s.InformerFactory, s.KubernetesClient.Kubernetes(),
s.KubernetesClient.KubeSphere()))
urlruntime.Must(notificationkapisv2beta2.AddToContainer(s.container, s.Config.NotificationOptions))
urlruntime.Must(notificationkapisv2beta2.AddToContainer(s.container, s.InformerFactory, s.KubernetesClient.Kubernetes(),
s.KubernetesClient.KubeSphere(), s.Config.NotificationOptions))
urlruntime.Must(gatewayv1alpha1.AddToContainer(s.container, s.Config.GatewayOptions, s.RuntimeCache, s.RuntimeClient, s.InformerFactory, s.KubernetesClient.Kubernetes(), s.LoggingClient))
}
@@ -320,6 +322,10 @@ func (s *APIServer) buildHandlerChain(stopCh <-chan struct{}) {
resourcev1alpha3.Resource(clusterv1alpha1.ResourcesPluralCluster),
notificationv2beta1.Resource(notificationv2beta1.ResourcesPluralConfig),
notificationv2beta1.Resource(notificationv2beta1.ResourcesPluralReceiver),
notificationv2beta2.Resource(notificationv2beta2.ResourcesPluralConfig),
notificationv2beta2.Resource(notificationv2beta2.ResourcesPluralReceiver),
notificationv2beta2.Resource(notificationv2beta2.ResourcesPluralRouter),
notificationv2beta2.Resource(notificationv2beta2.ResourcesPluralSilence),
},
}
@@ -498,6 +504,12 @@ func (s *APIServer) waitForResourceSync(ctx context.Context) error {
notificationv2beta1.ResourcesPluralConfig,
notificationv2beta1.ResourcesPluralReceiver,
},
{Group: "notification.kubesphere.io", Version: "v2beta2"}: {
notificationv2beta2.ResourcesPluralConfig,
notificationv2beta2.ResourcesPluralReceiver,
notificationv2beta2.ResourcesPluralRouter,
notificationv2beta2.ResourcesPluralSilence,
},
}
// skip caching devops resources if devops not enabled

View File

@@ -32,12 +32,14 @@ import (
iamv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/iam/v1alpha2"
networkv1alpha1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/network/v1alpha1"
notificationv2beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/notification/v2beta1"
notificationv2beta2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/notification/v2beta2"
quotav1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/quota/v1alpha2"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/servicemesh/v1alpha2"
storagev1alpha1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/storage/v1alpha1"
tenantv1alpha1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/tenant/v1alpha1"
tenantv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/tenant/v1alpha2"
typesv1beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/types/v1beta1"
typesv1beta2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/types/v1beta2"
)
type Interface interface {
@@ -50,12 +52,14 @@ type Interface interface {
IamV1alpha2() iamv1alpha2.IamV1alpha2Interface
NetworkV1alpha1() networkv1alpha1.NetworkV1alpha1Interface
NotificationV2beta1() notificationv2beta1.NotificationV2beta1Interface
NotificationV2beta2() notificationv2beta2.NotificationV2beta2Interface
QuotaV1alpha2() quotav1alpha2.QuotaV1alpha2Interface
ServicemeshV1alpha2() servicemeshv1alpha2.ServicemeshV1alpha2Interface
StorageV1alpha1() storagev1alpha1.StorageV1alpha1Interface
TenantV1alpha1() tenantv1alpha1.TenantV1alpha1Interface
TenantV1alpha2() tenantv1alpha2.TenantV1alpha2Interface
TypesV1beta1() typesv1beta1.TypesV1beta1Interface
TypesV1beta2() typesv1beta2.TypesV1beta2Interface
}
// Clientset contains the clients for groups. Each group has exactly one
@@ -70,12 +74,14 @@ type Clientset struct {
iamV1alpha2 *iamv1alpha2.IamV1alpha2Client
networkV1alpha1 *networkv1alpha1.NetworkV1alpha1Client
notificationV2beta1 *notificationv2beta1.NotificationV2beta1Client
notificationV2beta2 *notificationv2beta2.NotificationV2beta2Client
quotaV1alpha2 *quotav1alpha2.QuotaV1alpha2Client
servicemeshV1alpha2 *servicemeshv1alpha2.ServicemeshV1alpha2Client
storageV1alpha1 *storagev1alpha1.StorageV1alpha1Client
tenantV1alpha1 *tenantv1alpha1.TenantV1alpha1Client
tenantV1alpha2 *tenantv1alpha2.TenantV1alpha2Client
typesV1beta1 *typesv1beta1.TypesV1beta1Client
typesV1beta2 *typesv1beta2.TypesV1beta2Client
}
// ApplicationV1alpha1 retrieves the ApplicationV1alpha1Client
@@ -118,6 +124,11 @@ func (c *Clientset) NotificationV2beta1() notificationv2beta1.NotificationV2beta
return c.notificationV2beta1
}
// NotificationV2beta2 retrieves the NotificationV2beta2Client
func (c *Clientset) NotificationV2beta2() notificationv2beta2.NotificationV2beta2Interface {
return c.notificationV2beta2
}
// QuotaV1alpha2 retrieves the QuotaV1alpha2Client
func (c *Clientset) QuotaV1alpha2() quotav1alpha2.QuotaV1alpha2Interface {
return c.quotaV1alpha2
@@ -148,6 +159,11 @@ func (c *Clientset) TypesV1beta1() typesv1beta1.TypesV1beta1Interface {
return c.typesV1beta1
}
// TypesV1beta2 retrieves the TypesV1beta2Client
func (c *Clientset) TypesV1beta2() typesv1beta2.TypesV1beta2Interface {
return c.typesV1beta2
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
@@ -201,6 +217,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
if err != nil {
return nil, err
}
cs.notificationV2beta2, err = notificationv2beta2.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.quotaV1alpha2, err = quotav1alpha2.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
@@ -225,6 +245,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
if err != nil {
return nil, err
}
cs.typesV1beta2, err = typesv1beta2.NewForConfig(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
if err != nil {
@@ -245,12 +269,14 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
cs.iamV1alpha2 = iamv1alpha2.NewForConfigOrDie(c)
cs.networkV1alpha1 = networkv1alpha1.NewForConfigOrDie(c)
cs.notificationV2beta1 = notificationv2beta1.NewForConfigOrDie(c)
cs.notificationV2beta2 = notificationv2beta2.NewForConfigOrDie(c)
cs.quotaV1alpha2 = quotav1alpha2.NewForConfigOrDie(c)
cs.servicemeshV1alpha2 = servicemeshv1alpha2.NewForConfigOrDie(c)
cs.storageV1alpha1 = storagev1alpha1.NewForConfigOrDie(c)
cs.tenantV1alpha1 = tenantv1alpha1.NewForConfigOrDie(c)
cs.tenantV1alpha2 = tenantv1alpha2.NewForConfigOrDie(c)
cs.typesV1beta1 = typesv1beta1.NewForConfigOrDie(c)
cs.typesV1beta2 = typesv1beta2.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
@@ -267,12 +293,14 @@ func New(c rest.Interface) *Clientset {
cs.iamV1alpha2 = iamv1alpha2.New(c)
cs.networkV1alpha1 = networkv1alpha1.New(c)
cs.notificationV2beta1 = notificationv2beta1.New(c)
cs.notificationV2beta2 = notificationv2beta2.New(c)
cs.quotaV1alpha2 = quotav1alpha2.New(c)
cs.servicemeshV1alpha2 = servicemeshv1alpha2.New(c)
cs.storageV1alpha1 = storagev1alpha1.New(c)
cs.tenantV1alpha1 = tenantv1alpha1.New(c)
cs.tenantV1alpha2 = tenantv1alpha2.New(c)
cs.typesV1beta1 = typesv1beta1.New(c)
cs.typesV1beta2 = typesv1beta2.New(c)
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
return &cs

View File

@@ -41,6 +41,8 @@ import (
fakenetworkv1alpha1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/network/v1alpha1/fake"
notificationv2beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/notification/v2beta1"
fakenotificationv2beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/notification/v2beta1/fake"
notificationv2beta2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/notification/v2beta2"
fakenotificationv2beta2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/notification/v2beta2/fake"
quotav1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/quota/v1alpha2"
fakequotav1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/quota/v1alpha2/fake"
servicemeshv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/servicemesh/v1alpha2"
@@ -53,6 +55,8 @@ import (
faketenantv1alpha2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/tenant/v1alpha2/fake"
typesv1beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/types/v1beta1"
faketypesv1beta1 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/types/v1beta1/fake"
typesv1beta2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/types/v1beta2"
faketypesv1beta2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/types/v1beta2/fake"
)
// NewSimpleClientset returns a clientset that will respond with the provided objects.
@@ -142,6 +146,11 @@ func (c *Clientset) NotificationV2beta1() notificationv2beta1.NotificationV2beta
return &fakenotificationv2beta1.FakeNotificationV2beta1{Fake: &c.Fake}
}
// NotificationV2beta2 retrieves the NotificationV2beta2Client
func (c *Clientset) NotificationV2beta2() notificationv2beta2.NotificationV2beta2Interface {
return &fakenotificationv2beta2.FakeNotificationV2beta2{Fake: &c.Fake}
}
// QuotaV1alpha2 retrieves the QuotaV1alpha2Client
func (c *Clientset) QuotaV1alpha2() quotav1alpha2.QuotaV1alpha2Interface {
return &fakequotav1alpha2.FakeQuotaV1alpha2{Fake: &c.Fake}
@@ -171,3 +180,8 @@ func (c *Clientset) TenantV1alpha2() tenantv1alpha2.TenantV1alpha2Interface {
func (c *Clientset) TypesV1beta1() typesv1beta1.TypesV1beta1Interface {
return &faketypesv1beta1.FakeTypesV1beta1{Fake: &c.Fake}
}
// TypesV1beta2 retrieves the TypesV1beta2Client
func (c *Clientset) TypesV1beta2() typesv1beta2.TypesV1beta2Interface {
return &faketypesv1beta2.FakeTypesV1beta2{Fake: &c.Fake}
}

View File

@@ -32,12 +32,14 @@ import (
iamv1alpha2 "kubesphere.io/api/iam/v1alpha2"
networkv1alpha1 "kubesphere.io/api/network/v1alpha1"
notificationv2beta1 "kubesphere.io/api/notification/v2beta1"
notificationv2beta2 "kubesphere.io/api/notification/v2beta2"
quotav1alpha2 "kubesphere.io/api/quota/v1alpha2"
servicemeshv1alpha2 "kubesphere.io/api/servicemesh/v1alpha2"
storagev1alpha1 "kubesphere.io/api/storage/v1alpha1"
tenantv1alpha1 "kubesphere.io/api/tenant/v1alpha1"
tenantv1alpha2 "kubesphere.io/api/tenant/v1alpha2"
typesv1beta1 "kubesphere.io/api/types/v1beta1"
typesv1beta2 "kubesphere.io/api/types/v1beta2"
)
var scheme = runtime.NewScheme()
@@ -52,12 +54,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{
iamv1alpha2.AddToScheme,
networkv1alpha1.AddToScheme,
notificationv2beta1.AddToScheme,
notificationv2beta2.AddToScheme,
quotav1alpha2.AddToScheme,
servicemeshv1alpha2.AddToScheme,
storagev1alpha1.AddToScheme,
tenantv1alpha1.AddToScheme,
tenantv1alpha2.AddToScheme,
typesv1beta1.AddToScheme,
typesv1beta2.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition

View File

@@ -32,12 +32,14 @@ import (
iamv1alpha2 "kubesphere.io/api/iam/v1alpha2"
networkv1alpha1 "kubesphere.io/api/network/v1alpha1"
notificationv2beta1 "kubesphere.io/api/notification/v2beta1"
notificationv2beta2 "kubesphere.io/api/notification/v2beta2"
quotav1alpha2 "kubesphere.io/api/quota/v1alpha2"
servicemeshv1alpha2 "kubesphere.io/api/servicemesh/v1alpha2"
storagev1alpha1 "kubesphere.io/api/storage/v1alpha1"
tenantv1alpha1 "kubesphere.io/api/tenant/v1alpha1"
tenantv1alpha2 "kubesphere.io/api/tenant/v1alpha2"
typesv1beta1 "kubesphere.io/api/types/v1beta1"
typesv1beta2 "kubesphere.io/api/types/v1beta2"
)
var Scheme = runtime.NewScheme()
@@ -52,12 +54,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{
iamv1alpha2.AddToScheme,
networkv1alpha1.AddToScheme,
notificationv2beta1.AddToScheme,
notificationv2beta2.AddToScheme,
quotav1alpha2.AddToScheme,
servicemeshv1alpha2.AddToScheme,
storagev1alpha1.AddToScheme,
tenantv1alpha1.AddToScheme,
tenantv1alpha2.AddToScheme,
typesv1beta1.AddToScheme,
typesv1beta2.AddToScheme,
}
// AddToScheme adds all types of this clientset into the given scheme. This allows composition

View File

@@ -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"
)
// ConfigsGetter has a method to return a ConfigInterface.
// A group's client should implement this interface.
type ConfigsGetter interface {
Configs() ConfigInterface
}
// ConfigInterface has methods to work with Config resources.
type ConfigInterface interface {
Create(ctx context.Context, config *v2beta2.Config, opts v1.CreateOptions) (*v2beta2.Config, error)
Update(ctx context.Context, config *v2beta2.Config, opts v1.UpdateOptions) (*v2beta2.Config, error)
UpdateStatus(ctx context.Context, config *v2beta2.Config, opts v1.UpdateOptions) (*v2beta2.Config, 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.Config, error)
List(ctx context.Context, opts v1.ListOptions) (*v2beta2.ConfigList, 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.Config, err error)
ConfigExpansion
}
// configs implements ConfigInterface
type configs struct {
client rest.Interface
}
// newConfigs returns a Configs
func newConfigs(c *NotificationV2beta2Client) *configs {
return &configs{
client: c.RESTClient(),
}
}
// Get takes name of the config, and returns the corresponding config object, and an error if there is any.
func (c *configs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.Config, err error) {
result = &v2beta2.Config{}
err = c.client.Get().
Resource("configs").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of Configs that match those selectors.
func (c *configs) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.ConfigList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v2beta2.ConfigList{}
err = c.client.Get().
Resource("configs").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested configs.
func (c *configs) 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("configs").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a config and creates it. Returns the server's representation of the config, and an error, if there is any.
func (c *configs) Create(ctx context.Context, config *v2beta2.Config, opts v1.CreateOptions) (result *v2beta2.Config, err error) {
result = &v2beta2.Config{}
err = c.client.Post().
Resource("configs").
VersionedParams(&opts, scheme.ParameterCodec).
Body(config).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a config and updates it. Returns the server's representation of the config, and an error, if there is any.
func (c *configs) Update(ctx context.Context, config *v2beta2.Config, opts v1.UpdateOptions) (result *v2beta2.Config, err error) {
result = &v2beta2.Config{}
err = c.client.Put().
Resource("configs").
Name(config.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(config).
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 *configs) UpdateStatus(ctx context.Context, config *v2beta2.Config, opts v1.UpdateOptions) (result *v2beta2.Config, err error) {
result = &v2beta2.Config{}
err = c.client.Put().
Resource("configs").
Name(config.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(config).
Do(ctx).
Into(result)
return
}
// Delete takes name of the config and deletes it. Returns an error if one occurs.
func (c *configs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Resource("configs").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *configs) 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("configs").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched config.
func (c *configs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.Config, err error) {
result = &v2beta2.Config{}
err = c.client.Patch(pt).
Resource("configs").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@@ -0,0 +1,20 @@
/*
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.
// This package has the automatically generated typed clients.
package v2beta2

View File

@@ -0,0 +1,20 @@
/*
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 has the automatically generated clients.
package fake

View File

@@ -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"
)
// FakeConfigs implements ConfigInterface
type FakeConfigs struct {
Fake *FakeNotificationV2beta2
}
var configsResource = schema.GroupVersionResource{Group: "notification.kubesphere.io", Version: "v2beta2", Resource: "configs"}
var configsKind = schema.GroupVersionKind{Group: "notification.kubesphere.io", Version: "v2beta2", Kind: "Config"}
// Get takes name of the config, and returns the corresponding config object, and an error if there is any.
func (c *FakeConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.Config, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(configsResource, name), &v2beta2.Config{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Config), err
}
// List takes label and field selectors, and returns the list of Configs that match those selectors.
func (c *FakeConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.ConfigList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(configsResource, configsKind, opts), &v2beta2.ConfigList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v2beta2.ConfigList{ListMeta: obj.(*v2beta2.ConfigList).ListMeta}
for _, item := range obj.(*v2beta2.ConfigList).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 configs.
func (c *FakeConfigs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(configsResource, opts))
}
// Create takes the representation of a config and creates it. Returns the server's representation of the config, and an error, if there is any.
func (c *FakeConfigs) Create(ctx context.Context, config *v2beta2.Config, opts v1.CreateOptions) (result *v2beta2.Config, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(configsResource, config), &v2beta2.Config{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Config), err
}
// Update takes the representation of a config and updates it. Returns the server's representation of the config, and an error, if there is any.
func (c *FakeConfigs) Update(ctx context.Context, config *v2beta2.Config, opts v1.UpdateOptions) (result *v2beta2.Config, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(configsResource, config), &v2beta2.Config{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Config), 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 *FakeConfigs) UpdateStatus(ctx context.Context, config *v2beta2.Config, opts v1.UpdateOptions) (*v2beta2.Config, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(configsResource, "status", config), &v2beta2.Config{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Config), err
}
// Delete takes name of the config and deletes it. Returns an error if one occurs.
func (c *FakeConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(configsResource, name), &v2beta2.Config{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(configsResource, listOpts)
_, err := c.Fake.Invokes(action, &v2beta2.ConfigList{})
return err
}
// Patch applies the patch and returns the patched config.
func (c *FakeConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.Config, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(configsResource, name, pt, data, subresources...), &v2beta2.Config{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Config), err
}

View File

@@ -0,0 +1,52 @@
/*
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 (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
v2beta2 "kubesphere.io/kubesphere/pkg/client/clientset/versioned/typed/notification/v2beta2"
)
type FakeNotificationV2beta2 struct {
*testing.Fake
}
func (c *FakeNotificationV2beta2) Configs() v2beta2.ConfigInterface {
return &FakeConfigs{c}
}
func (c *FakeNotificationV2beta2) Receivers() v2beta2.ReceiverInterface {
return &FakeReceivers{c}
}
func (c *FakeNotificationV2beta2) Routers() v2beta2.RouterInterface {
return &FakeRouters{c}
}
func (c *FakeNotificationV2beta2) Silences() v2beta2.SilenceInterface {
return &FakeSilences{c}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeNotificationV2beta2) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@@ -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"
)
// FakeReceivers implements ReceiverInterface
type FakeReceivers struct {
Fake *FakeNotificationV2beta2
}
var receiversResource = schema.GroupVersionResource{Group: "notification.kubesphere.io", Version: "v2beta2", Resource: "receivers"}
var receiversKind = schema.GroupVersionKind{Group: "notification.kubesphere.io", Version: "v2beta2", Kind: "Receiver"}
// Get takes name of the receiver, and returns the corresponding receiver object, and an error if there is any.
func (c *FakeReceivers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.Receiver, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(receiversResource, name), &v2beta2.Receiver{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Receiver), err
}
// List takes label and field selectors, and returns the list of Receivers that match those selectors.
func (c *FakeReceivers) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.ReceiverList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(receiversResource, receiversKind, opts), &v2beta2.ReceiverList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v2beta2.ReceiverList{ListMeta: obj.(*v2beta2.ReceiverList).ListMeta}
for _, item := range obj.(*v2beta2.ReceiverList).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 receivers.
func (c *FakeReceivers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(receiversResource, opts))
}
// Create takes the representation of a receiver and creates it. Returns the server's representation of the receiver, and an error, if there is any.
func (c *FakeReceivers) Create(ctx context.Context, receiver *v2beta2.Receiver, opts v1.CreateOptions) (result *v2beta2.Receiver, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(receiversResource, receiver), &v2beta2.Receiver{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Receiver), err
}
// Update takes the representation of a receiver and updates it. Returns the server's representation of the receiver, and an error, if there is any.
func (c *FakeReceivers) Update(ctx context.Context, receiver *v2beta2.Receiver, opts v1.UpdateOptions) (result *v2beta2.Receiver, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(receiversResource, receiver), &v2beta2.Receiver{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Receiver), 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 *FakeReceivers) UpdateStatus(ctx context.Context, receiver *v2beta2.Receiver, opts v1.UpdateOptions) (*v2beta2.Receiver, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(receiversResource, "status", receiver), &v2beta2.Receiver{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Receiver), err
}
// Delete takes name of the receiver and deletes it. Returns an error if one occurs.
func (c *FakeReceivers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(receiversResource, name), &v2beta2.Receiver{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeReceivers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(receiversResource, listOpts)
_, err := c.Fake.Invokes(action, &v2beta2.ReceiverList{})
return err
}
// Patch applies the patch and returns the patched receiver.
func (c *FakeReceivers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.Receiver, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(receiversResource, name, pt, data, subresources...), &v2beta2.Receiver{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Receiver), err
}

View File

@@ -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"
)
// FakeRouters implements RouterInterface
type FakeRouters struct {
Fake *FakeNotificationV2beta2
}
var routersResource = schema.GroupVersionResource{Group: "notification.kubesphere.io", Version: "v2beta2", Resource: "routers"}
var routersKind = schema.GroupVersionKind{Group: "notification.kubesphere.io", Version: "v2beta2", Kind: "Router"}
// Get takes name of the router, and returns the corresponding router object, and an error if there is any.
func (c *FakeRouters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.Router, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(routersResource, name), &v2beta2.Router{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Router), err
}
// List takes label and field selectors, and returns the list of Routers that match those selectors.
func (c *FakeRouters) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.RouterList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(routersResource, routersKind, opts), &v2beta2.RouterList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v2beta2.RouterList{ListMeta: obj.(*v2beta2.RouterList).ListMeta}
for _, item := range obj.(*v2beta2.RouterList).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 routers.
func (c *FakeRouters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(routersResource, opts))
}
// Create takes the representation of a router and creates it. Returns the server's representation of the router, and an error, if there is any.
func (c *FakeRouters) Create(ctx context.Context, router *v2beta2.Router, opts v1.CreateOptions) (result *v2beta2.Router, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(routersResource, router), &v2beta2.Router{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Router), err
}
// Update takes the representation of a router and updates it. Returns the server's representation of the router, and an error, if there is any.
func (c *FakeRouters) Update(ctx context.Context, router *v2beta2.Router, opts v1.UpdateOptions) (result *v2beta2.Router, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(routersResource, router), &v2beta2.Router{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Router), 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 *FakeRouters) UpdateStatus(ctx context.Context, router *v2beta2.Router, opts v1.UpdateOptions) (*v2beta2.Router, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(routersResource, "status", router), &v2beta2.Router{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Router), err
}
// Delete takes name of the router and deletes it. Returns an error if one occurs.
func (c *FakeRouters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(routersResource, name), &v2beta2.Router{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeRouters) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(routersResource, listOpts)
_, err := c.Fake.Invokes(action, &v2beta2.RouterList{})
return err
}
// Patch applies the patch and returns the patched router.
func (c *FakeRouters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.Router, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(routersResource, name, pt, data, subresources...), &v2beta2.Router{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Router), err
}

View File

@@ -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"
)
// FakeSilences implements SilenceInterface
type FakeSilences struct {
Fake *FakeNotificationV2beta2
}
var silencesResource = schema.GroupVersionResource{Group: "notification.kubesphere.io", Version: "v2beta2", Resource: "silences"}
var silencesKind = schema.GroupVersionKind{Group: "notification.kubesphere.io", Version: "v2beta2", Kind: "Silence"}
// Get takes name of the silence, and returns the corresponding silence object, and an error if there is any.
func (c *FakeSilences) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.Silence, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(silencesResource, name), &v2beta2.Silence{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Silence), err
}
// List takes label and field selectors, and returns the list of Silences that match those selectors.
func (c *FakeSilences) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.SilenceList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(silencesResource, silencesKind, opts), &v2beta2.SilenceList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v2beta2.SilenceList{ListMeta: obj.(*v2beta2.SilenceList).ListMeta}
for _, item := range obj.(*v2beta2.SilenceList).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 silences.
func (c *FakeSilences) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(silencesResource, opts))
}
// Create takes the representation of a silence and creates it. Returns the server's representation of the silence, and an error, if there is any.
func (c *FakeSilences) Create(ctx context.Context, silence *v2beta2.Silence, opts v1.CreateOptions) (result *v2beta2.Silence, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(silencesResource, silence), &v2beta2.Silence{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Silence), err
}
// Update takes the representation of a silence and updates it. Returns the server's representation of the silence, and an error, if there is any.
func (c *FakeSilences) Update(ctx context.Context, silence *v2beta2.Silence, opts v1.UpdateOptions) (result *v2beta2.Silence, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(silencesResource, silence), &v2beta2.Silence{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Silence), 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 *FakeSilences) UpdateStatus(ctx context.Context, silence *v2beta2.Silence, opts v1.UpdateOptions) (*v2beta2.Silence, error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateSubresourceAction(silencesResource, "status", silence), &v2beta2.Silence{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Silence), err
}
// Delete takes name of the silence and deletes it. Returns an error if one occurs.
func (c *FakeSilences) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteAction(silencesResource, name), &v2beta2.Silence{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeSilences) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(silencesResource, listOpts)
_, err := c.Fake.Invokes(action, &v2beta2.SilenceList{})
return err
}
// Patch applies the patch and returns the patched silence.
func (c *FakeSilences) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.Silence, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(silencesResource, name, pt, data, subresources...), &v2beta2.Silence{})
if obj == nil {
return nil, err
}
return obj.(*v2beta2.Silence), err
}

View File

@@ -0,0 +1,27 @@
/*
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
type ConfigExpansion interface{}
type ReceiverExpansion interface{}
type RouterExpansion interface{}
type SilenceExpansion interface{}

View File

@@ -0,0 +1,104 @@
/*
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 (
rest "k8s.io/client-go/rest"
v2beta2 "kubesphere.io/api/notification/v2beta2"
"kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme"
)
type NotificationV2beta2Interface interface {
RESTClient() rest.Interface
ConfigsGetter
ReceiversGetter
RoutersGetter
SilencesGetter
}
// NotificationV2beta2Client is used to interact with features provided by the notification.kubesphere.io group.
type NotificationV2beta2Client struct {
restClient rest.Interface
}
func (c *NotificationV2beta2Client) Configs() ConfigInterface {
return newConfigs(c)
}
func (c *NotificationV2beta2Client) Receivers() ReceiverInterface {
return newReceivers(c)
}
func (c *NotificationV2beta2Client) Routers() RouterInterface {
return newRouters(c)
}
func (c *NotificationV2beta2Client) Silences() SilenceInterface {
return newSilences(c)
}
// NewForConfig creates a new NotificationV2beta2Client for the given config.
func NewForConfig(c *rest.Config) (*NotificationV2beta2Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &NotificationV2beta2Client{client}, nil
}
// NewForConfigOrDie creates a new NotificationV2beta2Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *NotificationV2beta2Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new NotificationV2beta2Client for the given RESTClient.
func New(c rest.Interface) *NotificationV2beta2Client {
return &NotificationV2beta2Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v2beta2.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *NotificationV2beta2Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}

View File

@@ -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"
)
// ReceiversGetter has a method to return a ReceiverInterface.
// A group's client should implement this interface.
type ReceiversGetter interface {
Receivers() ReceiverInterface
}
// ReceiverInterface has methods to work with Receiver resources.
type ReceiverInterface interface {
Create(ctx context.Context, receiver *v2beta2.Receiver, opts v1.CreateOptions) (*v2beta2.Receiver, error)
Update(ctx context.Context, receiver *v2beta2.Receiver, opts v1.UpdateOptions) (*v2beta2.Receiver, error)
UpdateStatus(ctx context.Context, receiver *v2beta2.Receiver, opts v1.UpdateOptions) (*v2beta2.Receiver, 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.Receiver, error)
List(ctx context.Context, opts v1.ListOptions) (*v2beta2.ReceiverList, 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.Receiver, err error)
ReceiverExpansion
}
// receivers implements ReceiverInterface
type receivers struct {
client rest.Interface
}
// newReceivers returns a Receivers
func newReceivers(c *NotificationV2beta2Client) *receivers {
return &receivers{
client: c.RESTClient(),
}
}
// Get takes name of the receiver, and returns the corresponding receiver object, and an error if there is any.
func (c *receivers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.Receiver, err error) {
result = &v2beta2.Receiver{}
err = c.client.Get().
Resource("receivers").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of Receivers that match those selectors.
func (c *receivers) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.ReceiverList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v2beta2.ReceiverList{}
err = c.client.Get().
Resource("receivers").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested receivers.
func (c *receivers) 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("receivers").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a receiver and creates it. Returns the server's representation of the receiver, and an error, if there is any.
func (c *receivers) Create(ctx context.Context, receiver *v2beta2.Receiver, opts v1.CreateOptions) (result *v2beta2.Receiver, err error) {
result = &v2beta2.Receiver{}
err = c.client.Post().
Resource("receivers").
VersionedParams(&opts, scheme.ParameterCodec).
Body(receiver).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a receiver and updates it. Returns the server's representation of the receiver, and an error, if there is any.
func (c *receivers) Update(ctx context.Context, receiver *v2beta2.Receiver, opts v1.UpdateOptions) (result *v2beta2.Receiver, err error) {
result = &v2beta2.Receiver{}
err = c.client.Put().
Resource("receivers").
Name(receiver.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(receiver).
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 *receivers) UpdateStatus(ctx context.Context, receiver *v2beta2.Receiver, opts v1.UpdateOptions) (result *v2beta2.Receiver, err error) {
result = &v2beta2.Receiver{}
err = c.client.Put().
Resource("receivers").
Name(receiver.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(receiver).
Do(ctx).
Into(result)
return
}
// Delete takes name of the receiver and deletes it. Returns an error if one occurs.
func (c *receivers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Resource("receivers").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *receivers) 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("receivers").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched receiver.
func (c *receivers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.Receiver, err error) {
result = &v2beta2.Receiver{}
err = c.client.Patch(pt).
Resource("receivers").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@@ -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"
)
// RoutersGetter has a method to return a RouterInterface.
// A group's client should implement this interface.
type RoutersGetter interface {
Routers() RouterInterface
}
// RouterInterface has methods to work with Router resources.
type RouterInterface interface {
Create(ctx context.Context, router *v2beta2.Router, opts v1.CreateOptions) (*v2beta2.Router, error)
Update(ctx context.Context, router *v2beta2.Router, opts v1.UpdateOptions) (*v2beta2.Router, error)
UpdateStatus(ctx context.Context, router *v2beta2.Router, opts v1.UpdateOptions) (*v2beta2.Router, 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.Router, error)
List(ctx context.Context, opts v1.ListOptions) (*v2beta2.RouterList, 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.Router, err error)
RouterExpansion
}
// routers implements RouterInterface
type routers struct {
client rest.Interface
}
// newRouters returns a Routers
func newRouters(c *NotificationV2beta2Client) *routers {
return &routers{
client: c.RESTClient(),
}
}
// Get takes name of the router, and returns the corresponding router object, and an error if there is any.
func (c *routers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.Router, err error) {
result = &v2beta2.Router{}
err = c.client.Get().
Resource("routers").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of Routers that match those selectors.
func (c *routers) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.RouterList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v2beta2.RouterList{}
err = c.client.Get().
Resource("routers").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested routers.
func (c *routers) 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("routers").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a router and creates it. Returns the server's representation of the router, and an error, if there is any.
func (c *routers) Create(ctx context.Context, router *v2beta2.Router, opts v1.CreateOptions) (result *v2beta2.Router, err error) {
result = &v2beta2.Router{}
err = c.client.Post().
Resource("routers").
VersionedParams(&opts, scheme.ParameterCodec).
Body(router).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a router and updates it. Returns the server's representation of the router, and an error, if there is any.
func (c *routers) Update(ctx context.Context, router *v2beta2.Router, opts v1.UpdateOptions) (result *v2beta2.Router, err error) {
result = &v2beta2.Router{}
err = c.client.Put().
Resource("routers").
Name(router.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(router).
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 *routers) UpdateStatus(ctx context.Context, router *v2beta2.Router, opts v1.UpdateOptions) (result *v2beta2.Router, err error) {
result = &v2beta2.Router{}
err = c.client.Put().
Resource("routers").
Name(router.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(router).
Do(ctx).
Into(result)
return
}
// Delete takes name of the router and deletes it. Returns an error if one occurs.
func (c *routers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Resource("routers").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *routers) 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("routers").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched router.
func (c *routers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.Router, err error) {
result = &v2beta2.Router{}
err = c.client.Patch(pt).
Resource("routers").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@@ -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"
)
// SilencesGetter has a method to return a SilenceInterface.
// A group's client should implement this interface.
type SilencesGetter interface {
Silences() SilenceInterface
}
// SilenceInterface has methods to work with Silence resources.
type SilenceInterface interface {
Create(ctx context.Context, silence *v2beta2.Silence, opts v1.CreateOptions) (*v2beta2.Silence, error)
Update(ctx context.Context, silence *v2beta2.Silence, opts v1.UpdateOptions) (*v2beta2.Silence, error)
UpdateStatus(ctx context.Context, silence *v2beta2.Silence, opts v1.UpdateOptions) (*v2beta2.Silence, 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.Silence, error)
List(ctx context.Context, opts v1.ListOptions) (*v2beta2.SilenceList, 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.Silence, err error)
SilenceExpansion
}
// silences implements SilenceInterface
type silences struct {
client rest.Interface
}
// newSilences returns a Silences
func newSilences(c *NotificationV2beta2Client) *silences {
return &silences{
client: c.RESTClient(),
}
}
// Get takes name of the silence, and returns the corresponding silence object, and an error if there is any.
func (c *silences) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.Silence, err error) {
result = &v2beta2.Silence{}
err = c.client.Get().
Resource("silences").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of Silences that match those selectors.
func (c *silences) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.SilenceList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v2beta2.SilenceList{}
err = c.client.Get().
Resource("silences").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested silences.
func (c *silences) 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("silences").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a silence and creates it. Returns the server's representation of the silence, and an error, if there is any.
func (c *silences) Create(ctx context.Context, silence *v2beta2.Silence, opts v1.CreateOptions) (result *v2beta2.Silence, err error) {
result = &v2beta2.Silence{}
err = c.client.Post().
Resource("silences").
VersionedParams(&opts, scheme.ParameterCodec).
Body(silence).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a silence and updates it. Returns the server's representation of the silence, and an error, if there is any.
func (c *silences) Update(ctx context.Context, silence *v2beta2.Silence, opts v1.UpdateOptions) (result *v2beta2.Silence, err error) {
result = &v2beta2.Silence{}
err = c.client.Put().
Resource("silences").
Name(silence.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(silence).
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 *silences) UpdateStatus(ctx context.Context, silence *v2beta2.Silence, opts v1.UpdateOptions) (result *v2beta2.Silence, err error) {
result = &v2beta2.Silence{}
err = c.client.Put().
Resource("silences").
Name(silence.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(silence).
Do(ctx).
Into(result)
return
}
// Delete takes name of the silence and deletes it. Returns an error if one occurs.
func (c *silences) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Resource("silences").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *silences) 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("silences").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched silence.
func (c *silences) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.Silence, err error) {
result = &v2beta2.Silence{}
err = c.client.Patch(pt).
Resource("silences").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@@ -0,0 +1,20 @@
/*
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.
// This package has the automatically generated typed clients.
package v1beta2

View File

@@ -0,0 +1,20 @@
/*
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 has the automatically generated clients.
package fake

View File

@@ -0,0 +1,35 @@
/*
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 (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
)
type FakeTypesV1beta2 struct {
*testing.Fake
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeTypesV1beta2) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}

View File

@@ -0,0 +1,19 @@
/*
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

View File

@@ -0,0 +1,84 @@
/*
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 (
rest "k8s.io/client-go/rest"
v1beta2 "kubesphere.io/api/types/v1beta2"
"kubesphere.io/kubesphere/pkg/client/clientset/versioned/scheme"
)
type TypesV1beta2Interface interface {
RESTClient() rest.Interface
}
// TypesV1beta2Client is used to interact with features provided by the types.kubefed.io group.
type TypesV1beta2Client struct {
restClient rest.Interface
}
// NewForConfig creates a new TypesV1beta2Client for the given config.
func NewForConfig(c *rest.Config) (*TypesV1beta2Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
if err != nil {
return nil, err
}
return &TypesV1beta2Client{client}, nil
}
// NewForConfigOrDie creates a new TypesV1beta2Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *TypesV1beta2Client {
client, err := NewForConfig(c)
if err != nil {
panic(err)
}
return client
}
// New creates a new TypesV1beta2Client for the given RESTClient.
func New(c rest.Interface) *TypesV1beta2Client {
return &TypesV1beta2Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v1beta2.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *TypesV1beta2Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
}

View File

@@ -31,6 +31,7 @@ import (
v1alpha2 "kubesphere.io/api/iam/v1alpha2"
networkv1alpha1 "kubesphere.io/api/network/v1alpha1"
v2beta1 "kubesphere.io/api/notification/v2beta1"
v2beta2 "kubesphere.io/api/notification/v2beta2"
quotav1alpha2 "kubesphere.io/api/quota/v1alpha2"
servicemeshv1alpha2 "kubesphere.io/api/servicemesh/v1alpha2"
storagev1alpha1 "kubesphere.io/api/storage/v1alpha1"
@@ -139,6 +140,16 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
case v2beta1.SchemeGroupVersion.WithResource("receivers"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Notification().V2beta1().Receivers().Informer()}, nil
// 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("receivers"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Notification().V2beta2().Receivers().Informer()}, nil
case v2beta2.SchemeGroupVersion.WithResource("routers"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Notification().V2beta2().Routers().Informer()}, nil
case v2beta2.SchemeGroupVersion.WithResource("silences"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Notification().V2beta2().Silences().Informer()}, nil
// Group=quota.kubesphere.io, Version=v1alpha2
case quotav1alpha2.SchemeGroupVersion.WithResource("resourcequotas"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Quota().V1alpha2().ResourceQuotas().Informer()}, nil

View File

@@ -21,12 +21,15 @@ package notification
import (
internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces"
v2beta1 "kubesphere.io/kubesphere/pkg/client/informers/externalversions/notification/v2beta1"
v2beta2 "kubesphere.io/kubesphere/pkg/client/informers/externalversions/notification/v2beta2"
)
// Interface provides access to each of this group's versions.
type Interface interface {
// V2beta1 provides access to shared informers for resources in V2beta1.
V2beta1() v2beta1.Interface
// V2beta2 provides access to shared informers for resources in V2beta2.
V2beta2() v2beta2.Interface
}
type group struct {
@@ -44,3 +47,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
func (g *group) V2beta1() v2beta1.Interface {
return v2beta1.New(g.factory, g.namespace, g.tweakListOptions)
}
// V2beta2 returns a new v2beta2.Interface.
func (g *group) V2beta2() v2beta2.Interface {
return v2beta2.New(g.factory, g.namespace, g.tweakListOptions)
}

View File

@@ -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"
)
// ConfigInformer provides access to a shared informer and lister for
// Configs.
type ConfigInformer interface {
Informer() cache.SharedIndexInformer
Lister() v2beta2.ConfigLister
}
type configInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// NewConfigInformer constructs a new informer for Config 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 NewConfigInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredConfigInformer(client, resyncPeriod, indexers, nil)
}
// NewFilteredConfigInformer constructs a new informer for Config 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 NewFilteredConfigInformer(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().Configs().List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.NotificationV2beta2().Configs().Watch(context.TODO(), options)
},
},
&notificationv2beta2.Config{},
resyncPeriod,
indexers,
)
}
func (f *configInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredConfigInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *configInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&notificationv2beta2.Config{}, f.defaultInformer)
}
func (f *configInformer) Lister() v2beta2.ConfigLister {
return v2beta2.NewConfigLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,66 @@
/*
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 (
internalinterfaces "kubesphere.io/kubesphere/pkg/client/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// Configs returns a ConfigInformer.
Configs() ConfigInformer
// Receivers returns a ReceiverInformer.
Receivers() ReceiverInformer
// Routers returns a RouterInformer.
Routers() RouterInformer
// Silences returns a SilenceInformer.
Silences() SilenceInformer
}
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}
}
// Configs returns a ConfigInformer.
func (v *version) Configs() ConfigInformer {
return &configInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
// Receivers returns a ReceiverInformer.
func (v *version) Receivers() ReceiverInformer {
return &receiverInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
// Routers returns a RouterInformer.
func (v *version) Routers() RouterInformer {
return &routerInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
// Silences returns a SilenceInformer.
func (v *version) Silences() SilenceInformer {
return &silenceInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}

View File

@@ -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"
)
// ReceiverInformer provides access to a shared informer and lister for
// Receivers.
type ReceiverInformer interface {
Informer() cache.SharedIndexInformer
Lister() v2beta2.ReceiverLister
}
type receiverInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// NewReceiverInformer constructs a new informer for Receiver 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 NewReceiverInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredReceiverInformer(client, resyncPeriod, indexers, nil)
}
// NewFilteredReceiverInformer constructs a new informer for Receiver 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 NewFilteredReceiverInformer(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().Receivers().List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.NotificationV2beta2().Receivers().Watch(context.TODO(), options)
},
},
&notificationv2beta2.Receiver{},
resyncPeriod,
indexers,
)
}
func (f *receiverInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredReceiverInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *receiverInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&notificationv2beta2.Receiver{}, f.defaultInformer)
}
func (f *receiverInformer) Lister() v2beta2.ReceiverLister {
return v2beta2.NewReceiverLister(f.Informer().GetIndexer())
}

View File

@@ -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"
)
// RouterInformer provides access to a shared informer and lister for
// Routers.
type RouterInformer interface {
Informer() cache.SharedIndexInformer
Lister() v2beta2.RouterLister
}
type routerInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// NewRouterInformer constructs a new informer for Router 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 NewRouterInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredRouterInformer(client, resyncPeriod, indexers, nil)
}
// NewFilteredRouterInformer constructs a new informer for Router 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 NewFilteredRouterInformer(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().Routers().List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.NotificationV2beta2().Routers().Watch(context.TODO(), options)
},
},
&notificationv2beta2.Router{},
resyncPeriod,
indexers,
)
}
func (f *routerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredRouterInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *routerInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&notificationv2beta2.Router{}, f.defaultInformer)
}
func (f *routerInformer) Lister() v2beta2.RouterLister {
return v2beta2.NewRouterLister(f.Informer().GetIndexer())
}

View File

@@ -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"
)
// SilenceInformer provides access to a shared informer and lister for
// Silences.
type SilenceInformer interface {
Informer() cache.SharedIndexInformer
Lister() v2beta2.SilenceLister
}
type silenceInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// NewSilenceInformer constructs a new informer for Silence 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 NewSilenceInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredSilenceInformer(client, resyncPeriod, indexers, nil)
}
// NewFilteredSilenceInformer constructs a new informer for Silence 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 NewFilteredSilenceInformer(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().Silences().List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.NotificationV2beta2().Silences().Watch(context.TODO(), options)
},
},
&notificationv2beta2.Silence{},
resyncPeriod,
indexers,
)
}
func (f *silenceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredSilenceInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *silenceInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&notificationv2beta2.Silence{}, f.defaultInformer)
}
func (f *silenceInformer) Lister() v2beta2.SilenceLister {
return v2beta2.NewSilenceLister(f.Informer().GetIndexer())
}

View File

@@ -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"
)
// ConfigLister helps list Configs.
// All objects returned here must be treated as read-only.
type ConfigLister interface {
// List lists all Configs in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v2beta2.Config, err error)
// Get retrieves the Config from the index for a given name.
// Objects returned here must be treated as read-only.
Get(name string) (*v2beta2.Config, error)
ConfigListerExpansion
}
// configLister implements the ConfigLister interface.
type configLister struct {
indexer cache.Indexer
}
// NewConfigLister returns a new ConfigLister.
func NewConfigLister(indexer cache.Indexer) ConfigLister {
return &configLister{indexer: indexer}
}
// List lists all Configs in the indexer.
func (s *configLister) List(selector labels.Selector) (ret []*v2beta2.Config, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v2beta2.Config))
})
return ret, err
}
// Get retrieves the Config from the index for a given name.
func (s *configLister) Get(name string) (*v2beta2.Config, error) {
obj, exists, err := s.indexer.GetByKey(name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v2beta2.Resource("config"), name)
}
return obj.(*v2beta2.Config), nil
}

View File

@@ -0,0 +1,35 @@
/*
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
// ConfigListerExpansion allows custom methods to be added to
// ConfigLister.
type ConfigListerExpansion interface{}
// ReceiverListerExpansion allows custom methods to be added to
// ReceiverLister.
type ReceiverListerExpansion interface{}
// RouterListerExpansion allows custom methods to be added to
// RouterLister.
type RouterListerExpansion interface{}
// SilenceListerExpansion allows custom methods to be added to
// SilenceLister.
type SilenceListerExpansion interface{}

View File

@@ -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"
)
// ReceiverLister helps list Receivers.
// All objects returned here must be treated as read-only.
type ReceiverLister interface {
// List lists all Receivers in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v2beta2.Receiver, err error)
// Get retrieves the Receiver from the index for a given name.
// Objects returned here must be treated as read-only.
Get(name string) (*v2beta2.Receiver, error)
ReceiverListerExpansion
}
// receiverLister implements the ReceiverLister interface.
type receiverLister struct {
indexer cache.Indexer
}
// NewReceiverLister returns a new ReceiverLister.
func NewReceiverLister(indexer cache.Indexer) ReceiverLister {
return &receiverLister{indexer: indexer}
}
// List lists all Receivers in the indexer.
func (s *receiverLister) List(selector labels.Selector) (ret []*v2beta2.Receiver, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v2beta2.Receiver))
})
return ret, err
}
// Get retrieves the Receiver from the index for a given name.
func (s *receiverLister) Get(name string) (*v2beta2.Receiver, error) {
obj, exists, err := s.indexer.GetByKey(name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v2beta2.Resource("receiver"), name)
}
return obj.(*v2beta2.Receiver), nil
}

View File

@@ -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"
)
// RouterLister helps list Routers.
// All objects returned here must be treated as read-only.
type RouterLister interface {
// List lists all Routers in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v2beta2.Router, err error)
// Get retrieves the Router from the index for a given name.
// Objects returned here must be treated as read-only.
Get(name string) (*v2beta2.Router, error)
RouterListerExpansion
}
// routerLister implements the RouterLister interface.
type routerLister struct {
indexer cache.Indexer
}
// NewRouterLister returns a new RouterLister.
func NewRouterLister(indexer cache.Indexer) RouterLister {
return &routerLister{indexer: indexer}
}
// List lists all Routers in the indexer.
func (s *routerLister) List(selector labels.Selector) (ret []*v2beta2.Router, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v2beta2.Router))
})
return ret, err
}
// Get retrieves the Router from the index for a given name.
func (s *routerLister) Get(name string) (*v2beta2.Router, error) {
obj, exists, err := s.indexer.GetByKey(name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v2beta2.Resource("router"), name)
}
return obj.(*v2beta2.Router), nil
}

View File

@@ -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"
)
// SilenceLister helps list Silences.
// All objects returned here must be treated as read-only.
type SilenceLister interface {
// List lists all Silences in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v2beta2.Silence, err error)
// Get retrieves the Silence from the index for a given name.
// Objects returned here must be treated as read-only.
Get(name string) (*v2beta2.Silence, error)
SilenceListerExpansion
}
// silenceLister implements the SilenceLister interface.
type silenceLister struct {
indexer cache.Indexer
}
// NewSilenceLister returns a new SilenceLister.
func NewSilenceLister(indexer cache.Indexer) SilenceLister {
return &silenceLister{indexer: indexer}
}
// List lists all Silences in the indexer.
func (s *silenceLister) List(selector labels.Selector) (ret []*v2beta2.Silence, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v2beta2.Silence))
})
return ret, err
}
// Get retrieves the Silence from the index for a given name.
func (s *silenceLister) Get(name string) (*v2beta2.Silence, error) {
obj, exists, err := s.indexer.GetByKey(name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v2beta2.Resource("silence"), name)
}
return obj.(*v2beta2.Silence), nil
}

View File

@@ -36,14 +36,14 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog"
"kubesphere.io/api/cluster/v1alpha1"
"kubesphere.io/api/notification/v2beta2"
"kubesphere.io/api/types/v1beta1"
"kubesphere.io/api/types/v1beta2"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"kubesphere.io/api/cluster/v1alpha1"
"kubesphere.io/api/notification/v2beta1"
"kubesphere.io/api/types/v1beta1"
"kubesphere.io/kubesphere/pkg/constants"
)
@@ -100,8 +100,10 @@ func (c *Controller) setEventHandlers() error {
if c.reconciledObjs != nil && len(c.reconciledObjs) > 0 {
c.reconciledObjs = c.reconciledObjs[:0]
}
c.reconciledObjs = append(c.reconciledObjs, &v2beta1.Config{})
c.reconciledObjs = append(c.reconciledObjs, &v2beta1.Receiver{})
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{})
if c.informerSynced != nil && len(c.informerSynced) > 0 {
@@ -280,10 +282,14 @@ func (c *Controller) multiClusterSync(ctx context.Context, obj client.Object) er
}
switch obj := obj.(type) {
case *v2beta1.Config:
case *v2beta2.Config:
return c.syncFederatedConfig(obj)
case *v2beta1.Receiver:
case *v2beta2.Receiver:
return c.syncFederatedReceiver(obj)
case *v2beta2.Router:
return c.syncFederatedRouter(obj)
case *v2beta2.Silence:
return c.syncFederatedSilence(obj)
case *corev1.Secret:
return c.syncFederatedSecret(obj)
default:
@@ -292,28 +298,28 @@ func (c *Controller) multiClusterSync(ctx context.Context, obj client.Object) er
}
}
func (c *Controller) syncFederatedConfig(obj *v2beta1.Config) error {
func (c *Controller) syncFederatedConfig(obj *v2beta2.Config) error {
fedObj := &v1beta1.FederatedNotificationConfig{}
fedObj := &v1beta2.FederatedNotificationConfig{}
err := c.Get(context.Background(), client.ObjectKey{Name: obj.Name}, fedObj)
if err != nil {
if errors.IsNotFound(err) {
fedObj = &v1beta1.FederatedNotificationConfig{
fedObj = &v1beta2.FederatedNotificationConfig{
TypeMeta: metav1.TypeMeta{
Kind: v1beta1.FederatedNotificationConfigKind,
APIVersion: v1beta1.SchemeGroupVersion.String(),
Kind: v1beta2.FederatedNotificationConfigKind,
APIVersion: v1beta2.SchemeGroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: obj.Name,
},
Spec: v1beta1.FederatedNotificationConfigSpec{
Template: v1beta1.NotificationConfigTemplate{
Spec: v1beta2.FederatedNotificationConfigSpec{
Template: v1beta2.NotificationConfigTemplate{
ObjectMeta: metav1.ObjectMeta{
Labels: obj.Labels,
},
Spec: obj.Spec,
},
Placement: v1beta1.GenericPlacementFields{
Placement: v1beta2.GenericPlacementFields{
ClusterSelector: &metav1.LabelSelector{},
},
},
@@ -350,28 +356,28 @@ func (c *Controller) syncFederatedConfig(obj *v2beta1.Config) error {
return nil
}
func (c *Controller) syncFederatedReceiver(obj *v2beta1.Receiver) error {
func (c *Controller) syncFederatedReceiver(obj *v2beta2.Receiver) error {
fedObj := &v1beta1.FederatedNotificationReceiver{}
fedObj := &v1beta2.FederatedNotificationReceiver{}
err := c.Get(context.Background(), client.ObjectKey{Name: obj.Name}, fedObj)
if err != nil {
if errors.IsNotFound(err) {
fedObj = &v1beta1.FederatedNotificationReceiver{
fedObj = &v1beta2.FederatedNotificationReceiver{
TypeMeta: metav1.TypeMeta{
Kind: v1beta1.FederatedNotificationReceiverKind,
APIVersion: v1beta1.SchemeGroupVersion.String(),
Kind: v1beta2.FederatedNotificationReceiverKind,
APIVersion: v1beta2.SchemeGroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: obj.Name,
},
Spec: v1beta1.FederatedNotificationReceiverSpec{
Template: v1beta1.NotificationReceiverTemplate{
Spec: v1beta2.FederatedNotificationReceiverSpec{
Template: v1beta2.NotificationReceiverTemplate{
ObjectMeta: metav1.ObjectMeta{
Labels: obj.Labels,
},
Spec: obj.Spec,
},
Placement: v1beta1.GenericPlacementFields{
Placement: v1beta2.GenericPlacementFields{
ClusterSelector: &metav1.LabelSelector{},
},
},
@@ -408,6 +414,122 @@ func (c *Controller) syncFederatedReceiver(obj *v2beta1.Receiver) error {
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{}

View File

@@ -26,20 +26,19 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
k8sinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
fakek8s "k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/kubernetes/scheme"
"kubesphere.io/api/cluster/v1alpha1"
"kubesphere.io/api/notification/v2beta2"
"kubesphere.io/api/types/v1beta1"
"kubesphere.io/api/types/v1beta2"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
"kubesphere.io/api/cluster/v1alpha1"
"kubesphere.io/api/notification/v2beta1"
"kubesphere.io/api/types/v1beta1"
k8sinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes/scheme"
"kubesphere.io/kubesphere/pkg/apis"
"kubesphere.io/kubesphere/pkg/constants"
)
@@ -52,12 +51,13 @@ func TestSource(t *testing.T) {
var (
_ = Describe("Secret", func() {
v2beta1.AddToScheme(scheme.Scheme)
apis.AddToScheme(scheme.Scheme)
_ = v2beta2.AddToScheme(scheme.Scheme)
_ = apis.AddToScheme(scheme.Scheme)
_ = v1beta2.AddToScheme(scheme.Scheme)
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Name: "secret-foo",
Namespace: constants.NotificationSecretNamespace,
Labels: map[string]string{
constants.NotificationManagedLabel: "true",
@@ -65,24 +65,39 @@ var (
},
}
config := &v2beta1.Config{
config := &v2beta2.Config{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Name: "config-foo",
Labels: map[string]string{
"type": "global",
},
},
}
receiver := &v2beta1.Receiver{
receiver := &v2beta2.Receiver{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Name: "receiver-foo",
Labels: map[string]string{
"type": "default",
},
},
}
router := &v2beta2.Router{
ObjectMeta: metav1.ObjectMeta{
Name: "router-foo",
},
}
silence := &v2beta2.Silence{
ObjectMeta: metav1.ObjectMeta{
Name: "silence-foo",
Labels: map[string]string{
"type": "global",
},
},
}
host := &v1alpha1.Cluster{
ObjectMeta: metav1.ObjectMeta{
Name: "host",
@@ -144,7 +159,7 @@ var (
Expect(cl.Create(context.Background(), config)).Should(Succeed())
Expect(r.reconcile(config)).Should(Succeed())
fedConfig := &v1beta1.FederatedNotificationConfig{}
fedConfig := &v1beta2.FederatedNotificationConfig{}
By("Expecting to create federated object successfully")
err = ksCache.Get(context.Background(), client.ObjectKey{Name: config.Name}, fedConfig)
Expect(err).Should(Succeed())
@@ -166,7 +181,7 @@ var (
Expect(cl.Create(context.Background(), receiver)).Should(Succeed())
Expect(r.reconcile(receiver)).Should(Succeed())
fedReceiver := &v1beta1.FederatedNotificationReceiver{}
fedReceiver := &v1beta2.FederatedNotificationReceiver{}
By("Expecting to create federated object successfully")
err = ksCache.Get(context.Background(), client.ObjectKey{Name: receiver.Name}, fedReceiver)
Expect(err).Should(Succeed())
@@ -185,6 +200,52 @@ var (
Expect(err).Should(Succeed())
Expect(fedReceiver.Spec.Template.Labels["foo"]).Should(Equal("bar"))
// Create a router
Expect(cl.Create(context.Background(), router)).Should(Succeed())
Expect(r.reconcile(router)).Should(Succeed())
fedRouter := &v1beta2.FederatedNotificationRouter{}
By("Expecting to create federated object successfully")
err = ksCache.Get(context.Background(), client.ObjectKey{Name: router.Name}, fedRouter)
Expect(err).Should(Succeed())
Expect(fedRouter.Name).Should(Equal(router.Name))
// Update a receiver
err = ksCache.Get(context.Background(), client.ObjectKey{Name: router.Name}, router)
Expect(err).Should(Succeed())
router.Labels = map[string]string{"foo": "bar"}
Expect(cl.Update(context.Background(), router)).Should(Succeed())
Expect(r.reconcile(router)).Should(Succeed())
By("Expecting to update federated object successfully")
err = ksCache.Get(context.Background(), client.ObjectKey{Name: router.Name}, fedRouter)
Expect(err).Should(Succeed())
Expect(fedRouter.Spec.Template.Labels["foo"]).Should(Equal("bar"))
// Create a receiver
Expect(cl.Create(context.Background(), silence)).Should(Succeed())
Expect(r.reconcile(silence)).Should(Succeed())
fedSilence := &v1beta2.FederatedNotificationSilence{}
By("Expecting to create federated object successfully")
err = ksCache.Get(context.Background(), client.ObjectKey{Name: silence.Name}, fedSilence)
Expect(err).Should(Succeed())
Expect(fedSilence.Name).Should(Equal(silence.Name))
// Update a receiver
err = ksCache.Get(context.Background(), client.ObjectKey{Name: silence.Name}, silence)
Expect(err).Should(Succeed())
silence.Labels = map[string]string{"foo": "bar"}
Expect(cl.Update(context.Background(), silence)).Should(Succeed())
Expect(r.reconcile(silence)).Should(Succeed())
By("Expecting to update federated object successfully")
err = ksCache.Get(context.Background(), client.ObjectKey{Name: silence.Name}, fedSilence)
Expect(err).Should(Succeed())
Expect(fedSilence.Spec.Template.Labels["foo"]).Should(Equal("bar"))
// Add a cluster
Expect(cl.Create(informerCacheCtx, host)).Should(Succeed())
Expect(r.reconcile(secret)).Should(Succeed())
@@ -220,24 +281,24 @@ type fakeCache struct {
}
// GetInformerForKind returns the informer for the GroupVersionKind
func (f *fakeCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind) (cache.Informer, error) {
func (f *fakeCache) GetInformerForKind(_ context.Context, _ schema.GroupVersionKind) (cache.Informer, error) {
return nil, nil
}
// GetInformer returns the informer for the obj
func (f *fakeCache) GetInformer(ctx context.Context, obj client.Object) (cache.Informer, error) {
func (f *fakeCache) GetInformer(_ context.Context, _ client.Object) (cache.Informer, error) {
fakeInformerFactory := k8sinformers.NewSharedInformerFactory(f.K8sClient, defaultResync)
return fakeInformerFactory.Core().V1().Namespaces().Informer(), nil
}
func (f *fakeCache) IndexField(ctx context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error {
func (f *fakeCache) IndexField(_ context.Context, _ client.Object, _ string, _ client.IndexerFunc) error {
return nil
}
func (f *fakeCache) Start(ctx context.Context) error {
func (f *fakeCache) Start(_ context.Context) error {
return nil
}
func (f *fakeCache) WaitForCacheSync(ctx context.Context) bool {
func (f *fakeCache) WaitForCacheSync(_ context.Context) bool {
return true
}

View File

@@ -40,7 +40,7 @@ func newNotificationHandler(
ksClient kubesphere.Interface) *handler {
return &handler{
operator: notification.NewOperator(informers, k8sClient, ksClient),
operator: notification.NewOperator(informers, k8sClient, ksClient, nil),
}
}
@@ -51,12 +51,12 @@ func (h *handler) ListResource(req *restful.Request, resp *restful.Response) {
subresource := req.QueryParameter("type")
q := query.ParseQueryParameter(req)
if !h.operator.IsKnownResource(resource, subresource) {
if !h.operator.IsKnownResource(resource, notification.V2beta1, subresource) {
api.HandleBadRequest(resp, req, servererr.New("unknown resource type %s/%s", resource, subresource))
return
}
objs, err := h.operator.List(user, resource, subresource, q)
objs, err := h.operator.ListV2beta1(user, resource, subresource, q)
handleResponse(req, resp, objs, err)
}
@@ -67,12 +67,12 @@ func (h *handler) GetResource(req *restful.Request, resp *restful.Response) {
name := req.PathParameter("name")
subresource := req.QueryParameter("type")
if !h.operator.IsKnownResource(resource, subresource) {
if !h.operator.IsKnownResource(resource, notification.V2beta1, subresource) {
api.HandleBadRequest(resp, req, servererr.New("unknown resource type %s/%s", resource, subresource))
return
}
obj, err := h.operator.Get(user, resource, name, subresource)
obj, err := h.operator.GetV2beta1(user, resource, name, subresource)
handleResponse(req, resp, obj, err)
}
@@ -81,18 +81,18 @@ func (h *handler) CreateResource(req *restful.Request, resp *restful.Response) {
user := req.PathParameter("user")
resource := req.PathParameter("resources")
if !h.operator.IsKnownResource(resource, "") {
if !h.operator.IsKnownResource(resource, notification.V2beta1, "") {
api.HandleBadRequest(resp, req, servererr.New("unknown resource type %s", resource))
return
}
obj := h.operator.GetObject(resource)
obj := h.operator.GetObject(resource, notification.V2beta1)
if err := req.ReadEntity(obj); err != nil {
api.HandleBadRequest(resp, req, err)
return
}
created, err := h.operator.Create(user, resource, obj)
created, err := h.operator.CreateV2beta1(user, resource, obj)
handleResponse(req, resp, created, err)
}
@@ -102,18 +102,18 @@ func (h *handler) UpdateResource(req *restful.Request, resp *restful.Response) {
resource := req.PathParameter("resources")
name := req.PathParameter("name")
if !h.operator.IsKnownResource(resource, "") {
if !h.operator.IsKnownResource(resource, notification.V2beta1, "") {
api.HandleBadRequest(resp, req, servererr.New("unknown resource type %s", resource))
return
}
obj := h.operator.GetObject(resource)
obj := h.operator.GetObject(resource, notification.V2beta1)
if err := req.ReadEntity(obj); err != nil {
api.HandleBadRequest(resp, req, err)
return
}
updated, err := h.operator.Update(user, resource, name, obj)
updated, err := h.operator.UpdateV2beta1(user, resource, name, obj)
handleResponse(req, resp, updated, err)
}
@@ -123,12 +123,12 @@ func (h *handler) DeleteResource(req *restful.Request, resp *restful.Response) {
resource := req.PathParameter("resources")
name := req.PathParameter("name")
if !h.operator.IsKnownResource(resource, "") {
if !h.operator.IsKnownResource(resource, notification.V2beta1, "") {
api.HandleBadRequest(resp, req, servererr.New("unknown resource type %s", resource))
return
}
handleResponse(req, resp, servererr.None, h.operator.Delete(user, resource, name))
handleResponse(req, resp, servererr.None, h.operator.DeleteV2beta1(user, resource, name))
}
func handleResponse(req *restful.Request, resp *restful.Response, obj interface{}, err error) {

View File

@@ -53,6 +53,7 @@ func AddToContainer(
// apis for global notification config, receiver, and secret
ws.Route(ws.GET("/{resources}").
Deprecate().
To(h.ListResource).
Doc("list the notification configs or receivers").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
@@ -67,6 +68,7 @@ func AddToContainer(
Returns(http.StatusOK, api.StatusOK, api.ListResult{Items: []interface{}{}}))
ws.Route(ws.GET("/{resources}/{name}").
Deprecate().
To(h.GetResource).
Doc("get the specified notification config or receiver").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
@@ -76,6 +78,7 @@ func AddToContainer(
Returns(http.StatusOK, api.StatusOK, nil))
ws.Route(ws.POST("/{resources}").
Deprecate().
To(h.CreateResource).
Doc("create a notification config or receiver").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
@@ -83,6 +86,7 @@ func AddToContainer(
Returns(http.StatusOK, api.StatusOK, nil))
ws.Route(ws.PUT("/{resources}/{name}").
Deprecate().
To(h.UpdateResource).
Doc("update the specified notification config or receiver").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
@@ -91,6 +95,7 @@ func AddToContainer(
Returns(http.StatusOK, api.StatusOK, nil))
ws.Route(ws.DELETE("/{resources}/{name}").
Deprecate().
To(h.DeleteResource).
Doc("delete the specified notification config or receiver").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
@@ -100,6 +105,7 @@ func AddToContainer(
// apis for tenant notification config and receiver
ws.Route(ws.GET("/users/{user}/{resources}").
Deprecate().
To(h.ListResource).
Doc("list the notification configs or receivers").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
@@ -115,6 +121,7 @@ func AddToContainer(
Returns(http.StatusOK, api.StatusOK, api.ListResult{Items: []interface{}{}}))
ws.Route(ws.GET("/users/{user}/{resources}/{name}").
Deprecate().
To(h.GetResource).
Doc("get the specified notification config or receiver").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
@@ -125,6 +132,7 @@ func AddToContainer(
Returns(http.StatusOK, api.StatusOK, nil))
ws.Route(ws.POST("/users/{user}/{resources}").
Deprecate().
To(h.CreateResource).
Doc("create the specified notification config or receiver").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
@@ -133,6 +141,7 @@ func AddToContainer(
Returns(http.StatusOK, api.StatusOK, nil))
ws.Route(ws.PUT("/users/{user}/{resources}/{name}").
Deprecate().
To(h.UpdateResource).
Doc("update the specified notification config or receiver").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
@@ -142,6 +151,7 @@ func AddToContainer(
Returns(http.StatusOK, api.StatusOK, nil))
ws.Route(ws.DELETE("/users/{user}/{resources}/{name}").
Deprecate().
To(h.DeleteResource).
Doc("delete the specified notification config or receiver").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).

View File

@@ -12,117 +12,144 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
package v2beta2
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"github.com/emicklei/go-restful"
"kubesphere.io/api/notification/v2beta2"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/kubernetes"
"k8s.io/klog"
nm "kubesphere.io/kubesphere/pkg/simple/client/notification"
)
const (
VerificationAPIPath = "/api/v2/verify"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
kubesphere "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
"kubesphere.io/kubesphere/pkg/informers"
nmoperator "kubesphere.io/kubesphere/pkg/models/notification"
servererr "kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/simple/client/notification"
)
type handler struct {
option *nm.Options
operator nmoperator.Operator
}
type Result struct {
Code int `json:"Status"`
Message string `json:"Message"`
}
type notification struct {
Config v2beta2.Config `json:"config"`
Receiver v2beta2.Receiver `json:"receiver"`
}
func newNotificationHandler(
informers informers.InformerFactory,
k8sClient kubernetes.Interface,
ksClient kubesphere.Interface,
options *notification.Options) *handler {
func newHandler(option *nm.Options) *handler {
return &handler{
option,
operator: nmoperator.NewOperator(informers, k8sClient, ksClient, options),
}
}
func (h handler) Verify(request *restful.Request, response *restful.Response) {
opt := h.option
if opt == nil || len(opt.Endpoint) == 0 {
response.WriteAsJson(Result{
http.StatusBadRequest,
"Cannot find Notification Manager endpoint",
})
}
host := opt.Endpoint
notification := notification{}
reqBody, err := ioutil.ReadAll(request.Request.Body)
if err != nil {
response.WriteHeaderAndEntity(http.StatusInternalServerError, err)
func (h *handler) ListResource(req *restful.Request, resp *restful.Response) {
user := req.PathParameter("user")
resource := req.PathParameter("resources")
subresource := req.QueryParameter("type")
q := query.ParseQueryParameter(req)
if !h.operator.IsKnownResource(resource, nmoperator.V2beta2, subresource) {
api.HandleBadRequest(resp, req, servererr.New("unknown resource type %s/%s", resource, subresource))
return
}
err = json.Unmarshal(reqBody, &notification)
if err != nil {
response.WriteHeaderAndEntity(http.StatusInternalServerError, err)
return
}
receiver := notification.Receiver
user := request.PathParameter("user")
if receiver.Labels["type"] == "tenant" {
if user != receiver.Labels["user"] {
response.WriteAsJson(Result{
http.StatusForbidden,
"Permission denied",
})
return
}
}
if receiver.Labels["type"] == "global" {
if user != "" {
response.WriteAsJson(Result{
http.StatusForbidden,
"Permission denied",
})
return
}
}
req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", host, VerificationAPIPath), bytes.NewReader(reqBody))
if err != nil {
response.WriteHeaderAndEntity(http.StatusInternalServerError, err)
return
}
req.Header = request.Request.Header
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
response.WriteHeaderAndEntity(http.StatusInternalServerError, err)
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
// return 500
response.WriteHeaderAndEntity(http.StatusInternalServerError, err)
return
}
var result Result
err = json.Unmarshal(body, &result)
if err != nil {
response.WriteHeaderAndEntity(http.StatusInternalServerError, err)
return
}
response.WriteAsJson(result)
objs, err := h.operator.List(user, resource, subresource, q)
handleResponse(req, resp, objs, err)
}
func (h *handler) GetResource(req *restful.Request, resp *restful.Response) {
user := req.PathParameter("user")
resource := req.PathParameter("resources")
name := req.PathParameter("name")
subresource := req.QueryParameter("type")
if !h.operator.IsKnownResource(resource, nmoperator.V2beta2, subresource) {
api.HandleBadRequest(resp, req, servererr.New("unknown resource type %s/%s", resource, subresource))
return
}
obj, err := h.operator.Get(user, resource, name, subresource)
handleResponse(req, resp, obj, err)
}
func (h *handler) CreateResource(req *restful.Request, resp *restful.Response) {
user := req.PathParameter("user")
resource := req.PathParameter("resources")
if !h.operator.IsKnownResource(resource, nmoperator.V2beta2, "") {
api.HandleBadRequest(resp, req, servererr.New("unknown resource type %s", resource))
return
}
obj := h.operator.GetObject(resource, nmoperator.V2beta2)
if err := req.ReadEntity(obj); err != nil {
api.HandleBadRequest(resp, req, err)
return
}
created, err := h.operator.Create(user, resource, obj)
handleResponse(req, resp, created, err)
}
func (h *handler) UpdateResource(req *restful.Request, resp *restful.Response) {
user := req.PathParameter("user")
resource := req.PathParameter("resources")
name := req.PathParameter("name")
if !h.operator.IsKnownResource(resource, nmoperator.V2beta2, "") {
api.HandleBadRequest(resp, req, servererr.New("unknown resource type %s", resource))
return
}
obj := h.operator.GetObject(resource, nmoperator.V2beta2)
if err := req.ReadEntity(obj); err != nil {
api.HandleBadRequest(resp, req, err)
return
}
updated, err := h.operator.Update(user, resource, name, obj)
handleResponse(req, resp, updated, err)
}
func (h *handler) DeleteResource(req *restful.Request, resp *restful.Response) {
user := req.PathParameter("user")
resource := req.PathParameter("resources")
name := req.PathParameter("name")
if !h.operator.IsKnownResource(resource, nmoperator.V2beta2, "") {
api.HandleBadRequest(resp, req, servererr.New("unknown resource type %s", resource))
return
}
handleResponse(req, resp, servererr.None, h.operator.Delete(user, resource, name))
}
func (h *handler) Verify(req *restful.Request, resp *restful.Response) {
h.operator.Verify(req, resp)
}
func handleResponse(req *restful.Request, resp *restful.Response, obj interface{}, err error) {
if err != nil {
klog.Error(err)
if errors.IsNotFound(err) {
api.HandleNotFound(resp, req, err)
return
} else if errors.IsConflict(err) {
api.HandleConflict(resp, req, err)
return
}
api.HandleBadRequest(resp, req, err)
return
}
_ = resp.WriteEntity(obj)
}

View File

@@ -21,20 +21,38 @@ package v2beta2
import (
"net/http"
nm "kubesphere.io/kubesphere/pkg/simple/client/notification"
"github.com/emicklei/go-restful"
openapi "github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
kubesphere "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/simple/client/notification"
)
var GroupVersion = schema.GroupVersion{Group: "notification.kubesphere.io", Version: "v2beta2"}
const (
GroupName = "notification.kubesphere.io"
KeyOpenAPITags = openapi.KeyOpenAPITags
)
var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v2beta2"}
func AddToContainer(
container *restful.Container,
informers informers.InformerFactory,
k8sClient kubernetes.Interface,
ksClient kubesphere.Interface,
options *notification.Options) error {
func AddToContainer(container *restful.Container, option *nm.Options) error {
h := newHandler(option)
ws := runtime.NewWebService(GroupVersion)
h := newNotificationHandler(informers, k8sClient, ksClient, options)
ws.Route(ws.POST("/configs/notification/verification").
Reads("").
To(h.Verify).
@@ -45,6 +63,106 @@ func AddToContainer(container *restful.Container, option *nm.Options) error {
Param(ws.PathParameter("user", "user name")).
Returns(http.StatusOK, api.StatusOK, http.Response{}.Body)).
Doc("Provide validation for notification-manager information")
// apis for global notification config, receiver, and secret
ws.Route(ws.GET("/{resources}").
To(h.ListResource).
Doc("list the notification configs or receivers").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences")).
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)).
Param(ws.QueryParameter(query.ParameterPage, "page").Required(false).DataFormat("page=%d").DefaultValue("page=1")).
Param(ws.QueryParameter(query.ParameterLimit, "limit").Required(false)).
Param(ws.QueryParameter(query.ParameterAscending, "sort parameters, e.g. ascending=false").Required(false).DefaultValue("ascending=false")).
Param(ws.QueryParameter(query.ParameterOrderBy, "sort parameters, e.g. orderBy=createTime")).
Returns(http.StatusOK, api.StatusOK, api.ListResult{Items: []interface{}{}}))
ws.Route(ws.GET("/{resources}/{name}").
To(h.GetResource).
Doc("get the specified notification config or receiver").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences")).
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").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences")).
Returns(http.StatusOK, api.StatusOK, nil))
ws.Route(ws.PUT("/{resources}/{name}").
To(h.UpdateResource).
Doc("update the specified notification config or receiver").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences")).
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").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, routers, silences")).
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").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
Param(ws.PathParameter("user", "user name")).
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences")).
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)).
Param(ws.QueryParameter(query.ParameterPage, "page").Required(false).DataFormat("page=%d").DefaultValue("page=1")).
Param(ws.QueryParameter(query.ParameterLimit, "limit").Required(false)).
Param(ws.QueryParameter(query.ParameterAscending, "sort parameters, e.g. ascending=false").Required(false).DefaultValue("ascending=false")).
Param(ws.QueryParameter(query.ParameterOrderBy, "sort parameters, e.g. orderBy=createTime")).
Returns(http.StatusOK, api.StatusOK, api.ListResult{Items: []interface{}{}}))
ws.Route(ws.GET("/users/{user}/{resources}/{name}").
To(h.GetResource).
Doc("get the specified notification config or receiver").
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(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").
Metadata(KeyOpenAPITags, []string{constants.NotificationTag}).
Param(ws.PathParameter("user", "user name")).
Param(ws.PathParameter("resources", "known values include configs, receivers, secrets, silences")).
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").
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(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").
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(query.ParameterName, "the name of the resource")).
Returns(http.StatusOK, api.StatusOK, errors.None))
container.Add(ws)
return nil
}

View File

@@ -12,13 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
package notification
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"reflect"
"github.com/emicklei/go-restful"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
@@ -26,8 +33,8 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes"
"k8s.io/klog"
"kubesphere.io/api/notification/v2beta1"
"kubesphere.io/api/notification/v2beta2"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
@@ -35,21 +42,34 @@ import (
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha3/resource"
"kubesphere.io/kubesphere/pkg/simple/client/notification"
)
const (
Secret = "secrets"
Secret = "secrets"
VerificationAPIPath = "/api/v2/verify"
V2beta1 = "v2beta1"
V2beta2 = "v2beta2"
)
type Operator interface {
ListV2beta1(user, resource, subresource string, query *query.Query) (*api.ListResult, error)
GetV2beta1(user, resource, name, subresource string) (runtime.Object, error)
CreateV2beta1(user, resource string, obj runtime.Object) (runtime.Object, error)
DeleteV2beta1(user, resource, name string) error
UpdateV2beta1(user, resource, name string, obj runtime.Object) (runtime.Object, error)
List(user, resource, subresource string, query *query.Query) (*api.ListResult, error)
Get(user, resource, name, subresource string) (runtime.Object, error)
Create(user, resource string, obj runtime.Object) (runtime.Object, error)
Delete(user, resource, name string) error
Update(user, resource, name string, obj runtime.Object) (runtime.Object, error)
GetObject(resource string) runtime.Object
IsKnownResource(resource, subresource string) bool
Verify(request *restful.Request, response *restful.Response)
GetObject(resource, version string) runtime.Object
IsKnownResource(resource, version, subresource string) bool
}
type operator struct {
@@ -57,24 +77,52 @@ type operator struct {
ksClient kubesphere.Interface
informers informers.InformerFactory
resourceGetter *resource.ResourceGetter
options *notification.Options
}
type Data struct {
Config v2beta2.Config `json:"config"`
Receiver v2beta2.Receiver `json:"receiver"`
}
type Result struct {
Code int `json:"Status"`
Message string `json:"Message"`
}
func NewOperator(
informers informers.InformerFactory,
k8sClient kubernetes.Interface,
ksClient kubesphere.Interface) Operator {
ksClient kubesphere.Interface,
options *notification.Options) Operator {
return &operator{
informers: informers,
k8sClient: k8sClient,
ksClient: ksClient,
resourceGetter: resource.NewResourceGetter(informers, nil),
options: options,
}
}
// ListV2beta1 list objects of version v2beta1. Only global objects will be returned if the user is nil.
// If the user is not nil, only tenant objects whose tenant label matches the user will be returned.
func (o *operator) ListV2beta1(user, resource, subresource string, q *query.Query) (*api.ListResult, error) {
return o.list(user, resource, V2beta1, subresource, q)
}
// List objects. Only global objects will be returned if the user is nil.
// If the user is not nil, only tenant objects whose tenant label matches the user will be returned.
func (o *operator) List(user, resource, subresource string, q *query.Query) (*api.ListResult, error) {
return o.list(user, resource, V2beta2, subresource, q)
}
func (o *operator) list(user, resource, version, subresource string, q *query.Query) (*api.ListResult, error) {
if user != "" && resource == v2beta2.ResourcesPluralRouter {
return nil, errors.NewForbidden(v2beta2.Resource(v2beta2.ResourcesPluralRouter), "",
fmt.Errorf("tenant can not list router"))
}
if len(q.LabelSelector) > 0 {
q.LabelSelector = q.LabelSelector + ","
@@ -83,7 +131,7 @@ func (o *operator) List(user, resource, subresource string, q *query.Query) (*ap
filter := ""
// If user is nil, it will list all global object.
if user == "" {
if isConfig(o.GetObject(resource)) {
if isConfig(o.GetObject(resource, version)) {
filter = "type=default"
} else {
filter = "type=global"
@@ -102,6 +150,7 @@ func (o *operator) List(user, resource, subresource string, q *query.Query) (*ap
res, err := o.resourceGetter.List(resource, ns, q)
if err != nil {
klog.Error(err)
return nil, err
}
@@ -113,6 +162,9 @@ func (o *operator) List(user, resource, subresource string, q *query.Query) (*ap
for _, item := range res.Items {
obj := clean(item, resource, subresource)
if obj != nil {
if version == V2beta1 {
obj = convert(obj)
}
results.Items = append(results.Items, obj)
}
}
@@ -121,9 +173,24 @@ func (o *operator) List(user, resource, subresource string, q *query.Query) (*ap
return results, nil
}
// GetV2beta1 get the specified object of version v2beta1, if you want to get a global object, the user must be nil.
// If you want to get a tenant object, the user must equal to the tenant specified in labels of the object.
func (o *operator) GetV2beta1(user, resource, name, subresource string) (runtime.Object, error) {
return o.get(user, resource, V2beta1, name, subresource)
}
// Get the specified object, if you want to get a global object, the user must be nil.
// If you want to get a tenant object, the user must equal to the tenant specified in labels of the object.
func (o *operator) Get(user, resource, name, subresource string) (runtime.Object, error) {
return o.get(user, resource, V2beta2, name, subresource)
}
func (o *operator) get(user, resource, version, name, subresource string) (runtime.Object, error) {
if user != "" && resource == v2beta2.ResourcesPluralRouter {
return nil, errors.NewForbidden(v2beta2.Resource(v2beta2.ResourcesPluralRouter), "",
fmt.Errorf("tenant can not get router"))
}
ns := ""
if resource == Secret {
@@ -132,10 +199,12 @@ func (o *operator) Get(user, resource, name, subresource string) (runtime.Object
obj, err := o.resourceGetter.Get(resource, ns, name)
if err != nil {
klog.Error(err)
return nil, err
}
if err := authorizer(user, obj); err != nil {
klog.Error(err)
return nil, err
}
@@ -148,22 +217,53 @@ func (o *operator) Get(user, resource, name, subresource string) (runtime.Object
return nil, errors.NewNotFound(v2beta1.Resource(obj.GetObjectKind().GroupVersionKind().GroupKind().Kind), name)
}
if version == V2beta1 {
res = convert(res)
}
return res, nil
}
// CreateV2beta1 an object of version v2beta1. A global object will be created if the user is nil.
// A tenant object will be created if the user is not nil.
func (o *operator) CreateV2beta1(user, resource string, obj runtime.Object) (runtime.Object, error) {
return o.create(user, resource, V2beta1, obj)
}
// Create an object. A global object will be created if the user is nil.
// A tenant object will be created if the user is not nil.
func (o *operator) Create(user, resource string, obj runtime.Object) (runtime.Object, error) {
return o.create(user, resource, V2beta2, obj)
}
func (o *operator) create(user, resource, version string, obj runtime.Object) (runtime.Object, error) {
if err := appendLabel(user, resource, obj); err != nil {
return nil, err
}
if user != "" && resource == v2beta2.ResourcesPluralRouter {
return nil, errors.NewForbidden(v2beta2.Resource(v2beta2.ResourcesPluralRouter), "",
fmt.Errorf("tenant can not create router"))
}
switch resource {
case v2beta1.ResourcesPluralConfig:
return o.ksClient.NotificationV2beta1().Configs().Create(context.Background(), obj.(*v2beta1.Config), v1.CreateOptions{})
case v2beta1.ResourcesPluralReceiver:
return o.ksClient.NotificationV2beta1().Receivers().Create(context.Background(), obj.(*v2beta1.Receiver), v1.CreateOptions{})
case v2beta2.ResourcesPluralConfig:
if version == V2beta1 {
return o.ksClient.NotificationV2beta1().Configs().Create(context.Background(), obj.(*v2beta1.Config), v1.CreateOptions{})
} else {
return o.ksClient.NotificationV2beta2().Configs().Create(context.Background(), obj.(*v2beta2.Config), v1.CreateOptions{})
}
case v2beta2.ResourcesPluralReceiver:
if version == V2beta1 {
return o.ksClient.NotificationV2beta1().Receivers().Create(context.Background(), obj.(*v2beta1.Receiver), v1.CreateOptions{})
} else {
return o.ksClient.NotificationV2beta2().Receivers().Create(context.Background(), obj.(*v2beta2.Receiver), v1.CreateOptions{})
}
case v2beta2.ResourcesPluralRouter:
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":
return o.k8sClient.CoreV1().Secrets(constants.NotificationSecretNamespace).Create(context.Background(), obj.(*corev1.Secret), v1.CreateOptions{})
default:
@@ -171,23 +271,44 @@ func (o *operator) Create(user, resource string, obj runtime.Object) (runtime.Ob
}
}
// DeleteV2beta1 an object of version v2beta1. A global object will be deleted if the user is nil.
// If the user is not nil, a tenant object whose tenant label matches the user will be deleted.
func (o *operator) DeleteV2beta1(user, resource, name string) error {
return o.delete(user, resource, name)
}
// Delete an object. A global object will be deleted if the user is nil.
// If the user is not nil, a tenant object whose tenant label matches the user will be deleted.
func (o *operator) Delete(user, resource, name string) error {
return o.delete(user, resource, name)
}
func (o *operator) delete(user, resource, name string) error {
if user != "" && resource == v2beta2.ResourcesPluralRouter {
return errors.NewForbidden(v2beta2.Resource(v2beta2.ResourcesPluralRouter), "",
fmt.Errorf("tenant can not delete router"))
}
if obj, err := o.Get(user, resource, name, ""); err != nil {
klog.Error(err)
return err
} else {
if err := authorizer(user, obj); err != nil {
klog.Error(err)
return err
}
}
switch resource {
case v2beta1.ResourcesPluralConfig:
return o.ksClient.NotificationV2beta1().Configs().Delete(context.Background(), name, v1.DeleteOptions{})
case v2beta1.ResourcesPluralReceiver:
return o.ksClient.NotificationV2beta1().Receivers().Delete(context.Background(), name, v1.DeleteOptions{})
case v2beta2.ResourcesPluralConfig:
return o.ksClient.NotificationV2beta2().Configs().Delete(context.Background(), name, v1.DeleteOptions{})
case v2beta2.ResourcesPluralReceiver:
return o.ksClient.NotificationV2beta2().Receivers().Delete(context.Background(), name, v1.DeleteOptions{})
case v2beta2.ResourcesPluralRouter:
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":
return o.k8sClient.CoreV1().Secrets(constants.NotificationSecretNamespace).Delete(context.Background(), name, v1.DeleteOptions{})
default:
@@ -195,27 +316,56 @@ func (o *operator) Delete(user, resource, name string) error {
}
}
// UpdateV2beta1 an object of version v2beta1, only a global object will be updated if the user is nil.
// If the user is not nil, a tenant object whose tenant label matches the user will be updated.
func (o *operator) UpdateV2beta1(user, resource, name string, obj runtime.Object) (runtime.Object, error) {
return o.update(user, resource, V2beta1, name, obj)
}
// Update an object, only a global object will be updated if the user is nil.
// If the user is not nil, a tenant object whose tenant label matches the user will be updated.
func (o *operator) Update(user, resource, name string, obj runtime.Object) (runtime.Object, error) {
return o.update(user, resource, V2beta2, name, obj)
}
func (o *operator) update(user, resource, version, name string, obj runtime.Object) (runtime.Object, error) {
if user != "" && resource == v2beta2.ResourcesPluralRouter {
return nil, errors.NewForbidden(v2beta2.Resource(v2beta2.ResourcesPluralRouter), "",
fmt.Errorf("tenant can not update router"))
}
if err := appendLabel(user, resource, obj); err != nil {
return nil, err
}
if old, err := o.Get(user, resource, name, ""); err != nil {
klog.Error(err)
return nil, err
} else {
if err := authorizer(user, old); err != nil {
klog.Error(err)
return nil, err
}
}
switch resource {
case v2beta1.ResourcesPluralConfig:
return o.ksClient.NotificationV2beta1().Configs().Update(context.Background(), obj.(*v2beta1.Config), v1.UpdateOptions{})
case v2beta1.ResourcesPluralReceiver:
return o.ksClient.NotificationV2beta1().Receivers().Update(context.Background(), obj.(*v2beta1.Receiver), v1.UpdateOptions{})
case v2beta2.ResourcesPluralConfig:
if version == V2beta1 {
return o.ksClient.NotificationV2beta1().Configs().Update(context.Background(), obj.(*v2beta1.Config), v1.UpdateOptions{})
} else {
return o.ksClient.NotificationV2beta2().Configs().Update(context.Background(), obj.(*v2beta2.Config), v1.UpdateOptions{})
}
case v2beta2.ResourcesPluralReceiver:
if version == V2beta1 {
return o.ksClient.NotificationV2beta1().Receivers().Update(context.Background(), obj.(*v2beta1.Receiver), v1.UpdateOptions{})
} else {
return o.ksClient.NotificationV2beta2().Receivers().Update(context.Background(), obj.(*v2beta2.Receiver), v1.UpdateOptions{})
}
case v2beta2.ResourcesPluralRouter:
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":
return o.k8sClient.CoreV1().Secrets(constants.NotificationSecretNamespace).Update(context.Background(), obj.(*corev1.Secret), v1.UpdateOptions{})
default:
@@ -223,13 +373,31 @@ func (o *operator) Update(user, resource, name string, obj runtime.Object) (runt
}
}
func (o *operator) GetObject(resource string) runtime.Object {
func (o *operator) GetObject(resource, version string) runtime.Object {
switch resource {
case v2beta1.ResourcesPluralConfig:
return &v2beta1.Config{}
case v2beta1.ResourcesPluralReceiver:
return &v2beta1.Receiver{}
case v2beta2.ResourcesPluralConfig:
if version == V2beta1 {
return &v2beta1.Config{}
} else {
return &v2beta2.Config{}
}
case v2beta2.ResourcesPluralReceiver:
if version == V2beta1 {
return &v2beta1.Receiver{}
} else {
return &v2beta2.Receiver{}
}
case v2beta2.ResourcesPluralRouter:
if version == V2beta1 {
return nil
}
return &v2beta2.Router{}
case v2beta2.ResourcesPluralSilence:
if version == V2beta1 {
return nil
}
return &v2beta2.Silence{}
case Secret:
return &corev1.Secret{}
default:
@@ -237,36 +405,105 @@ func (o *operator) GetObject(resource string) runtime.Object {
}
}
func (o *operator) IsKnownResource(resource, subresource string) bool {
func (o *operator) IsKnownResource(resource, version, subresource string) bool {
if obj := o.GetObject(resource); obj == nil {
if obj := o.GetObject(resource, version); obj == nil {
return false
}
res := false
// "" means get all types of the config or receiver.
if subresource != "dingtalk" &&
subresource != "email" &&
subresource != "slack" &&
subresource != "webhook" &&
subresource != "wechat" &&
subresource != "" {
return false
if subresource == "dingtalk" ||
subresource == "email" ||
subresource == "slack" ||
subresource == "webhook" ||
subresource == "wechat" ||
subresource == "" {
res = true
}
return true
if version == V2beta2 && subresource == "feishu" {
res = true
}
return res
}
func (o *operator) Verify(request *restful.Request, response *restful.Response) {
if o.options == nil || len(o.options.Endpoint) == 0 {
_ = response.WriteAsJson(Result{
http.StatusInternalServerError,
"Cannot find Notification Manager endpoint",
})
return
}
reqBody, err := ioutil.ReadAll(request.Request.Body)
if err != nil {
klog.Error(err)
_ = response.WriteHeaderAndEntity(http.StatusBadRequest, err)
return
}
data := Data{}
err = json.Unmarshal(reqBody, &data)
if err != nil {
_ = response.WriteHeaderAndEntity(http.StatusBadRequest, err)
return
}
receiver := data.Receiver
user := request.PathParameter("user")
if err := authorizer(user, &receiver); err != nil {
klog.Error(err)
_ = response.WriteHeaderAndEntity(http.StatusBadRequest, err)
return
}
req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", o.options.Endpoint, VerificationAPIPath), bytes.NewReader(reqBody))
if err != nil {
klog.Error(err)
_ = response.WriteHeaderAndEntity(http.StatusInternalServerError, err)
return
}
req.Header = request.Request.Header
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
klog.Error(err)
_ = response.WriteHeaderAndEntity(http.StatusInternalServerError, err)
return
}
defer func() {
_ = resp.Body.Close()
}()
body, err := io.ReadAll(resp.Body)
if err != nil {
klog.Error(err)
// return 500
_ = response.WriteHeaderAndEntity(http.StatusInternalServerError, err)
return
}
response.AddHeader(restful.HEADER_ContentType, restful.MIME_JSON)
response.WriteHeader(http.StatusOK)
_, _ = response.Write(body)
}
// Does the user has permission to access this object.
func authorizer(user string, obj runtime.Object) error {
// If the user is not nil, it must equal to the tenant specified in labels of the object.
if user != "" && !isOwner(user, obj) {
return errors.NewForbidden(v2beta1.Resource(obj.GetObjectKind().GroupVersionKind().GroupKind().Kind), "",
return errors.NewForbidden(v2beta2.Resource(obj.GetObjectKind().GroupVersionKind().GroupKind().Kind), "",
fmt.Errorf("user '%s' is not the owner of object", user))
}
// If the user is nil, the object must be a global object.
if user == "" && !isGlobal(obj) {
return errors.NewForbidden(v2beta1.Resource(obj.GetObjectKind().GroupVersionKind().GroupKind().Kind), "",
return errors.NewForbidden(v2beta2.Resource(obj.GetObjectKind().GroupVersionKind().GroupKind().Kind), "",
fmt.Errorf("object is not a global object"))
}
@@ -282,12 +519,12 @@ func isOwner(user string, obj interface{}) bool {
return false
}
return accessor.GetLabels()["user"] == user
return accessor.GetLabels()["user"] == user && accessor.GetLabels()["type"] == "tenant"
}
func isConfig(obj runtime.Object) bool {
switch obj.(type) {
case *v2beta1.Config:
case *v2beta1.Config, *v2beta2.Config:
return true
default:
return false
@@ -342,15 +579,17 @@ func appendLabel(user, resource string, obj runtime.Object) error {
}
func clean(obj interface{}, resource, subresource string) runtime.Object {
if resource == v2beta1.ResourcesPluralConfig {
config := obj.(*v2beta1.Config)
if resource == v2beta2.ResourcesPluralConfig {
config := obj.(*v2beta2.Config)
newConfig := config.DeepCopy()
newConfig.Spec = v2beta1.ConfigSpec{}
newConfig.Spec = v2beta2.ConfigSpec{}
switch subresource {
case "dingtalk":
newConfig.Spec.DingTalk = config.Spec.DingTalk
case "email":
newConfig.Spec.Email = config.Spec.Email
case "feishu":
newConfig.Spec.Feishu = config.Spec.Feishu
case "slack":
newConfig.Spec.Slack = config.Spec.Slack
case "webhook":
@@ -366,15 +605,17 @@ func clean(obj interface{}, resource, subresource string) runtime.Object {
}
return newConfig
} else {
receiver := obj.(*v2beta1.Receiver)
} else if resource == v2beta2.ResourcesPluralReceiver {
receiver := obj.(*v2beta2.Receiver)
newReceiver := receiver.DeepCopy()
newReceiver.Spec = v2beta1.ReceiverSpec{}
newReceiver.Spec = v2beta2.ReceiverSpec{}
switch subresource {
case "dingtalk":
newReceiver.Spec.DingTalk = receiver.Spec.DingTalk
case "email":
newReceiver.Spec.Email = receiver.Spec.Email
case "feishu":
newReceiver.Spec.Feishu = receiver.Spec.Feishu
case "slack":
newReceiver.Spec.Slack = receiver.Spec.Slack
case "webhook":
@@ -390,5 +631,22 @@ func clean(obj interface{}, resource, subresource string) runtime.Object {
}
return newReceiver
} else {
return obj.(runtime.Object)
}
}
func convert(obj runtime.Object) runtime.Object {
switch obj := obj.(type) {
case *v2beta2.Config:
dst := &v2beta1.Config{}
_ = obj.ConvertTo(dst)
return dst
case *v2beta2.Receiver:
dst := &v2beta1.Receiver{}
_ = obj.ConvertTo(dst)
return dst
default:
return obj
}
}

View File

@@ -217,5 +217,5 @@ func prepare() Operator {
_ = fakeInformerFactory.KubernetesSharedInformerFactory().Core().V1().Secrets().Informer().GetIndexer().Add(secret)
}
return NewOperator(fakeInformerFactory, k8sClient, ksClient)
return NewOperator(fakeInformerFactory, k8sClient, ksClient, nil)
}

View File

@@ -37,11 +37,11 @@ func NewNotificationConfigGetter(informer ksinformers.SharedInformerFactory) v1a
}
func (g *configGetter) Get(_, name string) (runtime.Object, error) {
return g.ksInformer.Notification().V2beta1().Configs().Lister().Get(name)
return g.ksInformer.Notification().V2beta2().Configs().Lister().Get(name)
}
func (g *configGetter) List(_ string, query *query.Query) (*api.ListResult, error) {
objs, err := g.ksInformer.Notification().V2beta1().Configs().Lister().List(query.Selector())
objs, err := g.ksInformer.Notification().V2beta2().Configs().Lister().List(query.Selector())
if err != nil {
return nil, err
}
@@ -62,11 +62,61 @@ func NewNotificationReceiverGetter(informer ksinformers.SharedInformerFactory) v
}
func (g *receiverGetter) Get(_, name string) (runtime.Object, error) {
return g.ksInformer.Notification().V2beta1().Receivers().Lister().Get(name)
return g.ksInformer.Notification().V2beta2().Receivers().Lister().Get(name)
}
func (g *receiverGetter) List(_ string, query *query.Query) (*api.ListResult, error) {
objs, err := g.ksInformer.Notification().V2beta1().Receivers().Lister().List(query.Selector())
objs, err := g.ksInformer.Notification().V2beta2().Receivers().Lister().List(query.Selector())
if err != nil {
return nil, err
}
var result []runtime.Object
for _, obj := range objs {
result = append(result, obj)
}
return v1alpha3.DefaultList(result, query, compare, filter), nil
}
type routerGetter struct {
ksInformer ksinformers.SharedInformerFactory
}
func NewNotificationRouterGetter(informer ksinformers.SharedInformerFactory) v1alpha3.Interface {
return &routerGetter{ksInformer: informer}
}
func (g *routerGetter) Get(_, name string) (runtime.Object, error) {
return g.ksInformer.Notification().V2beta2().Routers().Lister().Get(name)
}
func (g *routerGetter) List(_ string, query *query.Query) (*api.ListResult, error) {
objs, err := g.ksInformer.Notification().V2beta2().Routers().Lister().List(query.Selector())
if err != nil {
return nil, err
}
var result []runtime.Object
for _, obj := range objs {
result = append(result, obj)
}
return v1alpha3.DefaultList(result, query, compare, filter), nil
}
type silenceGetter struct {
ksInformer ksinformers.SharedInformerFactory
}
func NewNotificationSilenceGetter(informer ksinformers.SharedInformerFactory) v1alpha3.Interface {
return &silenceGetter{ksInformer: informer}
}
func (g *silenceGetter) Get(_, name string) (runtime.Object, error) {
return g.ksInformer.Notification().V2beta2().Silences().Lister().Get(name)
}
func (g *silenceGetter) List(_ string, query *query.Query) (*api.ListResult, error) {
objs, err := g.ksInformer.Notification().V2beta2().Silences().Lister().List(query.Selector())
if err != nil {
return nil, err
}

View File

@@ -26,8 +26,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/cache"
"kubesphere.io/api/notification/v2beta1"
"kubesphere.io/api/notification/v2beta2"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
@@ -50,11 +49,19 @@ func TestListObjects(t *testing.T) {
}{
{
"test name filter",
v2beta1.ResourcesPluralConfig,
v2beta2.ResourcesPluralConfig,
},
{
"test name filter",
v2beta1.ResourcesPluralReceiver,
v2beta2.ResourcesPluralReceiver,
},
{
"test name filter",
v2beta2.ResourcesPluralRouter,
},
{
"test name filter",
v2beta2.ResourcesPluralSilence,
},
}
@@ -99,14 +106,22 @@ func prepare(key string) (v1alpha3.Interface, []interface{}, error) {
var indexer cache.Indexer
var getter func(informer ksinformers.SharedInformerFactory) v1alpha3.Interface
switch key {
case v2beta1.ResourcesPluralConfig:
indexer = informer.Notification().V2beta1().Configs().Informer().GetIndexer()
case v2beta2.ResourcesPluralConfig:
indexer = informer.Notification().V2beta2().Configs().Informer().GetIndexer()
getter = NewNotificationConfigGetter
obj = &v2beta1.Config{}
case v2beta1.ResourcesPluralReceiver:
indexer = informer.Notification().V2beta1().Receivers().Informer().GetIndexer()
obj = &v2beta2.Config{}
case v2beta2.ResourcesPluralReceiver:
indexer = informer.Notification().V2beta2().Receivers().Informer().GetIndexer()
getter = NewNotificationReceiverGetter
obj = &v2beta1.Receiver{}
obj = &v2beta2.Receiver{}
case v2beta2.ResourcesPluralRouter:
indexer = informer.Notification().V2beta2().Routers().Informer().GetIndexer()
getter = NewNotificationRouterGetter
obj = &v2beta2.Router{}
case v2beta2.ResourcesPluralSilence:
indexer = informer.Notification().V2beta2().Silences().Informer().GetIndexer()
getter = NewNotificationSilenceGetter
obj = &v2beta2.Silence{}
default:
return nil, nil, errors.New("unowned type %s", key)
}

View File

@@ -36,7 +36,7 @@ import (
devopsv1alpha3 "kubesphere.io/api/devops/v1alpha3"
iamv1alpha2 "kubesphere.io/api/iam/v1alpha2"
networkv1alpha1 "kubesphere.io/api/network/v1alpha1"
notificationv2beta1 "kubesphere.io/api/notification/v2beta1"
notificationv2beta2 "kubesphere.io/api/notification/v2beta2"
tenantv1alpha1 "kubesphere.io/api/tenant/v1alpha1"
tenantv1alpha2 "kubesphere.io/api/tenant/v1alpha2"
typesv1beta1 "kubesphere.io/api/types/v1beta1"
@@ -143,8 +143,10 @@ func NewResourceGetter(factory informers.InformerFactory, cache cache.Cache) *Re
clusterResourceGetters[rbacv1.SchemeGroupVersion.WithResource(iamv1alpha2.ResourcesPluralClusterRole)] = clusterrole.New(factory.KubernetesSharedInformerFactory())
clusterResourceGetters[rbacv1.SchemeGroupVersion.WithResource(iamv1alpha2.ResourcesPluralClusterRoleBinding)] = clusterrolebinding.New(factory.KubernetesSharedInformerFactory())
clusterResourceGetters[clusterv1alpha1.SchemeGroupVersion.WithResource(clusterv1alpha1.ResourcesPluralCluster)] = cluster.New(factory.KubeSphereSharedInformerFactory())
clusterResourceGetters[notificationv2beta1.SchemeGroupVersion.WithResource(notificationv2beta1.ResourcesPluralConfig)] = notification.NewNotificationConfigGetter(factory.KubeSphereSharedInformerFactory())
clusterResourceGetters[notificationv2beta1.SchemeGroupVersion.WithResource(notificationv2beta1.ResourcesPluralReceiver)] = notification.NewNotificationReceiverGetter(factory.KubeSphereSharedInformerFactory())
clusterResourceGetters[notificationv2beta2.SchemeGroupVersion.WithResource(notificationv2beta2.ResourcesPluralConfig)] = notification.NewNotificationConfigGetter(factory.KubeSphereSharedInformerFactory())
clusterResourceGetters[notificationv2beta2.SchemeGroupVersion.WithResource(notificationv2beta2.ResourcesPluralReceiver)] = notification.NewNotificationReceiverGetter(factory.KubeSphereSharedInformerFactory())
clusterResourceGetters[notificationv2beta2.SchemeGroupVersion.WithResource(notificationv2beta2.ResourcesPluralRouter)] = notification.NewNotificationRouterGetter(factory.KubeSphereSharedInformerFactory())
clusterResourceGetters[notificationv2beta2.SchemeGroupVersion.WithResource(notificationv2beta2.ResourcesPluralSilence)] = notification.NewNotificationSilenceGetter(factory.KubeSphereSharedInformerFactory())
clusterResourceGetters[monitoringdashboardv1alpha2.GroupVersion.WithResource("clusterdashboards")] = clusterdashboard.New(cache)
// federated resources