kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/notification/v2beta1/config_types.go (about)

     1  /*
     2  
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v2beta1
    18  
    19  import (
    20  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  )
    22  
    23  // Configuration of conversation
    24  type DingTalkApplicationConfig struct {
    25  	// The key of the application with which to send messages.
    26  	AppKey *SecretKeySelector `json:"appkey,omitempty"`
    27  	// The key in the secret to be used. Must be a valid secret key.
    28  	AppSecret *SecretKeySelector `json:"appsecret,omitempty"`
    29  }
    30  
    31  type DingTalkConfig struct {
    32  	Labels map[string]string `json:"labels,omitempty"`
    33  	// Only needed when send alerts to the conversation.
    34  	Conversation *DingTalkApplicationConfig `json:"conversation,omitempty"`
    35  }
    36  
    37  type ClientCertificate struct {
    38  	// The client cert file for the targets.
    39  	Cert *SecretKeySelector `json:"cert,omitempty"`
    40  	// The client key file for the targets.
    41  	Key *SecretKeySelector `json:"key,omitempty"`
    42  }
    43  
    44  // TLSConfig configures the options for TLS connections.
    45  type TLSConfig struct {
    46  	// RootCA defines the root certificate authorities
    47  	// that clients use when verifying server certificates.
    48  	RootCA *SecretKeySelector `json:"rootCA,omitempty"`
    49  	// The certificate of the client.
    50  	*ClientCertificate `json:"clientCertificate,omitempty"`
    51  	// Used to verify the hostname for the targets.
    52  	ServerName string `json:"serverName,omitempty"`
    53  	// Disable target certificate validation.
    54  	InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
    55  }
    56  
    57  // BasicAuth contains basic HTTP authentication credentials.
    58  type BasicAuth struct {
    59  	Username string             `json:"username"`
    60  	Password *SecretKeySelector `json:"password,omitempty"`
    61  }
    62  
    63  // HTTPClientConfig configures an HTTP client.
    64  type HTTPClientConfig struct {
    65  	// The HTTP basic authentication credentials for the targets.
    66  	BasicAuth *BasicAuth `json:"basicAuth,omitempty"`
    67  	// The bearer token for the targets.
    68  	BearerToken *SecretKeySelector `json:"bearerToken,omitempty"`
    69  	// HTTP proxy server to use to connect to the targets.
    70  	ProxyURL string `json:"proxyUrl,omitempty"`
    71  	// TLSConfig to use to connect to the targets.
    72  	TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
    73  }
    74  
    75  type HostPort struct {
    76  	Host string `json:"host"`
    77  	Port int    `json:"port"`
    78  }
    79  
    80  type EmailConfig struct {
    81  	Labels map[string]string `json:"labels,omitempty"`
    82  	// The sender address.
    83  	From string `json:"from"`
    84  	// The address of the SMTP server.
    85  	SmartHost HostPort `json:"smartHost"`
    86  	// The hostname to use when identifying to the SMTP server.
    87  	Hello *string `json:"hello,omitempty"`
    88  	// The username for CRAM-MD5, LOGIN and PLAIN authentications.
    89  	AuthUsername *string `json:"authUsername,omitempty"`
    90  	// The identity for PLAIN authentication.
    91  	AuthIdentify *string `json:"authIdentify,omitempty"`
    92  	// The secret contains the SMTP password for LOGIN and PLAIN authentications.
    93  	AuthPassword *SecretKeySelector `json:"authPassword,omitempty"`
    94  	// The secret contains the SMTP secret for CRAM-MD5 authentication.
    95  	AuthSecret *SecretKeySelector `json:"authSecret,omitempty"`
    96  	// The default SMTP TLS requirement.
    97  	RequireTLS *bool      `json:"requireTLS,omitempty"`
    98  	TLS        *TLSConfig `json:"tls,omitempty"`
    99  }
   100  
   101  type SlackConfig struct {
   102  	Labels map[string]string `json:"labels,omitempty"`
   103  	// The token of user or bot.
   104  	SlackTokenSecret *SecretKeySelector `json:"slackTokenSecret,omitempty"`
   105  }
   106  
   107  type WebhookConfig struct {
   108  	Labels map[string]string `json:"labels,omitempty"`
   109  }
   110  
   111  type WechatConfig struct {
   112  	Labels map[string]string `json:"labels,omitempty"`
   113  	// The WeChat API URL.
   114  	WechatApiUrl string `json:"wechatApiUrl,omitempty"`
   115  	// The corp id for authentication.
   116  	WechatApiCorpId string `json:"wechatApiCorpId"`
   117  	// The id of the application which sending message.
   118  	WechatApiAgentId string `json:"wechatApiAgentId"`
   119  	// The API key to use when talking to the WeChat API.
   120  	WechatApiSecret *SecretKeySelector `json:"wechatApiSecret"`
   121  }
   122  
   123  // ConfigSpec defines the desired state of Config
   124  type ConfigSpec struct {
   125  	DingTalk *DingTalkConfig `json:"dingtalk,omitempty"`
   126  	Email    *EmailConfig    `json:"email,omitempty"`
   127  	Slack    *SlackConfig    `json:"slack,omitempty"`
   128  	Webhook  *WebhookConfig  `json:"webhook,omitempty"`
   129  	Wechat   *WechatConfig   `json:"wechat,omitempty"`
   130  }
   131  
   132  // ConfigStatus defines the observed state of Config
   133  type ConfigStatus struct {
   134  }
   135  
   136  // +kubebuilder:object:root=true
   137  // +kubebuilder:resource:scope=Cluster,shortName=nc,categories=notification-manager
   138  // +kubebuilder:subresource:status
   139  // +genclient
   140  // +genclient:nonNamespaced
   141  
   142  // Config is the Schema for the configs API
   143  type Config struct {
   144  	metav1.TypeMeta   `json:",inline"`
   145  	metav1.ObjectMeta `json:"metadata,omitempty"`
   146  
   147  	Spec   ConfigSpec   `json:"spec,omitempty"`
   148  	Status ConfigStatus `json:"status,omitempty"`
   149  }
   150  
   151  // +kubebuilder:object:root=true
   152  
   153  // ConfigList contains a list of Config
   154  type ConfigList struct {
   155  	metav1.TypeMeta `json:",inline"`
   156  	metav1.ListMeta `json:"metadata,omitempty"`
   157  	Items           []Config `json:"items"`
   158  }
   159  
   160  func init() {
   161  	SchemeBuilder.Register(&Config{}, &ConfigList{})
   162  }
   163  
   164  func (_ *Config) Hub() {}