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

@@ -10,6 +10,7 @@ require (
github.com/go-openapi/spec v0.19.7
github.com/onsi/gomega v1.15.0
github.com/projectcalico/libcalico-go v1.7.2-0.20191014160346-2382c6cdd056
github.com/robfig/cron/v3 v3.0.1
golang.org/x/net v0.0.0-20210525063256-abc453219eb5
istio.io/api v0.0.0-20201113182140-d4b7e3fc2b44
k8s.io/api v0.21.2

View File

@@ -454,6 +454,8 @@ github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3x
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=

View File

@@ -138,7 +138,8 @@ type ConfigStatus struct {
// +kubebuilder:subresource:status
// +genclient
// +genclient:nonNamespaced
// DingTalkConfig is the Schema for the dingtalkconfigs API
// Config is the Schema for the configs API
type Config struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -159,3 +160,5 @@ type ConfigList struct {
func init() {
SchemeBuilder.Register(&Config{}, &ConfigList{})
}
func (_ *Config) Hub() {}

View File

@@ -195,3 +195,5 @@ type ReceiverList struct {
func init() {
SchemeBuilder.Register(&Receiver{}, &ReceiverList{})
}
func (_ *Receiver) Hub() {}

View File

@@ -0,0 +1,340 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v2beta2
import (
"kubesphere.io/api/notification/v2beta1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
// ConvertTo converts this Config to the Hub version (v2beta1).
func (src *Config) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v2beta1.Config)
dst.ObjectMeta = src.ObjectMeta
if err := src.convertDingTalkTo(dst); err != nil {
return err
}
if err := src.convertEmailTo(dst); err != nil {
return err
}
if err := src.convertSlackTo(dst); err != nil {
return err
}
if err := src.convertWebhookTo(dst); err != nil {
return err
}
if err := src.convertWechatTo(dst); err != nil {
return err
}
return nil
}
// ConvertFrom converts from the Hub version (v2beta1) to this version.
func (dst *Config) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*v2beta1.Config)
dst.ObjectMeta = src.ObjectMeta
if err := dst.convertDingTalkFrom(src); err != nil {
return err
}
if err := dst.convertEmailFrom(src); err != nil {
return err
}
if err := dst.convertSlackFrom(src); err != nil {
return err
}
if err := dst.convertWebhookFrom(src); err != nil {
return err
}
if err := dst.convertWechatFrom(src); err != nil {
return err
}
return nil
}
func (src *Config) convertDingTalkTo(dst *v2beta1.Config) error {
if src.Spec.DingTalk == nil {
return nil
}
dingtalk := src.Spec.DingTalk
dst.Spec.DingTalk = &v2beta1.DingTalkConfig{
Labels: dingtalk.Labels,
}
if dingtalk.Conversation != nil {
dst.Spec.DingTalk.Conversation = &v2beta1.DingTalkApplicationConfig{
AppKey: credentialToSecretKeySelector(dingtalk.Conversation.AppKey),
AppSecret: credentialToSecretKeySelector(dingtalk.Conversation.AppSecret),
}
}
return nil
}
func (src *Config) convertEmailTo(dst *v2beta1.Config) error {
if src.Spec.Email == nil {
return nil
}
email := src.Spec.Email
dst.Spec.Email = &v2beta1.EmailConfig{
Labels: email.Labels,
From: email.From,
SmartHost: v2beta1.HostPort{
Host: email.SmartHost.Host,
Port: email.SmartHost.Port,
},
Hello: email.Hello,
AuthUsername: email.AuthUsername,
AuthPassword: credentialToSecretKeySelector(email.AuthPassword),
AuthSecret: credentialToSecretKeySelector(email.AuthSecret),
AuthIdentify: email.AuthIdentify,
RequireTLS: email.RequireTLS,
TLS: convertTLSConfigTo(email.TLS),
}
return nil
}
func (src *Config) convertSlackTo(dst *v2beta1.Config) error {
if src.Spec.Slack == nil {
return nil
}
slack := src.Spec.Slack
dst.Spec.Slack = &v2beta1.SlackConfig{
Labels: slack.Labels,
SlackTokenSecret: credentialToSecretKeySelector(slack.SlackTokenSecret),
}
return nil
}
func (src *Config) convertWebhookTo(dst *v2beta1.Config) error {
if src.Spec.Webhook == nil {
return nil
}
dst.Spec.Webhook = &v2beta1.WebhookConfig{
Labels: src.Spec.Webhook.Labels,
}
return nil
}
func (src *Config) convertWechatTo(dst *v2beta1.Config) error {
if src.Spec.Wechat == nil {
return nil
}
wechat := src.Spec.Wechat
dst.Spec.Wechat = &v2beta1.WechatConfig{
Labels: wechat.Labels,
WechatApiUrl: wechat.WechatApiUrl,
WechatApiCorpId: wechat.WechatApiCorpId,
WechatApiAgentId: wechat.WechatApiAgentId,
WechatApiSecret: credentialToSecretKeySelector(wechat.WechatApiSecret),
}
return nil
}
func (dst *Config) convertDingTalkFrom(src *v2beta1.Config) error {
if src.Spec.DingTalk == nil {
return nil
}
dingtalk := src.Spec.DingTalk
dst.Spec.DingTalk = &DingTalkConfig{
Labels: dingtalk.Labels,
}
if dingtalk.Conversation != nil {
dst.Spec.DingTalk.Conversation = &DingTalkApplicationConfig{
AppKey: secretKeySelectorToCredential(dingtalk.Conversation.AppKey),
AppSecret: secretKeySelectorToCredential(dingtalk.Conversation.AppSecret),
}
}
return nil
}
func (dst *Config) convertEmailFrom(src *v2beta1.Config) error {
if src.Spec.Email == nil {
return nil
}
email := src.Spec.Email
dst.Spec.Email = &EmailConfig{
Labels: email.Labels,
From: email.From,
SmartHost: HostPort{
Host: email.SmartHost.Host,
Port: email.SmartHost.Port,
},
Hello: email.Hello,
AuthUsername: email.AuthUsername,
AuthPassword: secretKeySelectorToCredential(email.AuthPassword),
AuthSecret: secretKeySelectorToCredential(email.AuthSecret),
AuthIdentify: email.AuthIdentify,
RequireTLS: email.RequireTLS,
TLS: convertTLSConfigFrom(email.TLS),
}
return nil
}
func (dst *Config) convertSlackFrom(src *v2beta1.Config) error {
if src.Spec.Slack == nil {
return nil
}
slack := src.Spec.Slack
dst.Spec.Slack = &SlackConfig{
Labels: slack.Labels,
SlackTokenSecret: secretKeySelectorToCredential(slack.SlackTokenSecret),
}
return nil
}
func (dst *Config) convertWebhookFrom(src *v2beta1.Config) error {
if src.Spec.Webhook == nil {
return nil
}
dst.Spec.Webhook = &WebhookConfig{
Labels: src.Spec.Webhook.Labels,
}
return nil
}
func (dst *Config) convertWechatFrom(src *v2beta1.Config) error {
if src.Spec.Wechat == nil {
return nil
}
wechat := src.Spec.Wechat
dst.Spec.Wechat = &WechatConfig{
Labels: wechat.Labels,
WechatApiUrl: wechat.WechatApiUrl,
WechatApiCorpId: wechat.WechatApiCorpId,
WechatApiAgentId: wechat.WechatApiAgentId,
WechatApiSecret: secretKeySelectorToCredential(wechat.WechatApiSecret),
}
return nil
}
func convertTLSConfigTo(src *TLSConfig) *v2beta1.TLSConfig {
if src == nil {
return nil
}
dst := &v2beta1.TLSConfig{
RootCA: credentialToSecretKeySelector(src.RootCA),
ServerName: src.ServerName,
InsecureSkipVerify: src.InsecureSkipVerify,
}
if src.ClientCertificate != nil {
dst.ClientCertificate = &v2beta1.ClientCertificate{
Cert: credentialToSecretKeySelector(src.Cert),
Key: credentialToSecretKeySelector(src.Key),
}
}
return dst
}
func convertTLSConfigFrom(src *v2beta1.TLSConfig) *TLSConfig {
if src == nil {
return nil
}
dst := &TLSConfig{
RootCA: secretKeySelectorToCredential(src.RootCA),
ServerName: src.ServerName,
InsecureSkipVerify: src.InsecureSkipVerify,
}
if src.ClientCertificate != nil {
dst.ClientCertificate = &ClientCertificate{
Cert: secretKeySelectorToCredential(src.Cert),
Key: secretKeySelectorToCredential(src.Key),
}
}
return dst
}
func credentialToSecretKeySelector(src *Credential) *v2beta1.SecretKeySelector {
if src == nil || src.ValueFrom == nil || src.ValueFrom.SecretKeyRef == nil {
return nil
}
return &v2beta1.SecretKeySelector{
Key: src.ValueFrom.SecretKeyRef.Key,
Name: src.ValueFrom.SecretKeyRef.Name,
Namespace: src.ValueFrom.SecretKeyRef.Namespace,
}
}
func secretKeySelectorToCredential(selector *v2beta1.SecretKeySelector) *Credential {
if selector == nil {
return nil
}
return &Credential{
ValueFrom: &ValueSource{
SecretKeyRef: &SecretKeySelector{
Key: selector.Key,
Name: selector.Name,
Namespace: selector.Namespace,
},
},
}
}

View File

@@ -147,10 +147,18 @@ type HuaweiSMS struct {
AppKey *Credential `json:"appKey"`
}
// Sms AWS provider parameters
type AWSSMS struct {
Region string `json:"region,omitempty"`
AccessKeyId *Credential `json:"accessKeyId"`
SecretAccessKey *Credential `json:"secretAccessKey"`
}
type Providers struct {
Aliyun *AliyunSMS `json:"aliyun,omitempty"`
Tencent *TencentSMS `json:"tencent,omitempty"`
Huawei *HuaweiSMS `json:"huawei,omitempty"`
AWS *AWSSMS `json:"aws,omitempty"`
}
type SmsConfig struct {
@@ -166,6 +174,14 @@ type PushoverConfig struct {
PushoverTokenSecret *Credential `json:"pushoverTokenSecret"`
}
// FeishuConfig is the configuration of feishu application
type FeishuConfig struct {
// The id of the application with which to send messages.
AppID *Credential `json:"appID"`
// The key in the secret to be used. Must be a valid secret key.
AppSecret *Credential `json:"appSecret"`
}
//ConfigSpec defines the desired state of Config
type ConfigSpec struct {
DingTalk *DingTalkConfig `json:"dingtalk,omitempty"`
@@ -175,6 +191,7 @@ type ConfigSpec struct {
Wechat *WechatConfig `json:"wechat,omitempty"`
Sms *SmsConfig `json:"sms,omitempty"`
Pushover *PushoverConfig `json:"pushover,omitempty"`
Feishu *FeishuConfig `json:"feishu,omitempty"`
}
// ConfigStatus defines the observed state of Config
@@ -185,8 +202,10 @@ type ConfigStatus struct {
// +kubebuilder:resource:scope=Cluster,shortName=nc,categories=notification-manager
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +genclient
// +genclient:nonNamespaced
// Config is the Schema for the dingtalkconfigs API
// Config is the Schema for the configs API
type Config struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

View File

@@ -39,6 +39,18 @@ type SecretKeySelector struct {
Key string `json:"key" protobuf:"bytes,2,opt,name=key"`
}
// ConfigmapKeySelector selects a key of a Configmap.
type ConfigmapKeySelector struct {
// The namespace of the configmap, default to the `defaultSecretNamespace` of `NotificationManager` crd.
// If the `defaultSecretNamespace` does not set, default to the pod's namespace.
// +optional
Namespace string `json:"namespace,omitempty" protobuf:"bytes,1,opt,name=namespace"`
// Name of the configmap.
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
// The key of the configmap to select from. Must be a valid configmap key.
Key string `json:"key,omitempty" protobuf:"bytes,2,opt,name=key"`
}
type ValueSource struct {
// Selects a key of a secret in the pod's namespace
// +optional
@@ -51,7 +63,7 @@ type Credential struct {
ValueFrom *ValueSource `json:"valueFrom,omitempty" protobuf:"bytes,3,opt,name=valueFrom"`
}
// Sidecar defines a sidecar container which will be add to the notification manager deployment pod.
// Sidecar defines a sidecar container which will be added to the notification manager deployment pod.
type Sidecar struct {
// The type of sidecar, it can be specified to any value.
// Notification manager built-in sidecar for KubeSphere,
@@ -61,6 +73,27 @@ type Sidecar struct {
*v1.Container `json:",inline"`
}
// HistoryReceiver used to collect notification history.
type HistoryReceiver struct {
// Use a webhook to collect notification history, it will create a virtual receiver.
Webhook *WebhookReceiver `json:"webhook"`
}
type Template struct {
// Template file.
Text *ConfigmapKeySelector `json:"text,omitempty"`
// Time to reload template file.
//
// +kubebuilder:default="1m"
ReloadCycle metav1.Duration `json:"reloadCycle,omitempty"`
// Configmap which the i18n file be in.
LanguagePack []*ConfigmapKeySelector `json:"languagePack,omitempty"`
// The language used to send notification.
//
// +kubebuilder:default="English"
Language string `json:"language,omitempty"`
}
// NotificationManagerSpec defines the desired state of NotificationManager
type NotificationManagerSpec struct {
// Compute Resources required by container.
@@ -84,7 +117,7 @@ type NotificationManagerSpec struct {
ServiceAccountName string `json:"serviceAccountName,omitempty"`
// Port name used for the pods and service, defaults to webhook
PortName string `json:"portName,omitempty"`
// Default Email/Wechat/Slack/Webhook Config to be selected
// Default Email/WeChat/Slack/Webhook Config to be selected
DefaultConfigSelector *metav1.LabelSelector `json:"defaultConfigSelector,omitempty"`
// Receivers to send notifications to
Receivers *ReceiversSpec `json:"receivers"`
@@ -104,6 +137,30 @@ type NotificationManagerSpec struct {
// It needs to provide the API `/api/v2/tenant` at port `19094`, this api receives
// a parameter `namespace` and return all tenants which need to receive notifications in this namespace.
Sidecars map[string]*Sidecar `json:"sidecars,omitempty"`
// History used to collect notification history.
History *HistoryReceiver `json:"history,omitempty"`
// Labels for grouping notifiations.
GroupLabels []string `json:"groupLabels,omitempty"`
// The maximum size of a batch. A batch used to buffer alerts and asynchronously process them.
//
// +kubebuilder:default=100
BatchMaxSize int `json:"batchMaxSize,omitempty"`
// The amount of time to wait before force processing the batch that hadn't reached the max size.
//
// +kubebuilder:default="1m"
BatchMaxWait metav1.Duration `json:"batchMaxWait,omitempty"`
// The RoutePolicy determines how to find receivers to which notifications will be sent.
// Valid RoutePolicy include All, RouterFirst, and RouterOnly.
// All: The alerts will be sent to the receivers that match any router,
// and also will be sent to the receivers of those tenants with the right to access the namespace to which the alert belongs.
// RouterFirst: The alerts will be sent to the receivers that match any router first.
// If no receivers match any router, alerts will send to the receivers of those tenants with the right to access the namespace to which the alert belongs.
// RouterOnly: The alerts will only be sent to the receivers that match any router.
//
// +kubebuilder:default=All
RoutePolicy string `json:"routePolicy,omitempty"`
// Template used to define information about templates
Template *Template `json:"template,omitempty"`
}
type ReceiversSpec struct {
@@ -121,7 +178,9 @@ type ReceiversSpec struct {
}
type GlobalOptions struct {
// Template file path, must be a absolute path.
// Template file path, must be an absolute path.
//
// Deprecated
TemplateFiles []string `json:"templateFile,omitempty"`
// The name of the template to generate message.
// If the receiver dose not setup template, it will use this.
@@ -149,7 +208,7 @@ type EmailOptions struct {
type WechatOptions struct {
// Notification Sending Timeout
NotificationTimeout *int32 `json:"notificationTimeout,omitempty"`
// The name of the template to generate wechat message.
// The name of the template to generate WeChat message.
Template string `json:"template,omitempty"`
// template type: text or markdown, default type is text
TmplType string `json:"tmplType,omitempty"`
@@ -162,7 +221,7 @@ type WechatOptions struct {
type SlackOptions struct {
// Notification Sending Timeout
NotificationTimeout *int32 `json:"notificationTimeout,omitempty"`
// The name of the template to generate slack message.
// The name of the template to generate Slack message.
// If the global template is not set, it will use default.
Template string `json:"template,omitempty"`
}
@@ -181,7 +240,7 @@ type Throttle struct {
Threshold int `json:"threshold,omitempty"`
Unit time.Duration `json:"unit,omitempty"`
// The maximum tolerable waiting time when the calls trigger flow control, if the actual waiting time is more than this time, it will
// return a error, else it will wait for the flow restriction lifted, and send the message.
// return an error, else it will wait for the flow restriction lifted, and send the message.
// Nil means do not wait, the maximum value is `Unit`.
MaxWaitTime time.Duration `json:"maxWaitTime,omitempty"`
}
@@ -202,9 +261,9 @@ type DingTalkOptions struct {
ConversationMessageMaxSize int `json:"conversationMessageMaxSize,omitempty"`
// The maximum message size that can be sent to chatbot in a request.
ChatbotMessageMaxSize int `json:"chatbotMessageMaxSize,omitempty"`
// The flow control fo chatbot.
// The flow control for chatbot.
ChatBotThrottle *Throttle `json:"chatBotThrottle,omitempty"`
// The flow control fo conversation.
// The flow control for conversation.
ConversationThrottle *Throttle `json:"conversationThrottle,omitempty"`
}
@@ -222,6 +281,20 @@ type PushoverOptions struct {
// The name of the template to generate pushover message.
// If the global template is not set, it will use default.
Template string `json:"template,omitempty"`
// The name of the template to generate message title
TitleTemplate string `json:"titleTemplate,omitempty"`
}
type FeishuOptions struct {
// Notification Sending Timeout
NotificationTimeout *int32 `json:"notificationTimeout,omitempty"`
// The name of the template to generate DingTalk message.
// If the global template is not set, it will use default.
Template string `json:"template,omitempty"`
// template type: text or post, default type is post
TmplType string `json:"tmplType,omitempty"`
// The time of token expired.
TokenExpires time.Duration `json:"tokenExpires,omitempty"`
}
type Options struct {
@@ -233,6 +306,7 @@ type Options struct {
DingTalk *DingTalkOptions `json:"dingtalk,omitempty"`
Sms *SmsOptions `json:"sms,omitempty"`
Pushover *PushoverOptions `json:"pushover,omitempty"`
Feishu *FeishuOptions `json:"feishu,omitempty"`
}
// NotificationManagerStatus defines the observed state of NotificationManager

View File

@@ -0,0 +1,330 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v2beta2
import (
"kubesphere.io/api/notification/v2beta1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
// ConvertTo converts this Config to the Hub version (v2beta1).
func (src *Receiver) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v2beta1.Receiver)
dst.ObjectMeta = src.ObjectMeta
if err := src.convertDingTalkTo(dst); err != nil {
return err
}
if err := src.convertEmailTo(dst); err != nil {
return err
}
if err := src.convertSlackTo(dst); err != nil {
return err
}
if err := src.convertWebhookTo(dst); err != nil {
return err
}
if err := src.convertWechatTo(dst); err != nil {
return err
}
return nil
}
// ConvertFrom converts from the Hub version (v2beta1) to this version.
func (dst *Receiver) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*v2beta1.Receiver)
dst.ObjectMeta = src.ObjectMeta
if err := dst.convertDingTalkFrom(src); err != nil {
return err
}
if err := dst.convertEmailFrom(src); err != nil {
return err
}
if err := dst.convertSlackFrom(src); err != nil {
return err
}
if err := dst.convertWebhookFrom(src); err != nil {
return err
}
if err := dst.convertWechatFrom(src); err != nil {
return err
}
return nil
}
func (src *Receiver) convertDingTalkTo(dst *v2beta1.Receiver) error {
if src.Spec.DingTalk == nil {
return nil
}
dingtalk := src.Spec.DingTalk
dst.Spec.DingTalk = &v2beta1.DingTalkReceiver{
Enabled: dingtalk.Enabled,
DingTalkConfigSelector: dingtalk.DingTalkConfigSelector,
AlertSelector: dingtalk.AlertSelector,
}
if dingtalk.Conversation != nil {
dst.Spec.DingTalk.Conversation = &v2beta1.DingTalkConversation{
ChatIDs: dingtalk.Conversation.ChatIDs,
}
}
if dingtalk.ChatBot != nil {
dst.Spec.DingTalk.ChatBot = &v2beta1.DingTalkChatBot{
Webhook: credentialToSecretKeySelector(dingtalk.ChatBot.Webhook),
Keywords: dingtalk.ChatBot.Keywords,
Secret: credentialToSecretKeySelector(dingtalk.ChatBot.Secret),
}
}
return nil
}
func (src *Receiver) convertEmailTo(dst *v2beta1.Receiver) error {
if src.Spec.Email == nil {
return nil
}
email := src.Spec.Email
dst.Spec.Email = &v2beta1.EmailReceiver{
Enabled: email.Enabled,
To: email.To,
EmailConfigSelector: email.EmailConfigSelector,
AlertSelector: email.AlertSelector,
}
return nil
}
func (src *Receiver) convertSlackTo(dst *v2beta1.Receiver) error {
if src.Spec.Slack == nil {
return nil
}
slack := src.Spec.Slack
dst.Spec.Slack = &v2beta1.SlackReceiver{
Enabled: slack.Enabled,
SlackConfigSelector: slack.SlackConfigSelector,
AlertSelector: slack.AlertSelector,
Channels: slack.Channels,
}
return nil
}
func (src *Receiver) convertWebhookTo(dst *v2beta1.Receiver) error {
if src.Spec.Webhook == nil {
return nil
}
webhook := src.Spec.Webhook
dst.Spec.Webhook = &v2beta1.WebhookReceiver{
Enabled: webhook.Enabled,
WebhookConfigSelector: webhook.WebhookConfigSelector,
AlertSelector: webhook.AlertSelector,
URL: webhook.URL,
}
if webhook.Service != nil {
dst.Spec.Webhook.Service = &v2beta1.ServiceReference{
Namespace: webhook.Service.Namespace,
Name: webhook.Service.Name,
Path: webhook.Service.Path,
Port: webhook.Service.Port,
Scheme: webhook.Service.Scheme,
}
}
if webhook.HTTPConfig != nil {
dst.Spec.Webhook.HTTPConfig = &v2beta1.HTTPClientConfig{
BearerToken: credentialToSecretKeySelector(webhook.HTTPConfig.BearerToken),
ProxyURL: webhook.HTTPConfig.ProxyURL,
TLSConfig: convertTLSConfigTo(webhook.HTTPConfig.TLSConfig),
}
if webhook.HTTPConfig.BasicAuth != nil {
dst.Spec.Webhook.HTTPConfig.BasicAuth = &v2beta1.BasicAuth{
Username: webhook.HTTPConfig.BasicAuth.Username,
Password: credentialToSecretKeySelector(webhook.HTTPConfig.BasicAuth.Password),
}
}
}
return nil
}
func (src *Receiver) convertWechatTo(dst *v2beta1.Receiver) error {
if src.Spec.Wechat == nil {
return nil
}
wechat := src.Spec.Wechat
dst.Spec.Wechat = &v2beta1.WechatReceiver{
Enabled: wechat.Enabled,
WechatConfigSelector: wechat.WechatConfigSelector,
AlertSelector: wechat.AlertSelector,
ToUser: wechat.ToUser,
ToParty: wechat.ToParty,
ToTag: wechat.ToTag,
}
return nil
}
func (dst *Receiver) convertDingTalkFrom(src *v2beta1.Receiver) error {
if src.Spec.DingTalk == nil {
return nil
}
dingtalk := src.Spec.DingTalk
dst.Spec.DingTalk = &DingTalkReceiver{
Enabled: dingtalk.Enabled,
DingTalkConfigSelector: dingtalk.DingTalkConfigSelector,
AlertSelector: dingtalk.AlertSelector,
}
if dingtalk.Conversation != nil {
dst.Spec.DingTalk.Conversation = &DingTalkConversation{
ChatIDs: dingtalk.Conversation.ChatIDs,
}
}
if dingtalk.ChatBot != nil {
dst.Spec.DingTalk.ChatBot = &DingTalkChatBot{
Webhook: secretKeySelectorToCredential(dingtalk.ChatBot.Webhook),
Keywords: dingtalk.ChatBot.Keywords,
Secret: secretKeySelectorToCredential(dingtalk.ChatBot.Secret),
}
}
return nil
}
func (dst *Receiver) convertEmailFrom(src *v2beta1.Receiver) error {
if src.Spec.Email == nil {
return nil
}
email := src.Spec.Email
dst.Spec.Email = &EmailReceiver{
Enabled: email.Enabled,
To: email.To,
EmailConfigSelector: email.EmailConfigSelector,
AlertSelector: email.AlertSelector,
}
return nil
}
func (dst *Receiver) convertSlackFrom(src *v2beta1.Receiver) error {
if src.Spec.Slack == nil {
return nil
}
slack := src.Spec.Slack
dst.Spec.Slack = &SlackReceiver{
Enabled: slack.Enabled,
SlackConfigSelector: slack.SlackConfigSelector,
AlertSelector: slack.AlertSelector,
Channels: slack.Channels,
}
return nil
}
func (dst *Receiver) convertWebhookFrom(src *v2beta1.Receiver) error {
if src.Spec.Webhook == nil {
return nil
}
webhook := src.Spec.Webhook
dst.Spec.Webhook = &WebhookReceiver{
Enabled: webhook.Enabled,
WebhookConfigSelector: webhook.WebhookConfigSelector,
AlertSelector: webhook.AlertSelector,
URL: webhook.URL,
}
if webhook.Service != nil {
dst.Spec.Webhook.Service = &ServiceReference{
Namespace: webhook.Service.Namespace,
Name: webhook.Service.Name,
Path: webhook.Service.Path,
Port: webhook.Service.Port,
Scheme: webhook.Service.Scheme,
}
}
if webhook.HTTPConfig != nil {
dst.Spec.Webhook.HTTPConfig = &HTTPClientConfig{
BearerToken: secretKeySelectorToCredential(webhook.HTTPConfig.BearerToken),
ProxyURL: webhook.HTTPConfig.ProxyURL,
TLSConfig: convertTLSConfigFrom(webhook.HTTPConfig.TLSConfig),
}
if webhook.HTTPConfig.BasicAuth != nil {
dst.Spec.Webhook.HTTPConfig.BasicAuth = &BasicAuth{
Username: webhook.HTTPConfig.BasicAuth.Username,
Password: secretKeySelectorToCredential(webhook.HTTPConfig.BasicAuth.Password),
}
}
}
return nil
}
func (dst *Receiver) convertWechatFrom(src *v2beta1.Receiver) error {
if src.Spec.Wechat == nil {
return nil
}
wechat := src.Spec.Wechat
dst.Spec.Wechat = &WechatReceiver{
Enabled: wechat.Enabled,
WechatConfigSelector: wechat.WechatConfigSelector,
AlertSelector: wechat.AlertSelector,
ToUser: wechat.ToUser,
ToParty: wechat.ToParty,
ToTag: wechat.ToTag,
}
return nil
}

View File

@@ -54,13 +54,15 @@ type DingTalkReceiver struct {
ChatBot *DingTalkChatBot `json:"chatbot,omitempty"`
// The conversation which message will send to.
Conversation *DingTalkConversation `json:"conversation,omitempty"`
// The name of the template to generate DingTalk message.
// The name of the template to generate notification.
// If the global template is not set, it will use default.
Template *string `json:"template,omitempty"`
// The name of the template to generate markdown title
TitleTemplate *string `json:"titleTemplate,omitempty"`
// template type: text or markdown
TmplType *string `json:"tmplType,omitempty"`
// Template file.
TmplText *ConfigmapKeySelector `json:"tmplText,omitempty"`
}
type EmailReceiver struct {
@@ -72,13 +74,15 @@ type EmailReceiver struct {
EmailConfigSelector *metav1.LabelSelector `json:"emailConfigSelector,omitempty"`
// Selector to filter alerts.
AlertSelector *metav1.LabelSelector `json:"alertSelector,omitempty"`
// The name of the template to generate DingTalk message.
// The name of the template to generate notification.
// If the global template is not set, it will use default.
Template *string `json:"template,omitempty"`
// The name of the template to generate email subject
SubjectTemplate *string `json:"subjectTemplate,omitempty"`
// template type: text or html, default type is html
TmplType *string `json:"tmplType,omitempty"`
// Template file.
TmplText *ConfigmapKeySelector `json:"tmplText,omitempty"`
}
type SlackReceiver struct {
@@ -90,9 +94,11 @@ type SlackReceiver struct {
AlertSelector *metav1.LabelSelector `json:"alertSelector,omitempty"`
// The channel or user to send notifications to.
Channels []string `json:"channels"`
// The name of the template to generate DingTalk message.
// The name of the template to generate notification.
// If the global template is not set, it will use default.
Template *string `json:"template,omitempty"`
// Template file.
TmplText *ConfigmapKeySelector `json:"tmplText,omitempty"`
}
// ServiceReference holds a reference to Service.legacy.k8s.io
@@ -164,9 +170,11 @@ type WebhookReceiver struct {
Service *ServiceReference `json:"service,omitempty"`
HTTPConfig *HTTPClientConfig `json:"httpConfig,omitempty"`
// The name of the template to generate DingTalk message.
// The name of the template to generate notification.
// If the global template is not set, it will use default.
Template *string `json:"template,omitempty"`
// Template file.
TmplText *ConfigmapKeySelector `json:"tmplText,omitempty"`
}
type WechatReceiver struct {
@@ -180,11 +188,13 @@ type WechatReceiver struct {
ToUser []string `json:"toUser,omitempty"`
ToParty []string `json:"toParty,omitempty"`
ToTag []string `json:"toTag,omitempty"`
// The name of the template to generate DingTalk message.
// The name of the template to generate notification.
// If the global template is not set, it will use default.
Template *string `json:"template,omitempty"`
// template type: text or markdown, default type is text
TmplType *string `json:"tmplType,omitempty"`
// Template file.
TmplText *ConfigmapKeySelector `json:"tmplText,omitempty"`
}
type SmsReceiver struct {
@@ -196,9 +206,11 @@ type SmsReceiver struct {
AlertSelector *metav1.LabelSelector `json:"alertSelector,omitempty"`
// Receivers' phone numbers
PhoneNumbers []string `json:"phoneNumbers"`
// The name of the template to generate Sms message.
// The name of the template to generate notification.
// If the global template is not set, it will use default.
Template *string `json:"template,omitempty"`
// Template file.
TmplText *ConfigmapKeySelector `json:"tmplText,omitempty"`
}
// PushoverUserProfile includes userKey and other preferences
@@ -209,6 +221,9 @@ type PushoverUserProfile struct {
// Devices refers to device name to send the message directly to that device, rather than all of the user's devices
Devices []string `json:"devices,omitempty"`
// Title refers to message's title, otherwise your app's name is used.
// it is deprecated, now the title will be generated by the title template.
//
// Deprecated
Title *string `json:"title,omitempty"`
// Sound refers to the name of one of the sounds (https://pushover.net/api#sounds) supported by device clients
Sound *string `json:"sound,omitempty"`
@@ -221,11 +236,50 @@ type PushoverReceiver struct {
PushoverConfigSelector *metav1.LabelSelector `json:"pushoverConfigSelector,omitempty"`
// Selector to filter alerts.
AlertSelector *metav1.LabelSelector `json:"alertSelector,omitempty"`
// The name of the template to generate DingTalk message.
// The name of the template to generate notification.
// If the global template is not set, it will use default.
Template *string `json:"template,omitempty"`
// The name of the template to generate message title
TitleTemplate *string `json:"titleTemplate,omitempty"`
// The users profile.
Profiles []*PushoverUserProfile `json:"profiles"`
// Template file.
TmplText *ConfigmapKeySelector `json:"tmplText,omitempty"`
}
// FeishuChatBot is the configuration of ChatBot
type FeishuChatBot struct {
// The webhook of the ChatBot to which the message will be sent.
Webhook *Credential `json:"webhook"`
// Custom keywords of ChatBot
Keywords []string `json:"keywords,omitempty"`
// Secret of ChatBot, you can get it after enabling signature verification of ChatBot.
Secret *Credential `json:"secret,omitempty"`
}
type FeishuReceiver struct {
// whether the receiver is enabled
Enabled *bool `json:"enabled,omitempty"`
// FeishuConfig to be selected for this receiver
FeishuConfigSelector *metav1.LabelSelector `json:"feishuConfigSelector,omitempty"`
// Selector to filter alerts.
AlertSelector *metav1.LabelSelector `json:"alertSelector,omitempty"`
// +optional
// +kubebuilder:validation:MaxItems=200
User []string `json:"user,omitempty"`
// +optional
// +kubebuilder:validation:MaxItems=200
Department []string `json:"department,omitempty"`
ChatBot *FeishuChatBot `json:"chatbot,omitempty"`
// The name of the template to generate notification.
// If the global template is not set, it will use default.
Template *string `json:"template,omitempty"`
// template type: text or post, default type is post
TmplType *string `json:"tmplType,omitempty"`
// Template file.
TmplText *ConfigmapKeySelector `json:"tmplText,omitempty"`
}
//ReceiverSpec defines the desired state of Receiver
@@ -237,6 +291,7 @@ type ReceiverSpec struct {
Wechat *WechatReceiver `json:"wechat,omitempty"`
Sms *SmsReceiver `json:"sms,omitempty"`
Pushover *PushoverReceiver `json:"pushover,omitempty"`
Feishu *FeishuReceiver `json:"feishu,omitempty"`
}
// ReceiverStatus defines the observed state of Receiver
@@ -247,7 +302,8 @@ type ReceiverStatus struct {
// +kubebuilder:resource:scope=Cluster,shortName=nr,categories=notification-manager
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +genclient
// +genclient:nonNamespaced
// Receiver is the Schema for the receivers API
type Receiver struct {
metav1.TypeMeta `json:",inline"`

View File

@@ -15,7 +15,7 @@ limitations under the License.
*/
// Package v2beta2 contains API Schema definitions for the notification v1alpha1 API group
// +kubebuilder:object:generate=true
// +k8s:deepcopy-gen=package,register
// +groupName=notification.kubesphere.io
package v2beta2
@@ -26,15 +26,15 @@ import (
var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "notification.kubesphere.io", Version: "v2beta2"}
SchemeGroupVersion = schema.GroupVersion{Group: "notification.kubesphere.io", Version: "v2beta2"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
func Resource(resource string) schema.GroupResource {
return GroupVersion.WithResource(resource).GroupResource()
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

View File

@@ -0,0 +1,70 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v2beta2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type ReceiverSelector struct {
Name []string `json:"name,omitempty"`
RegexName string `json:"regexName,omitempty"`
Selector *metav1.LabelSelector `json:"selector,omitempty"`
// Receiver type, known values are dingtalk, email, slack, sms, pushover, webhook, wechat.
Type string `json:"type,omitempty"`
}
// RouterSpec defines the desired state of Router
type RouterSpec struct {
// whether the router is enabled
Enabled *bool `json:"enabled,omitempty"`
AlertSelector *metav1.LabelSelector `json:"alertSelector"`
// Receivers which need to receive the matched alert.
Receivers ReceiverSelector `json:"receivers"`
}
// RouterStatus defines the observed state of Router
type RouterStatus struct {
}
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster,categories=notification-manager
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +genclient
// +genclient:nonNamespaced
// Router is the Schema for the router API
type Router struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec RouterSpec `json:"spec,omitempty"`
Status RouterStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// RouterList contains a list of Router
type RouterList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Router `json:"items"`
}
func init() {
SchemeBuilder.Register(&Router{}, &RouterList{})
}

View File

@@ -0,0 +1,111 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v2beta2
import (
"time"
"github.com/robfig/cron/v3"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// SilenceSpec defines the desired state of Silence
type SilenceSpec struct {
// whether the silence is enabled
Enabled *bool `json:"enabled,omitempty"`
Matcher *metav1.LabelSelector `json:"matcher"`
// The start time during which the silence is active.
//
// +kubebuilder:validation:Format: date-time
StartsAt *metav1.Time `json:"startsAt,omitempty"`
// The schedule in Cron format.
// If set the silence will be active periodicity, and the startsAt will be invalid.
Schedule string `json:"schedule,omitempty"`
// The time range during which the silence is active.
// If not set, the silence will be active ever.
Duration *metav1.Duration `json:"duration,omitempty"`
}
// SilenceStatus defines the observed state of Silence
type SilenceStatus struct {
}
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster,categories=notification-manager
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +genclient
// +genclient:nonNamespaced
// Silence is the Schema for the Silence API
type Silence struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec SilenceSpec `json:"spec,omitempty"`
Status SilenceStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// SilenceList contains a list of Silence
type SilenceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Silence `json:"items"`
}
func init() {
SchemeBuilder.Register(&Silence{}, &SilenceList{})
}
func (s *Silence) IsActive() bool {
if s.Spec.Enabled != nil && !*s.Spec.Enabled {
return false
}
if s.Spec.Schedule != "" {
if s.Spec.Duration == nil {
return true
}
schedule, _ := cron.ParseStandard(s.Spec.Schedule)
if schedule.Next(time.Now()) == schedule.Next(time.Now().Add(-(*s.Spec.Duration).Duration)) {
return false
} else {
return true
}
} else if s.Spec.StartsAt != nil {
if s.Spec.StartsAt.After(time.Now()) {
return false
}
if s.Spec.Duration == nil {
return true
}
if s.Spec.StartsAt.Add((*s.Spec.Duration).Duration).After(time.Now()) {
return true
}
return false
} else {
return true
}
}

View File

@@ -24,4 +24,12 @@ const (
ResourceKindReceiver = "Receiver"
ResourcesSingularReceiver = "receiver"
ResourcesPluralReceiver = "receivers"
ResourceKindRouter = "Router"
ResourcesSingularRouter = "router"
ResourcesPluralRouter = "routers"
ResourceKindSilence = "Silence"
ResourcesSingularSilence = "silence"
ResourcesPluralSilence = "silences"
)

View File

@@ -26,6 +26,31 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AWSSMS) DeepCopyInto(out *AWSSMS) {
*out = *in
if in.AccessKeyId != nil {
in, out := &in.AccessKeyId, &out.AccessKeyId
*out = new(Credential)
(*in).DeepCopyInto(*out)
}
if in.SecretAccessKey != nil {
in, out := &in.SecretAccessKey, &out.SecretAccessKey
*out = new(Credential)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSSMS.
func (in *AWSSMS) DeepCopy() *AWSSMS {
if in == nil {
return nil
}
out := new(AWSSMS)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AliyunSMS) DeepCopyInto(out *AliyunSMS) {
*out = *in
@@ -193,6 +218,11 @@ func (in *ConfigSpec) DeepCopyInto(out *ConfigSpec) {
*out = new(PushoverConfig)
(*in).DeepCopyInto(*out)
}
if in.Feishu != nil {
in, out := &in.Feishu, &out.Feishu
*out = new(FeishuConfig)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigSpec.
@@ -220,6 +250,21 @@ func (in *ConfigStatus) DeepCopy() *ConfigStatus {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ConfigmapKeySelector) DeepCopyInto(out *ConfigmapKeySelector) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigmapKeySelector.
func (in *ConfigmapKeySelector) DeepCopy() *ConfigmapKeySelector {
if in == nil {
return nil
}
out := new(ConfigmapKeySelector)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Credential) DeepCopyInto(out *Credential) {
*out = *in
@@ -425,6 +470,11 @@ func (in *DingTalkReceiver) DeepCopyInto(out *DingTalkReceiver) {
*out = new(string)
**out = **in
}
if in.TmplText != nil {
in, out := &in.TmplText, &out.TmplText
*out = new(ConfigmapKeySelector)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DingTalkReceiver.
@@ -553,6 +603,11 @@ func (in *EmailReceiver) DeepCopyInto(out *EmailReceiver) {
*out = new(string)
**out = **in
}
if in.TmplText != nil {
in, out := &in.TmplText, &out.TmplText
*out = new(ConfigmapKeySelector)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EmailReceiver.
@@ -565,6 +620,141 @@ func (in *EmailReceiver) DeepCopy() *EmailReceiver {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FeishuChatBot) DeepCopyInto(out *FeishuChatBot) {
*out = *in
if in.Webhook != nil {
in, out := &in.Webhook, &out.Webhook
*out = new(Credential)
(*in).DeepCopyInto(*out)
}
if in.Keywords != nil {
in, out := &in.Keywords, &out.Keywords
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.Secret != nil {
in, out := &in.Secret, &out.Secret
*out = new(Credential)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeishuChatBot.
func (in *FeishuChatBot) DeepCopy() *FeishuChatBot {
if in == nil {
return nil
}
out := new(FeishuChatBot)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FeishuConfig) DeepCopyInto(out *FeishuConfig) {
*out = *in
if in.AppID != nil {
in, out := &in.AppID, &out.AppID
*out = new(Credential)
(*in).DeepCopyInto(*out)
}
if in.AppSecret != nil {
in, out := &in.AppSecret, &out.AppSecret
*out = new(Credential)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeishuConfig.
func (in *FeishuConfig) DeepCopy() *FeishuConfig {
if in == nil {
return nil
}
out := new(FeishuConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FeishuOptions) DeepCopyInto(out *FeishuOptions) {
*out = *in
if in.NotificationTimeout != nil {
in, out := &in.NotificationTimeout, &out.NotificationTimeout
*out = new(int32)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeishuOptions.
func (in *FeishuOptions) DeepCopy() *FeishuOptions {
if in == nil {
return nil
}
out := new(FeishuOptions)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FeishuReceiver) DeepCopyInto(out *FeishuReceiver) {
*out = *in
if in.Enabled != nil {
in, out := &in.Enabled, &out.Enabled
*out = new(bool)
**out = **in
}
if in.FeishuConfigSelector != nil {
in, out := &in.FeishuConfigSelector, &out.FeishuConfigSelector
*out = new(metav1.LabelSelector)
(*in).DeepCopyInto(*out)
}
if in.AlertSelector != nil {
in, out := &in.AlertSelector, &out.AlertSelector
*out = new(metav1.LabelSelector)
(*in).DeepCopyInto(*out)
}
if in.User != nil {
in, out := &in.User, &out.User
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.Department != nil {
in, out := &in.Department, &out.Department
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.ChatBot != nil {
in, out := &in.ChatBot, &out.ChatBot
*out = new(FeishuChatBot)
(*in).DeepCopyInto(*out)
}
if in.Template != nil {
in, out := &in.Template, &out.Template
*out = new(string)
**out = **in
}
if in.TmplType != nil {
in, out := &in.TmplType, &out.TmplType
*out = new(string)
**out = **in
}
if in.TmplText != nil {
in, out := &in.TmplText, &out.TmplText
*out = new(ConfigmapKeySelector)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeishuReceiver.
func (in *FeishuReceiver) DeepCopy() *FeishuReceiver {
if in == nil {
return nil
}
out := new(FeishuReceiver)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GlobalOptions) DeepCopyInto(out *GlobalOptions) {
*out = *in
@@ -615,6 +805,26 @@ func (in *HTTPClientConfig) DeepCopy() *HTTPClientConfig {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HistoryReceiver) DeepCopyInto(out *HistoryReceiver) {
*out = *in
if in.Webhook != nil {
in, out := &in.Webhook, &out.Webhook
*out = new(WebhookReceiver)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HistoryReceiver.
func (in *HistoryReceiver) DeepCopy() *HistoryReceiver {
if in == nil {
return nil
}
out := new(HistoryReceiver)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HostPort) DeepCopyInto(out *HostPort) {
*out = *in
@@ -796,6 +1006,22 @@ func (in *NotificationManagerSpec) DeepCopyInto(out *NotificationManagerSpec) {
(*out)[key] = outVal
}
}
if in.History != nil {
in, out := &in.History, &out.History
*out = new(HistoryReceiver)
(*in).DeepCopyInto(*out)
}
if in.GroupLabels != nil {
in, out := &in.GroupLabels, &out.GroupLabels
*out = make([]string, len(*in))
copy(*out, *in)
}
out.BatchMaxWait = in.BatchMaxWait
if in.Template != nil {
in, out := &in.Template, &out.Template
*out = new(Template)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotificationManagerSpec.
@@ -866,6 +1092,11 @@ func (in *Options) DeepCopyInto(out *Options) {
*out = new(PushoverOptions)
(*in).DeepCopyInto(*out)
}
if in.Feishu != nil {
in, out := &in.Feishu, &out.Feishu
*out = new(FeishuOptions)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Options.
@@ -896,6 +1127,11 @@ func (in *Providers) DeepCopyInto(out *Providers) {
*out = new(HuaweiSMS)
(*in).DeepCopyInto(*out)
}
if in.AWS != nil {
in, out := &in.AWS, &out.AWS
*out = new(AWSSMS)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Providers.
@@ -978,6 +1214,11 @@ func (in *PushoverReceiver) DeepCopyInto(out *PushoverReceiver) {
*out = new(string)
**out = **in
}
if in.TitleTemplate != nil {
in, out := &in.TitleTemplate, &out.TitleTemplate
*out = new(string)
**out = **in
}
if in.Profiles != nil {
in, out := &in.Profiles, &out.Profiles
*out = make([]*PushoverUserProfile, len(*in))
@@ -989,6 +1230,11 @@ func (in *PushoverReceiver) DeepCopyInto(out *PushoverReceiver) {
}
}
}
if in.TmplText != nil {
in, out := &in.TmplText, &out.TmplText
*out = new(ConfigmapKeySelector)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PushoverReceiver.
@@ -1095,6 +1341,31 @@ func (in *ReceiverList) DeepCopyObject() runtime.Object {
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ReceiverSelector) DeepCopyInto(out *ReceiverSelector) {
*out = *in
if in.Name != nil {
in, out := &in.Name, &out.Name
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.Selector != nil {
in, out := &in.Selector, &out.Selector
*out = new(metav1.LabelSelector)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReceiverSelector.
func (in *ReceiverSelector) DeepCopy() *ReceiverSelector {
if in == nil {
return nil
}
out := new(ReceiverSelector)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ReceiverSpec) DeepCopyInto(out *ReceiverSpec) {
*out = *in
@@ -1133,6 +1404,11 @@ func (in *ReceiverSpec) DeepCopyInto(out *ReceiverSpec) {
*out = new(PushoverReceiver)
(*in).DeepCopyInto(*out)
}
if in.Feishu != nil {
in, out := &in.Feishu, &out.Feishu
*out = new(FeishuReceiver)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReceiverSpec.
@@ -1190,6 +1466,106 @@ func (in *ReceiversSpec) DeepCopy() *ReceiversSpec {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Router) DeepCopyInto(out *Router) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Router.
func (in *Router) DeepCopy() *Router {
if in == nil {
return nil
}
out := new(Router)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Router) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RouterList) DeepCopyInto(out *RouterList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Router, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouterList.
func (in *RouterList) DeepCopy() *RouterList {
if in == nil {
return nil
}
out := new(RouterList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *RouterList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RouterSpec) DeepCopyInto(out *RouterSpec) {
*out = *in
if in.Enabled != nil {
in, out := &in.Enabled, &out.Enabled
*out = new(bool)
**out = **in
}
if in.AlertSelector != nil {
in, out := &in.AlertSelector, &out.AlertSelector
*out = new(metav1.LabelSelector)
(*in).DeepCopyInto(*out)
}
in.Receivers.DeepCopyInto(&out.Receivers)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouterSpec.
func (in *RouterSpec) DeepCopy() *RouterSpec {
if in == nil {
return nil
}
out := new(RouterSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RouterStatus) DeepCopyInto(out *RouterStatus) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouterStatus.
func (in *RouterStatus) DeepCopy() *RouterStatus {
if in == nil {
return nil
}
out := new(RouterStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SecretKeySelector) DeepCopyInto(out *SecretKeySelector) {
*out = *in
@@ -1255,6 +1631,114 @@ func (in *Sidecar) DeepCopy() *Sidecar {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Silence) DeepCopyInto(out *Silence) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Silence.
func (in *Silence) DeepCopy() *Silence {
if in == nil {
return nil
}
out := new(Silence)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Silence) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SilenceList) DeepCopyInto(out *SilenceList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Silence, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SilenceList.
func (in *SilenceList) DeepCopy() *SilenceList {
if in == nil {
return nil
}
out := new(SilenceList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *SilenceList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SilenceSpec) DeepCopyInto(out *SilenceSpec) {
*out = *in
if in.Enabled != nil {
in, out := &in.Enabled, &out.Enabled
*out = new(bool)
**out = **in
}
if in.Matcher != nil {
in, out := &in.Matcher, &out.Matcher
*out = new(metav1.LabelSelector)
(*in).DeepCopyInto(*out)
}
if in.StartsAt != nil {
in, out := &in.StartsAt, &out.StartsAt
*out = (*in).DeepCopy()
}
if in.Duration != nil {
in, out := &in.Duration, &out.Duration
*out = new(metav1.Duration)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SilenceSpec.
func (in *SilenceSpec) DeepCopy() *SilenceSpec {
if in == nil {
return nil
}
out := new(SilenceSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SilenceStatus) DeepCopyInto(out *SilenceStatus) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SilenceStatus.
func (in *SilenceStatus) DeepCopy() *SilenceStatus {
if in == nil {
return nil
}
out := new(SilenceStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SlackConfig) DeepCopyInto(out *SlackConfig) {
*out = *in
@@ -1330,6 +1814,11 @@ func (in *SlackReceiver) DeepCopyInto(out *SlackReceiver) {
*out = new(string)
**out = **in
}
if in.TmplText != nil {
in, out := &in.TmplText, &out.TmplText
*out = new(ConfigmapKeySelector)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SlackReceiver.
@@ -1410,6 +1899,11 @@ func (in *SmsReceiver) DeepCopyInto(out *SmsReceiver) {
*out = new(string)
**out = **in
}
if in.TmplText != nil {
in, out := &in.TmplText, &out.TmplText
*out = new(ConfigmapKeySelector)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SmsReceiver.
@@ -1447,6 +1941,38 @@ func (in *TLSConfig) DeepCopy() *TLSConfig {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Template) DeepCopyInto(out *Template) {
*out = *in
if in.Text != nil {
in, out := &in.Text, &out.Text
*out = new(ConfigmapKeySelector)
**out = **in
}
out.ReloadCycle = in.ReloadCycle
if in.LanguagePack != nil {
in, out := &in.LanguagePack, &out.LanguagePack
*out = make([]*ConfigmapKeySelector, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(ConfigmapKeySelector)
**out = **in
}
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Template.
func (in *Template) DeepCopy() *Template {
if in == nil {
return nil
}
out := new(Template)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TencentSMS) DeepCopyInto(out *TencentSMS) {
*out = *in
@@ -1587,6 +2113,11 @@ func (in *WebhookReceiver) DeepCopyInto(out *WebhookReceiver) {
*out = new(string)
**out = **in
}
if in.TmplText != nil {
in, out := &in.TmplText, &out.TmplText
*out = new(ConfigmapKeySelector)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookReceiver.
@@ -1689,6 +2220,11 @@ func (in *WechatReceiver) DeepCopyInto(out *WechatReceiver) {
*out = new(string)
**out = **in
}
if in.TmplText != nil {
in, out := &in.TmplText, &out.TmplText
*out = new(ConfigmapKeySelector)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WechatReceiver.

View File

@@ -62,3 +62,5 @@ type FederatedNotificationConfigList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []FederatedNotificationConfig `json:"items"`
}
func (_ *FederatedNotificationConfig) Hub() {}

View File

@@ -61,3 +61,5 @@ type FederatedNotificationReceiverList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []FederatedNotificationReceiver `json:"items"`
}
func (_ *FederatedNotificationReceiver) Hub() {}

View File

@@ -0,0 +1,184 @@
/*
Copyright 2020 KubeSphere Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"kubesphere.io/api/notification/v2beta1"
"kubesphere.io/api/notification/v2beta2"
"kubesphere.io/api/types/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
const (
ResourcePluralFederatedNotificationConfig = "federatednotificationconfigs"
ResourceSingularFederatedNotificationConfig = "federatednotificationconfig"
FederatedNotificationConfigKind = "FederatedNotificationConfig"
)
// +genclient:nonNamespaced
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
type FederatedNotificationConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec FederatedNotificationConfigSpec `json:"spec"`
Status *GenericFederatedStatus `json:"status,omitempty"`
}
type FederatedNotificationConfigSpec struct {
Template NotificationConfigTemplate `json:"template"`
Placement GenericPlacementFields `json:"placement"`
Overrides []GenericOverrideItem `json:"overrides,omitempty"`
}
type NotificationConfigTemplate struct {
// +kubebuilder:pruning:PreserveUnknownFields
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec v2beta2.ConfigSpec `json:"spec,omitempty"`
}
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// FederatedNotificationConfigList contains a list of federatednotificationconfiglists
type FederatedNotificationConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FederatedNotificationConfig `json:"items"`
}
// ConvertTo converts this Config to the Hub version (v1beta1).
func (src *FederatedNotificationConfig) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v1beta1.FederatedNotificationConfig)
dst.ObjectMeta = src.ObjectMeta
srcConfig := v2beta2.Config{
Spec: src.Spec.Template.Spec,
}
dstConfig := &v2beta1.Config{}
if err := srcConfig.ConvertTo(dstConfig); err != nil {
return err
}
dst.Spec = v1beta1.FederatedNotificationConfigSpec{
Template: v1beta1.NotificationConfigTemplate{
Spec: dstConfig.Spec,
},
Placement: convertPlacementTo(src.Spec.Placement),
Overrides: convertOverridesTo(src.Spec.Overrides),
}
return nil
}
// ConvertFrom converts from the Hub version (v1beta1) to this version.
func (dst *FederatedNotificationConfig) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*v1beta1.FederatedNotificationConfig)
dst.ObjectMeta = src.ObjectMeta
srcConfig := v2beta1.Config{
Spec: src.Spec.Template.Spec,
}
dstConfig := &v2beta2.Config{}
if err := dstConfig.ConvertFrom(&srcConfig); err != nil {
return err
}
dst.Spec = FederatedNotificationConfigSpec{
Template: NotificationConfigTemplate{
Spec: dstConfig.Spec,
},
Placement: convertPlacementFrom(src.Spec.Placement),
Overrides: convertOverridesFrom(src.Spec.Overrides),
}
return nil
}
func convertPlacementTo(placement GenericPlacementFields) v1beta1.GenericPlacementFields {
var clusters []v1beta1.GenericClusterReference
for _, cluster := range placement.Clusters {
clusters = append(clusters, v1beta1.GenericClusterReference{
Name: cluster.Name,
})
}
return v1beta1.GenericPlacementFields{
Clusters: clusters,
ClusterSelector: placement.ClusterSelector,
}
}
func convertPlacementFrom(placement v1beta1.GenericPlacementFields) GenericPlacementFields {
var clusters []GenericClusterReference
for _, cluster := range placement.Clusters {
clusters = append(clusters, GenericClusterReference{
Name: cluster.Name,
})
}
return GenericPlacementFields{
Clusters: clusters,
ClusterSelector: placement.ClusterSelector,
}
}
func convertOverridesTo(src []GenericOverrideItem) []v1beta1.GenericOverrideItem {
var dst []v1beta1.GenericOverrideItem
for _, item := range src {
overrideItem := v1beta1.GenericOverrideItem{ClusterName: item.ClusterName}
for _, clusterOverride := range item.ClusterOverrides {
overrideItem.ClusterOverrides = append(overrideItem.ClusterOverrides, v1beta1.ClusterOverride{
Op: clusterOverride.Op,
Path: clusterOverride.Path,
Value: clusterOverride.Value,
})
}
dst = append(dst, overrideItem)
}
return dst
}
func convertOverridesFrom(src []v1beta1.GenericOverrideItem) []GenericOverrideItem {
var dst []GenericOverrideItem
for _, item := range src {
overrideItem := GenericOverrideItem{ClusterName: item.ClusterName}
for _, clusterOverride := range item.ClusterOverrides {
overrideItem.ClusterOverrides = append(overrideItem.ClusterOverrides, ClusterOverride{
Op: clusterOverride.Op,
Path: clusterOverride.Path,
Value: clusterOverride.Value,
})
}
dst = append(dst, overrideItem)
}
return dst
}

View File

@@ -0,0 +1,117 @@
/*
Copyright 2020 KubeSphere Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"kubesphere.io/api/notification/v2beta1"
"kubesphere.io/api/notification/v2beta2"
"kubesphere.io/api/types/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)
const (
ResourcePluralFederatedNotificationReceiver = "federatednotificationreceivers"
ResourceSingularFederatedNotificationReceiver = "federatednotificationreceiver"
FederatedNotificationReceiverKind = "FederatedNotificationReceiver"
)
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
type FederatedNotificationReceiver struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec FederatedNotificationReceiverSpec `json:"spec"`
Status *GenericFederatedStatus `json:"status,omitempty"`
}
type FederatedNotificationReceiverSpec struct {
Template NotificationReceiverTemplate `json:"template"`
Placement GenericPlacementFields `json:"placement"`
Overrides []GenericOverrideItem `json:"overrides,omitempty"`
}
type NotificationReceiverTemplate struct {
// +kubebuilder:pruning:PreserveUnknownFields
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec v2beta2.ReceiverSpec `json:"spec,omitempty"`
}
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// FederatedNotificationReceiverList contains a list of federatednotificationreceiverlists
type FederatedNotificationReceiverList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FederatedNotificationReceiver `json:"items"`
}
// ConvertTo converts this Config to the Hub version (v1beta1).
func (src *FederatedNotificationReceiver) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v1beta1.FederatedNotificationReceiver)
dst.ObjectMeta = src.ObjectMeta
srcReceiver := v2beta2.Receiver{
Spec: src.Spec.Template.Spec,
}
dstReceiver := &v2beta1.Receiver{}
if err := srcReceiver.ConvertTo(dstReceiver); err != nil {
return err
}
dst.Spec = v1beta1.FederatedNotificationReceiverSpec{
Template: v1beta1.NotificationReceiverTemplate{
Spec: dstReceiver.Spec,
},
Placement: convertPlacementTo(src.Spec.Placement),
Overrides: convertOverridesTo(src.Spec.Overrides),
}
return nil
}
// ConvertFrom converts from the Hub version (v1beta1) to this version.
func (dst *FederatedNotificationReceiver) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*v1beta1.FederatedNotificationReceiver)
dst.ObjectMeta = src.ObjectMeta
srcReceiver := v2beta1.Receiver{
Spec: src.Spec.Template.Spec,
}
dstReceiver := &v2beta2.Receiver{}
if err := dstReceiver.ConvertFrom(&srcReceiver); err != nil {
return err
}
dst.Spec = FederatedNotificationReceiverSpec{
Template: NotificationReceiverTemplate{
Spec: dstReceiver.Spec,
},
Placement: convertPlacementFrom(src.Spec.Placement),
Overrides: convertOverridesFrom(src.Spec.Overrides),
}
return nil
}

View File

@@ -0,0 +1,64 @@
/*
Copyright 2020 KubeSphere Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"kubesphere.io/api/notification/v2beta2"
)
const (
ResourcePluralFederatedNotificationRouter = "federatednotificationrouters"
ResourceSingularFederatedNotificationRouter = "federatednotificationrouter"
FederatedNotificationRouterKind = "FederatedNotificationRouter"
)
// +genclient:nonNamespaced
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:subresource:status
type FederatedNotificationRouter struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec FederatedNotificationRouterSpec `json:"spec"`
Status *GenericFederatedStatus `json:"status,omitempty"`
}
type FederatedNotificationRouterSpec struct {
Template NotificationRouterTemplate `json:"template"`
Placement GenericPlacementFields `json:"placement"`
Overrides []GenericOverrideItem `json:"overrides,omitempty"`
}
type NotificationRouterTemplate struct {
// +kubebuilder:pruning:PreserveUnknownFields
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec v2beta2.RouterSpec `json:"spec,omitempty"`
}
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// FederatedNotificationRouterList contains a list of federatednotificationrouterlists
type FederatedNotificationRouterList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FederatedNotificationRouter `json:"items"`
}

View File

@@ -0,0 +1,64 @@
/*
Copyright 2020 KubeSphere Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"kubesphere.io/api/notification/v2beta2"
)
const (
ResourcePluralFederatedNotificationSilence = "federatednotificationsilences"
ResourceSingularFederatedNotificationSilence = "federatednotificationsilence"
FederatedNotificationSilenceKind = "FederatedNotificationSilence"
)
// +genclient:nonNamespaced
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:subresource:status
type FederatedNotificationSilence struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec FederatedNotificationSilenceSpec `json:"spec"`
Status *GenericFederatedStatus `json:"status,omitempty"`
}
type FederatedNotificationSilenceSpec struct {
Template NotificationSilenceTemplate `json:"template"`
Placement GenericPlacementFields `json:"placement"`
Overrides []GenericOverrideItem `json:"overrides,omitempty"`
}
type NotificationSilenceTemplate struct {
// +kubebuilder:pruning:PreserveUnknownFields
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec v2beta2.SilenceSpec `json:"spec,omitempty"`
}
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// FederatedNotificationSilenceList contains a list of federatednotificationsilencelists
type FederatedNotificationSilenceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FederatedNotificationSilence `json:"items"`
}

View File

@@ -0,0 +1,57 @@
/*
Copyright 2019 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// NOTE: Boilerplate only. Ignore this file.
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen=package,register
// +kubebuilder:object:generate=true
// +groupName=types.kubefed.io
package v1beta2
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)
var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "types.kubefed.io", Version: "v1beta2"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
// AddToScheme is required by pkg/client/...
AddToScheme = SchemeBuilder.AddToScheme
)
// Resource is required by pkg/client/listers/...
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
func init() {
SchemeBuilder.Register(
&FederatedNotificationConfig{},
&FederatedNotificationConfigList{},
&FederatedNotificationReceiver{},
&FederatedNotificationReceiverList{},
&FederatedNotificationRouter{},
&FederatedNotificationRouterList{},
&FederatedNotificationSilence{},
&FederatedNotificationSilenceList{},
)
}

View File

@@ -0,0 +1,108 @@
/*
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.
*/
package v1beta2
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
type GenericClusterReference struct {
Name string `json:"name"`
}
type GenericPlacementFields struct {
Clusters []GenericClusterReference `json:"clusters,omitempty"`
ClusterSelector *metav1.LabelSelector `json:"clusterSelector,omitempty"`
}
type GenericPlacementSpec struct {
Placement GenericPlacementFields `json:"placement,omitempty"`
}
type GenericPlacement struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec GenericPlacementSpec `json:"spec,omitempty"`
}
type ClusterOverride struct {
Op string `json:"op,omitempty"`
Path string `json:"path"`
// +kubebuilder:pruning:PreserveUnknownFields
Value runtime.RawExtension `json:"value,omitempty"`
}
type GenericOverrideItem struct {
ClusterName string `json:"clusterName"`
ClusterOverrides []ClusterOverride `json:"clusterOverrides,omitempty"`
}
type GenericOverrideSpec struct {
Overrides []GenericOverrideItem `json:"overrides,omitempty"`
}
type GenericOverride struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec *GenericOverrideSpec `json:"spec,omitempty"`
}
type ConditionType string
type AggregateReason string
type PropagationStatus string
type GenericClusterStatus struct {
Name string `json:"name"`
Status PropagationStatus `json:"status,omitempty"`
}
type GenericCondition struct {
// Type of cluster condition
Type ConditionType `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// Last time reconciliation resulted in an error or the last time a
// change was propagated to member clusters.
// +optional
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transit from one status to another.
// +optional
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// (brief) reason for the condition's last transition.
// +optional
Reason AggregateReason `json:"reason,omitempty"`
}
type GenericFederatedStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Conditions []*GenericCondition `json:"conditions,omitempty"`
Clusters []GenericClusterStatus `json:"clusters,omitempty"`
}
type GenericFederatedResource struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Status *GenericFederatedStatus `json:"status,omitempty"`
}

View File

@@ -0,0 +1,681 @@
// +build !ignore_autogenerated
/*
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 controller-gen. DO NOT EDIT.
package v1beta2
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterOverride) DeepCopyInto(out *ClusterOverride) {
*out = *in
in.Value.DeepCopyInto(&out.Value)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOverride.
func (in *ClusterOverride) DeepCopy() *ClusterOverride {
if in == nil {
return nil
}
out := new(ClusterOverride)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationConfig) DeepCopyInto(out *FederatedNotificationConfig) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
if in.Status != nil {
in, out := &in.Status, &out.Status
*out = new(GenericFederatedStatus)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationConfig.
func (in *FederatedNotificationConfig) DeepCopy() *FederatedNotificationConfig {
if in == nil {
return nil
}
out := new(FederatedNotificationConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *FederatedNotificationConfig) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationConfigList) DeepCopyInto(out *FederatedNotificationConfigList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]FederatedNotificationConfig, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationConfigList.
func (in *FederatedNotificationConfigList) DeepCopy() *FederatedNotificationConfigList {
if in == nil {
return nil
}
out := new(FederatedNotificationConfigList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *FederatedNotificationConfigList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationConfigSpec) DeepCopyInto(out *FederatedNotificationConfigSpec) {
*out = *in
in.Template.DeepCopyInto(&out.Template)
in.Placement.DeepCopyInto(&out.Placement)
if in.Overrides != nil {
in, out := &in.Overrides, &out.Overrides
*out = make([]GenericOverrideItem, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationConfigSpec.
func (in *FederatedNotificationConfigSpec) DeepCopy() *FederatedNotificationConfigSpec {
if in == nil {
return nil
}
out := new(FederatedNotificationConfigSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationReceiver) DeepCopyInto(out *FederatedNotificationReceiver) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
if in.Status != nil {
in, out := &in.Status, &out.Status
*out = new(GenericFederatedStatus)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationReceiver.
func (in *FederatedNotificationReceiver) DeepCopy() *FederatedNotificationReceiver {
if in == nil {
return nil
}
out := new(FederatedNotificationReceiver)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *FederatedNotificationReceiver) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationReceiverList) DeepCopyInto(out *FederatedNotificationReceiverList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]FederatedNotificationReceiver, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationReceiverList.
func (in *FederatedNotificationReceiverList) DeepCopy() *FederatedNotificationReceiverList {
if in == nil {
return nil
}
out := new(FederatedNotificationReceiverList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *FederatedNotificationReceiverList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationReceiverSpec) DeepCopyInto(out *FederatedNotificationReceiverSpec) {
*out = *in
in.Template.DeepCopyInto(&out.Template)
in.Placement.DeepCopyInto(&out.Placement)
if in.Overrides != nil {
in, out := &in.Overrides, &out.Overrides
*out = make([]GenericOverrideItem, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationReceiverSpec.
func (in *FederatedNotificationReceiverSpec) DeepCopy() *FederatedNotificationReceiverSpec {
if in == nil {
return nil
}
out := new(FederatedNotificationReceiverSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationRouter) DeepCopyInto(out *FederatedNotificationRouter) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
if in.Status != nil {
in, out := &in.Status, &out.Status
*out = new(GenericFederatedStatus)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationRouter.
func (in *FederatedNotificationRouter) DeepCopy() *FederatedNotificationRouter {
if in == nil {
return nil
}
out := new(FederatedNotificationRouter)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *FederatedNotificationRouter) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationRouterList) DeepCopyInto(out *FederatedNotificationRouterList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]FederatedNotificationRouter, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationRouterList.
func (in *FederatedNotificationRouterList) DeepCopy() *FederatedNotificationRouterList {
if in == nil {
return nil
}
out := new(FederatedNotificationRouterList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *FederatedNotificationRouterList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationRouterSpec) DeepCopyInto(out *FederatedNotificationRouterSpec) {
*out = *in
in.Template.DeepCopyInto(&out.Template)
in.Placement.DeepCopyInto(&out.Placement)
if in.Overrides != nil {
in, out := &in.Overrides, &out.Overrides
*out = make([]GenericOverrideItem, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationRouterSpec.
func (in *FederatedNotificationRouterSpec) DeepCopy() *FederatedNotificationRouterSpec {
if in == nil {
return nil
}
out := new(FederatedNotificationRouterSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationSilence) DeepCopyInto(out *FederatedNotificationSilence) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
if in.Status != nil {
in, out := &in.Status, &out.Status
*out = new(GenericFederatedStatus)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationSilence.
func (in *FederatedNotificationSilence) DeepCopy() *FederatedNotificationSilence {
if in == nil {
return nil
}
out := new(FederatedNotificationSilence)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *FederatedNotificationSilence) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationSilenceList) DeepCopyInto(out *FederatedNotificationSilenceList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]FederatedNotificationSilence, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationSilenceList.
func (in *FederatedNotificationSilenceList) DeepCopy() *FederatedNotificationSilenceList {
if in == nil {
return nil
}
out := new(FederatedNotificationSilenceList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *FederatedNotificationSilenceList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FederatedNotificationSilenceSpec) DeepCopyInto(out *FederatedNotificationSilenceSpec) {
*out = *in
in.Template.DeepCopyInto(&out.Template)
in.Placement.DeepCopyInto(&out.Placement)
if in.Overrides != nil {
in, out := &in.Overrides, &out.Overrides
*out = make([]GenericOverrideItem, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FederatedNotificationSilenceSpec.
func (in *FederatedNotificationSilenceSpec) DeepCopy() *FederatedNotificationSilenceSpec {
if in == nil {
return nil
}
out := new(FederatedNotificationSilenceSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GenericClusterReference) DeepCopyInto(out *GenericClusterReference) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericClusterReference.
func (in *GenericClusterReference) DeepCopy() *GenericClusterReference {
if in == nil {
return nil
}
out := new(GenericClusterReference)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GenericClusterStatus) DeepCopyInto(out *GenericClusterStatus) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericClusterStatus.
func (in *GenericClusterStatus) DeepCopy() *GenericClusterStatus {
if in == nil {
return nil
}
out := new(GenericClusterStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GenericCondition) DeepCopyInto(out *GenericCondition) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericCondition.
func (in *GenericCondition) DeepCopy() *GenericCondition {
if in == nil {
return nil
}
out := new(GenericCondition)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GenericFederatedResource) DeepCopyInto(out *GenericFederatedResource) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
if in.Status != nil {
in, out := &in.Status, &out.Status
*out = new(GenericFederatedStatus)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericFederatedResource.
func (in *GenericFederatedResource) DeepCopy() *GenericFederatedResource {
if in == nil {
return nil
}
out := new(GenericFederatedResource)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GenericFederatedStatus) DeepCopyInto(out *GenericFederatedStatus) {
*out = *in
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]*GenericCondition, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(GenericCondition)
**out = **in
}
}
}
if in.Clusters != nil {
in, out := &in.Clusters, &out.Clusters
*out = make([]GenericClusterStatus, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericFederatedStatus.
func (in *GenericFederatedStatus) DeepCopy() *GenericFederatedStatus {
if in == nil {
return nil
}
out := new(GenericFederatedStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GenericOverride) DeepCopyInto(out *GenericOverride) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
if in.Spec != nil {
in, out := &in.Spec, &out.Spec
*out = new(GenericOverrideSpec)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericOverride.
func (in *GenericOverride) DeepCopy() *GenericOverride {
if in == nil {
return nil
}
out := new(GenericOverride)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GenericOverrideItem) DeepCopyInto(out *GenericOverrideItem) {
*out = *in
if in.ClusterOverrides != nil {
in, out := &in.ClusterOverrides, &out.ClusterOverrides
*out = make([]ClusterOverride, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericOverrideItem.
func (in *GenericOverrideItem) DeepCopy() *GenericOverrideItem {
if in == nil {
return nil
}
out := new(GenericOverrideItem)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GenericOverrideSpec) DeepCopyInto(out *GenericOverrideSpec) {
*out = *in
if in.Overrides != nil {
in, out := &in.Overrides, &out.Overrides
*out = make([]GenericOverrideItem, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericOverrideSpec.
func (in *GenericOverrideSpec) DeepCopy() *GenericOverrideSpec {
if in == nil {
return nil
}
out := new(GenericOverrideSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GenericPlacement) DeepCopyInto(out *GenericPlacement) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericPlacement.
func (in *GenericPlacement) DeepCopy() *GenericPlacement {
if in == nil {
return nil
}
out := new(GenericPlacement)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GenericPlacementFields) DeepCopyInto(out *GenericPlacementFields) {
*out = *in
if in.Clusters != nil {
in, out := &in.Clusters, &out.Clusters
*out = make([]GenericClusterReference, len(*in))
copy(*out, *in)
}
if in.ClusterSelector != nil {
in, out := &in.ClusterSelector, &out.ClusterSelector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericPlacementFields.
func (in *GenericPlacementFields) DeepCopy() *GenericPlacementFields {
if in == nil {
return nil
}
out := new(GenericPlacementFields)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GenericPlacementSpec) DeepCopyInto(out *GenericPlacementSpec) {
*out = *in
in.Placement.DeepCopyInto(&out.Placement)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericPlacementSpec.
func (in *GenericPlacementSpec) DeepCopy() *GenericPlacementSpec {
if in == nil {
return nil
}
out := new(GenericPlacementSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NotificationConfigTemplate) DeepCopyInto(out *NotificationConfigTemplate) {
*out = *in
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotificationConfigTemplate.
func (in *NotificationConfigTemplate) DeepCopy() *NotificationConfigTemplate {
if in == nil {
return nil
}
out := new(NotificationConfigTemplate)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NotificationReceiverTemplate) DeepCopyInto(out *NotificationReceiverTemplate) {
*out = *in
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotificationReceiverTemplate.
func (in *NotificationReceiverTemplate) DeepCopy() *NotificationReceiverTemplate {
if in == nil {
return nil
}
out := new(NotificationReceiverTemplate)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NotificationRouterTemplate) DeepCopyInto(out *NotificationRouterTemplate) {
*out = *in
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotificationRouterTemplate.
func (in *NotificationRouterTemplate) DeepCopy() *NotificationRouterTemplate {
if in == nil {
return nil
}
out := new(NotificationRouterTemplate)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NotificationSilenceTemplate) DeepCopyInto(out *NotificationSilenceTemplate) {
*out = *in
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotificationSilenceTemplate.
func (in *NotificationSilenceTemplate) DeepCopy() *NotificationSilenceTemplate {
if in == nil {
return nil
}
out := new(NotificationSilenceTemplate)
in.DeepCopyInto(out)
return out
}