/
config_types.go
228 lines (195 loc) · 7.38 KB
/
config_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
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"
)
// DingTalkApplicationConfig it th configuration of conversation
type DingTalkApplicationConfig struct {
// The key of the application with which to send messages.
AppKey *Credential `json:"appkey"`
// The key in the secret to be used. Must be a valid secret key.
AppSecret *Credential `json:"appsecret"`
}
type DingTalkConfig struct {
Labels map[string]string `json:"labels,omitempty"`
// Only needed when send alerts to the conversation.
Conversation *DingTalkApplicationConfig `json:"conversation,omitempty"`
}
type ClientCertificate struct {
// The client cert file for the targets.
Cert *Credential `json:"cert"`
// The client key file for the targets.
Key *Credential `json:"key"`
}
// TLSConfig configures the options for TLS connections.
type TLSConfig struct {
// RootCA defines the root certificate authorities
// that clients use when verifying server certificates.
RootCA *Credential `json:"rootCA,omitempty"`
// The certificate of the client.
*ClientCertificate `json:"clientCertificate,omitempty"`
// Used to verify the hostname for the targets.
ServerName string `json:"serverName,omitempty"`
// Disable target certificate validation.
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
}
// BasicAuth contains basic HTTP authentication credentials.
type BasicAuth struct {
Username string `json:"username"`
Password *Credential `json:"password,omitempty"`
}
// HTTPClientConfig configures an HTTP client.
type HTTPClientConfig struct {
// The HTTP basic authentication credentials for the targets.
BasicAuth *BasicAuth `json:"basicAuth,omitempty"`
// The bearer token for the targets.
BearerToken *Credential `json:"bearerToken,omitempty"`
// HTTP proxy server to use to connect to the targets.
ProxyURL string `json:"proxyUrl,omitempty"`
// TLSConfig to use to connect to the targets.
TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
}
type HostPort struct {
Host string `json:"host"`
Port int `json:"port"`
}
type EmailConfig struct {
Labels map[string]string `json:"labels,omitempty"`
// The sender address.
From string `json:"from"`
// The address of the SMTP server.
SmartHost HostPort `json:"smartHost"`
// The hostname to use when identifying to the SMTP server.
Hello *string `json:"hello,omitempty"`
// The username for CRAM-MD5, LOGIN and PLAIN authentications.
AuthUsername *string `json:"authUsername,omitempty"`
// The identity for PLAIN authentication.
AuthIdentify *string `json:"authIdentify,omitempty"`
// The secret contains the SMTP password for LOGIN and PLAIN authentications.
AuthPassword *Credential `json:"authPassword,omitempty"`
// The secret contains the SMTP secret for CRAM-MD5 authentication.
AuthSecret *Credential `json:"authSecret,omitempty"`
// The default SMTP TLS requirement.
RequireTLS *bool `json:"requireTLS,omitempty"`
TLS *TLSConfig `json:"tls,omitempty"`
}
type SlackConfig struct {
Labels map[string]string `json:"labels,omitempty"`
// The token of user or bot.
SlackTokenSecret *Credential `json:"slackTokenSecret"`
}
type WebhookConfig struct {
Labels map[string]string `json:"labels,omitempty"`
}
type WechatConfig struct {
Labels map[string]string `json:"labels,omitempty"`
// The WeChat API URL.
WechatApiUrl string `json:"wechatApiUrl,omitempty"`
// The corp id for authentication.
WechatApiCorpId string `json:"wechatApiCorpId"`
// The id of the application which sending message.
WechatApiAgentId string `json:"wechatApiAgentId"`
// The API key to use when talking to the WeChat API.
WechatApiSecret *Credential `json:"wechatApiSecret"`
}
// Sms Aliyun provider parameters
type AliyunSMS struct {
SignName string `json:"signName"`
TemplateCode string `json:"templateCode,omitempty"`
AccessKeyId *Credential `json:"accessKeyId"`
AccessKeySecret *Credential `json:"accessKeySecret"`
}
// Sms tencent provider parameters
type TencentSMS struct {
Sign string `json:"sign"`
TemplateID string `json:"templateID"`
SmsSdkAppid string `json:"smsSdkAppid"`
SecretId *Credential `json:"secretId"`
SecretKey *Credential `json:"secretKey"`
}
// Sms huawei provider parameters
type HuaweiSMS struct {
Url string `json:"url,omitempty"`
Signature string `json:"signature"`
TemplateId string `json:"templateId"`
Sender string `json:"sender"`
AppSecret *Credential `json:"appSecret"`
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 {
// The default sms provider, optional, use the first provider if not set
DefaultProvider string `json:"defaultProvider,omitempty"`
// All sms providers
Providers *Providers `json:"providers"`
}
type PushoverConfig struct {
Labels map[string]string `json:"labels,omitempty"`
// The token of a pushover application.
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"`
Email *EmailConfig `json:"email,omitempty"`
Slack *SlackConfig `json:"slack,omitempty"`
Webhook *WebhookConfig `json:"webhook,omitempty"`
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
type ConfigStatus struct {
}
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster,shortName=nc,categories=notification-manager
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +genclient
// +genclient:nonNamespaced
// Config is the Schema for the configs API
type Config struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ConfigSpec `json:"spec,omitempty"`
Status ConfigStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// ConfigList contains a list of Config
type ConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Config `json:"items"`
}
func init() {
SchemeBuilder.Register(&Config{}, &ConfigList{})
}