-
Notifications
You must be signed in to change notification settings - Fork 229
/
mapconfig.go
396 lines (389 loc) · 25.4 KB
/
mapconfig.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
// Code generated by devtools/configparams DO NOT EDIT.
package graphql2
import (
"fmt"
"strconv"
"strings"
"github.com/target/goalert/config"
"github.com/target/goalert/validation"
)
func MapConfigHints(cfg config.Hints) []ConfigHint {
return []ConfigHint{
{ID: "GitHub.AuthCallbackURL", Value: cfg.GitHub.AuthCallbackURL},
{ID: "OIDC.RedirectURL", Value: cfg.OIDC.RedirectURL},
{ID: "Mailgun.ForwardURL", Value: cfg.Mailgun.ForwardURL},
{ID: "Twilio.MessageWebhookURL", Value: cfg.Twilio.MessageWebhookURL},
{ID: "Twilio.VoiceWebhookURL", Value: cfg.Twilio.VoiceWebhookURL},
{ID: "Slack.InteractivityResponseURL", Value: cfg.Slack.InteractivityResponseURL},
}
}
// MapConfigValues will map a Config struct into a flat list of ConfigValue structs.
func MapConfigValues(cfg config.Config) []ConfigValue {
return []ConfigValue{
{ID: "General.ApplicationName", Type: ConfigTypeString, Description: "The name used in messaging and page titles. Defaults to \"GoAlert\".", Value: cfg.General.ApplicationName},
{ID: "General.PublicURL", Type: ConfigTypeString, Description: "Publicly routable URL for UI links and API calls.", Value: cfg.General.PublicURL, Deprecated: "Use --public-url flag instead, which takes precedence."},
{ID: "General.GoogleAnalyticsID", Type: ConfigTypeString, Description: "If set, will post user metrics to the corresponding data stream in Google Analytics 4.", Value: cfg.General.GoogleAnalyticsID},
{ID: "General.NotificationDisclaimer", Type: ConfigTypeString, Description: "Disclaimer text for receiving pre-recorded notifications (appears on profile page).", Value: cfg.General.NotificationDisclaimer},
{ID: "General.DisableMessageBundles", Type: ConfigTypeBoolean, Description: "Disable bundling status updates and alert notifications.", Value: fmt.Sprintf("%t", cfg.General.DisableMessageBundles)},
{ID: "General.ShortURL", Type: ConfigTypeString, Description: "If set, messages will contain a shorter URL using this as a prefix (e.g. http://example.com). It should point to GoAlert and can be the same as the PublicURL.", Value: cfg.General.ShortURL},
{ID: "General.DisableSMSLinks", Type: ConfigTypeBoolean, Description: "If set, SMS messages will not contain a URL pointing to GoAlert.", Value: fmt.Sprintf("%t", cfg.General.DisableSMSLinks)},
{ID: "General.DisableLabelCreation", Type: ConfigTypeBoolean, Description: "Disables the ability to create new labels for services.", Value: fmt.Sprintf("%t", cfg.General.DisableLabelCreation)},
{ID: "General.DisableCalendarSubscriptions", Type: ConfigTypeBoolean, Description: "If set, disables all active calendar subscriptions as well as the ability to create new calendar subscriptions.", Value: fmt.Sprintf("%t", cfg.General.DisableCalendarSubscriptions)},
{ID: "Services.RequiredLabels", Type: ConfigTypeStringList, Description: "List of label names to require new services to define.", Value: strings.Join(cfg.Services.RequiredLabels, "\n")},
{ID: "Maintenance.AlertCleanupDays", Type: ConfigTypeInteger, Description: "Closed alerts will be deleted after this many days (0 means disable cleanup).", Value: fmt.Sprintf("%d", cfg.Maintenance.AlertCleanupDays)},
{ID: "Maintenance.AlertAutoCloseDays", Type: ConfigTypeInteger, Description: "Unacknowledged alerts will automatically be closed after this many days of inactivity. (0 means disable auto-close).", Value: fmt.Sprintf("%d", cfg.Maintenance.AlertAutoCloseDays)},
{ID: "Maintenance.AutoCloseAckedAlerts", Type: ConfigTypeBoolean, Description: "If set, alerts that are acknowledged will also be automatically closed after the configured number of days of inactivity.", Value: fmt.Sprintf("%t", cfg.Maintenance.AutoCloseAckedAlerts)},
{ID: "Maintenance.APIKeyExpireDays", Type: ConfigTypeInteger, Description: "Unused calendar API keys will be disabled after this many days (0 means disable cleanup).", Value: fmt.Sprintf("%d", cfg.Maintenance.APIKeyExpireDays)},
{ID: "Maintenance.ScheduleCleanupDays", Type: ConfigTypeInteger, Description: "Schedule on-call history will be deleted after this many days (0 means disable cleanup).", Value: fmt.Sprintf("%d", cfg.Maintenance.ScheduleCleanupDays)},
{ID: "Auth.RefererURLs", Type: ConfigTypeStringList, Description: "Allowed referer URLs for auth and redirects.", Value: strings.Join(cfg.Auth.RefererURLs, "\n"), Deprecated: "Use --public-url flag instead, which takes precedence."},
{ID: "Auth.DisableBasic", Type: ConfigTypeBoolean, Description: "Disallow username/password login.", Value: fmt.Sprintf("%t", cfg.Auth.DisableBasic)},
{ID: "GitHub.Enable", Type: ConfigTypeBoolean, Description: "Enable GitHub authentication.", Value: fmt.Sprintf("%t", cfg.GitHub.Enable)},
{ID: "GitHub.NewUsers", Type: ConfigTypeBoolean, Description: "Allow new user creation via GitHub authentication.", Value: fmt.Sprintf("%t", cfg.GitHub.NewUsers)},
{ID: "GitHub.ClientID", Type: ConfigTypeString, Description: "", Value: cfg.GitHub.ClientID},
{ID: "GitHub.ClientSecret", Type: ConfigTypeString, Description: "", Value: cfg.GitHub.ClientSecret, Password: true},
{ID: "GitHub.AllowedUsers", Type: ConfigTypeStringList, Description: "Allow any of the listed GitHub usernames to authenticate. Use '*' to allow any user.", Value: strings.Join(cfg.GitHub.AllowedUsers, "\n")},
{ID: "GitHub.AllowedOrgs", Type: ConfigTypeStringList, Description: "Allow any member of any listed GitHub org (or team, using the format 'org/team') to authenticate.", Value: strings.Join(cfg.GitHub.AllowedOrgs, "\n")},
{ID: "GitHub.EnterpriseURL", Type: ConfigTypeString, Description: "GitHub URL (without /api) when used with GitHub Enterprise.", Value: cfg.GitHub.EnterpriseURL},
{ID: "OIDC.Enable", Type: ConfigTypeBoolean, Description: "Enable OpenID Connect authentication.", Value: fmt.Sprintf("%t", cfg.OIDC.Enable)},
{ID: "OIDC.NewUsers", Type: ConfigTypeBoolean, Description: "Allow new user creation via OIDC authentication.", Value: fmt.Sprintf("%t", cfg.OIDC.NewUsers)},
{ID: "OIDC.OverrideName", Type: ConfigTypeString, Description: "Set the name/label on the login page to something other than OIDC.", Value: cfg.OIDC.OverrideName},
{ID: "OIDC.IssuerURL", Type: ConfigTypeString, Description: "", Value: cfg.OIDC.IssuerURL},
{ID: "OIDC.ClientID", Type: ConfigTypeString, Description: "", Value: cfg.OIDC.ClientID},
{ID: "OIDC.ClientSecret", Type: ConfigTypeString, Description: "", Value: cfg.OIDC.ClientSecret, Password: true},
{ID: "OIDC.Scopes", Type: ConfigTypeString, Description: "Requested scopes for authentication. If left blank, openid, profile, and email will be used.", Value: cfg.OIDC.Scopes},
{ID: "OIDC.UserInfoEmailPath", Type: ConfigTypeString, Description: "JMESPath expression to find email address in UserInfo. If set, the email claim will be ignored in favor of this. (suggestion: email).", Value: cfg.OIDC.UserInfoEmailPath},
{ID: "OIDC.UserInfoEmailVerifiedPath", Type: ConfigTypeString, Description: "JMESPath expression to find email verification state in UserInfo. If set, the email_verified claim will be ignored in favor of this. (suggestion: email_verified).", Value: cfg.OIDC.UserInfoEmailVerifiedPath},
{ID: "OIDC.UserInfoNamePath", Type: ConfigTypeString, Description: "JMESPath expression to find full name in UserInfo. If set, the name claim will be ignored in favor of this. (suggestion: name || cn || join(' ', [firstname, lastname]))", Value: cfg.OIDC.UserInfoNamePath},
{ID: "Mailgun.Enable", Type: ConfigTypeBoolean, Description: "", Value: fmt.Sprintf("%t", cfg.Mailgun.Enable)},
{ID: "Mailgun.APIKey", Type: ConfigTypeString, Description: "", Value: cfg.Mailgun.APIKey, Password: true},
{ID: "Mailgun.EmailDomain", Type: ConfigTypeString, Description: "The TO address for all incoming alerts.", Value: cfg.Mailgun.EmailDomain},
{ID: "Slack.Enable", Type: ConfigTypeBoolean, Description: "", Value: fmt.Sprintf("%t", cfg.Slack.Enable)},
{ID: "Slack.ClientID", Type: ConfigTypeString, Description: "", Value: cfg.Slack.ClientID},
{ID: "Slack.ClientSecret", Type: ConfigTypeString, Description: "", Value: cfg.Slack.ClientSecret, Password: true},
{ID: "Slack.AccessToken", Type: ConfigTypeString, Description: "Slack app bot user OAuth access token (should start with xoxb-).", Value: cfg.Slack.AccessToken, Password: true},
{ID: "Slack.SigningSecret", Type: ConfigTypeString, Description: "Signing secret to verify requests from slack.", Value: cfg.Slack.SigningSecret, Password: true},
{ID: "Slack.InteractiveMessages", Type: ConfigTypeBoolean, Description: "Enable interactive messages (e.g. buttons).", Value: fmt.Sprintf("%t", cfg.Slack.InteractiveMessages)},
{ID: "Twilio.Enable", Type: ConfigTypeBoolean, Description: "Enables sending and processing of Voice and SMS messages through the Twilio notification provider.", Value: fmt.Sprintf("%t", cfg.Twilio.Enable)},
{ID: "Twilio.VoiceName", Type: ConfigTypeString, Description: "The Twilio voice to use for Text To Speech for phone calls. See https://www.twilio.com/docs/voice/twiml/say/text-speech#polly-standard-and-neural-voices", Value: cfg.Twilio.VoiceName},
{ID: "Twilio.VoiceLanguage", Type: ConfigTypeString, Description: "The Twilio voice language to use for Text To Speech for phone calls. See https://www.twilio.com/docs/voice/twiml/say/text-speech#polly-standard-and-neural-voices", Value: cfg.Twilio.VoiceLanguage},
{ID: "Twilio.AccountSID", Type: ConfigTypeString, Description: "", Value: cfg.Twilio.AccountSID},
{ID: "Twilio.AuthToken", Type: ConfigTypeString, Description: "The primary Auth Token for Twilio. Must be primary unless Alternate Auth Token is set. This token is used for outgoing requests.", Value: cfg.Twilio.AuthToken, Password: true},
{ID: "Twilio.AlternateAuthToken", Type: ConfigTypeString, Description: "An alternate Auth Token for validating incoming requests. During a key change, set this to the Primary, and Auth Token to the Secondary, then promote and clear this field.", Value: cfg.Twilio.AlternateAuthToken, Password: true},
{ID: "Twilio.FromNumber", Type: ConfigTypeString, Description: "The Twilio number to use for outgoing notifications.", Value: cfg.Twilio.FromNumber},
{ID: "Twilio.MessagingServiceSID", Type: ConfigTypeString, Description: "If set, replaces the use of From Number for SMS notifications.", Value: cfg.Twilio.MessagingServiceSID},
{ID: "Twilio.DisableTwoWaySMS", Type: ConfigTypeBoolean, Description: "Disables SMS reply codes for alert messages.", Value: fmt.Sprintf("%t", cfg.Twilio.DisableTwoWaySMS)},
{ID: "Twilio.SMSCarrierLookup", Type: ConfigTypeBoolean, Description: "Perform carrier lookup of SMS contact methods (required for SMSFromNumberOverride). Extra charges may apply.", Value: fmt.Sprintf("%t", cfg.Twilio.SMSCarrierLookup)},
{ID: "Twilio.SMSFromNumberOverride", Type: ConfigTypeStringList, Description: "List of 'carrier=number' pairs, SMS messages to numbers of the provided carrier string (exact match) will use the alternate From Number.", Value: strings.Join(cfg.Twilio.SMSFromNumberOverride, "\n")},
{ID: "SMTP.Enable", Type: ConfigTypeBoolean, Description: "Enables email as a contact method.", Value: fmt.Sprintf("%t", cfg.SMTP.Enable)},
{ID: "SMTP.From", Type: ConfigTypeString, Description: "The email address messages should be sent from.", Value: cfg.SMTP.From},
{ID: "SMTP.Address", Type: ConfigTypeString, Description: "The server address to use for sending email. Port is optional and defaults to 465, or 25 if Disable TLS is set. Common ports are: 25 or 587 for STARTTLS (or unencrypted) and 465 for TLS.", Value: cfg.SMTP.Address},
{ID: "SMTP.DisableTLS", Type: ConfigTypeBoolean, Description: "Disables TLS on the connection (STARTTLS will still be used if supported).", Value: fmt.Sprintf("%t", cfg.SMTP.DisableTLS)},
{ID: "SMTP.SkipVerify", Type: ConfigTypeBoolean, Description: "Disables certificate validation for TLS/STARTTLS (insecure).", Value: fmt.Sprintf("%t", cfg.SMTP.SkipVerify)},
{ID: "SMTP.Username", Type: ConfigTypeString, Description: "Username for authentication.", Value: cfg.SMTP.Username},
{ID: "SMTP.Password", Type: ConfigTypeString, Description: "Password for authentication.", Value: cfg.SMTP.Password, Password: true},
{ID: "Webhook.Enable", Type: ConfigTypeBoolean, Description: "Enables webhook as a contact method.", Value: fmt.Sprintf("%t", cfg.Webhook.Enable)},
{ID: "Webhook.AllowedURLs", Type: ConfigTypeStringList, Description: "If set, allows webhooks for these domains only.", Value: strings.Join(cfg.Webhook.AllowedURLs, "\n")},
{ID: "Feedback.Enable", Type: ConfigTypeBoolean, Description: "Enables Feedback link in nav bar.", Value: fmt.Sprintf("%t", cfg.Feedback.Enable)},
{ID: "Feedback.OverrideURL", Type: ConfigTypeString, Description: "Use a custom URL for Feedback link in nav bar.", Value: cfg.Feedback.OverrideURL},
}
}
// MapPublicConfigValues will map a Config struct into a flat list of ConfigValue structs.
func MapPublicConfigValues(cfg config.Config) []ConfigValue {
return []ConfigValue{
{ID: "General.ApplicationName", Type: ConfigTypeString, Description: "The name used in messaging and page titles. Defaults to \"GoAlert\".", Value: cfg.General.ApplicationName},
{ID: "General.PublicURL", Type: ConfigTypeString, Description: "Publicly routable URL for UI links and API calls.", Value: cfg.General.PublicURL, Deprecated: "Use --public-url flag instead, which takes precedence."},
{ID: "General.GoogleAnalyticsID", Type: ConfigTypeString, Description: "If set, will post user metrics to the corresponding data stream in Google Analytics 4.", Value: cfg.General.GoogleAnalyticsID},
{ID: "General.NotificationDisclaimer", Type: ConfigTypeString, Description: "Disclaimer text for receiving pre-recorded notifications (appears on profile page).", Value: cfg.General.NotificationDisclaimer},
{ID: "General.DisableMessageBundles", Type: ConfigTypeBoolean, Description: "Disable bundling status updates and alert notifications.", Value: fmt.Sprintf("%t", cfg.General.DisableMessageBundles)},
{ID: "General.ShortURL", Type: ConfigTypeString, Description: "If set, messages will contain a shorter URL using this as a prefix (e.g. http://example.com). It should point to GoAlert and can be the same as the PublicURL.", Value: cfg.General.ShortURL},
{ID: "General.DisableSMSLinks", Type: ConfigTypeBoolean, Description: "If set, SMS messages will not contain a URL pointing to GoAlert.", Value: fmt.Sprintf("%t", cfg.General.DisableSMSLinks)},
{ID: "General.DisableLabelCreation", Type: ConfigTypeBoolean, Description: "Disables the ability to create new labels for services.", Value: fmt.Sprintf("%t", cfg.General.DisableLabelCreation)},
{ID: "General.DisableCalendarSubscriptions", Type: ConfigTypeBoolean, Description: "If set, disables all active calendar subscriptions as well as the ability to create new calendar subscriptions.", Value: fmt.Sprintf("%t", cfg.General.DisableCalendarSubscriptions)},
{ID: "Services.RequiredLabels", Type: ConfigTypeStringList, Description: "List of label names to require new services to define.", Value: strings.Join(cfg.Services.RequiredLabels, "\n")},
{ID: "Maintenance.AlertCleanupDays", Type: ConfigTypeInteger, Description: "Closed alerts will be deleted after this many days (0 means disable cleanup).", Value: fmt.Sprintf("%d", cfg.Maintenance.AlertCleanupDays)},
{ID: "Maintenance.AlertAutoCloseDays", Type: ConfigTypeInteger, Description: "Unacknowledged alerts will automatically be closed after this many days of inactivity. (0 means disable auto-close).", Value: fmt.Sprintf("%d", cfg.Maintenance.AlertAutoCloseDays)},
{ID: "Maintenance.AutoCloseAckedAlerts", Type: ConfigTypeBoolean, Description: "If set, alerts that are acknowledged will also be automatically closed after the configured number of days of inactivity.", Value: fmt.Sprintf("%t", cfg.Maintenance.AutoCloseAckedAlerts)},
{ID: "Maintenance.APIKeyExpireDays", Type: ConfigTypeInteger, Description: "Unused calendar API keys will be disabled after this many days (0 means disable cleanup).", Value: fmt.Sprintf("%d", cfg.Maintenance.APIKeyExpireDays)},
{ID: "Maintenance.ScheduleCleanupDays", Type: ConfigTypeInteger, Description: "Schedule on-call history will be deleted after this many days (0 means disable cleanup).", Value: fmt.Sprintf("%d", cfg.Maintenance.ScheduleCleanupDays)},
{ID: "Auth.DisableBasic", Type: ConfigTypeBoolean, Description: "Disallow username/password login.", Value: fmt.Sprintf("%t", cfg.Auth.DisableBasic)},
{ID: "GitHub.Enable", Type: ConfigTypeBoolean, Description: "Enable GitHub authentication.", Value: fmt.Sprintf("%t", cfg.GitHub.Enable)},
{ID: "OIDC.Enable", Type: ConfigTypeBoolean, Description: "Enable OpenID Connect authentication.", Value: fmt.Sprintf("%t", cfg.OIDC.Enable)},
{ID: "Mailgun.Enable", Type: ConfigTypeBoolean, Description: "", Value: fmt.Sprintf("%t", cfg.Mailgun.Enable)},
{ID: "Slack.Enable", Type: ConfigTypeBoolean, Description: "", Value: fmt.Sprintf("%t", cfg.Slack.Enable)},
{ID: "Twilio.Enable", Type: ConfigTypeBoolean, Description: "Enables sending and processing of Voice and SMS messages through the Twilio notification provider.", Value: fmt.Sprintf("%t", cfg.Twilio.Enable)},
{ID: "Twilio.FromNumber", Type: ConfigTypeString, Description: "The Twilio number to use for outgoing notifications.", Value: cfg.Twilio.FromNumber},
{ID: "Twilio.MessagingServiceSID", Type: ConfigTypeString, Description: "If set, replaces the use of From Number for SMS notifications.", Value: cfg.Twilio.MessagingServiceSID},
{ID: "SMTP.Enable", Type: ConfigTypeBoolean, Description: "Enables email as a contact method.", Value: fmt.Sprintf("%t", cfg.SMTP.Enable)},
{ID: "SMTP.From", Type: ConfigTypeString, Description: "The email address messages should be sent from.", Value: cfg.SMTP.From},
{ID: "Webhook.Enable", Type: ConfigTypeBoolean, Description: "Enables webhook as a contact method.", Value: fmt.Sprintf("%t", cfg.Webhook.Enable)},
{ID: "Webhook.AllowedURLs", Type: ConfigTypeStringList, Description: "If set, allows webhooks for these domains only.", Value: strings.Join(cfg.Webhook.AllowedURLs, "\n")},
{ID: "Feedback.Enable", Type: ConfigTypeBoolean, Description: "Enables Feedback link in nav bar.", Value: fmt.Sprintf("%t", cfg.Feedback.Enable)},
{ID: "Feedback.OverrideURL", Type: ConfigTypeString, Description: "Use a custom URL for Feedback link in nav bar.", Value: cfg.Feedback.OverrideURL},
}
}
// ApplyConfigValues will apply a list of ConfigValues to a Config struct.
func ApplyConfigValues(cfg config.Config, vals []ConfigValueInput) (config.Config, error) {
parseStringList := func(v string) []string {
if v == "" {
return nil
}
return strings.Split(v, "\n")
}
parseInt := func(id, v string) (int, error) {
if v == "" {
return 0, nil
}
val, err := strconv.ParseInt(v, 10, 32)
if err != nil {
return 0, validation.NewFieldError("\""+id+"\".Value", "integer value invalid: "+err.Error())
}
return int(val), nil
}
parseBool := func(id, v string) (bool, error) {
switch v {
case "true":
return true, nil
case "false":
return false, nil
default:
return false, validation.NewFieldError("\""+id+"\".Value", "boolean value invalid: expected 'true' or 'false'")
}
}
for _, v := range vals {
switch v.ID {
case "General.ApplicationName":
cfg.General.ApplicationName = v.Value
case "General.PublicURL":
cfg.General.PublicURL = v.Value
case "General.GoogleAnalyticsID":
cfg.General.GoogleAnalyticsID = v.Value
case "General.NotificationDisclaimer":
cfg.General.NotificationDisclaimer = v.Value
case "General.DisableMessageBundles":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.General.DisableMessageBundles = val
case "General.ShortURL":
cfg.General.ShortURL = v.Value
case "General.DisableSMSLinks":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.General.DisableSMSLinks = val
case "General.DisableLabelCreation":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.General.DisableLabelCreation = val
case "General.DisableCalendarSubscriptions":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.General.DisableCalendarSubscriptions = val
case "Services.RequiredLabels":
cfg.Services.RequiredLabels = parseStringList(v.Value)
case "Maintenance.AlertCleanupDays":
val, err := parseInt(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Maintenance.AlertCleanupDays = val
case "Maintenance.AlertAutoCloseDays":
val, err := parseInt(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Maintenance.AlertAutoCloseDays = val
case "Maintenance.AutoCloseAckedAlerts":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Maintenance.AutoCloseAckedAlerts = val
case "Maintenance.APIKeyExpireDays":
val, err := parseInt(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Maintenance.APIKeyExpireDays = val
case "Maintenance.ScheduleCleanupDays":
val, err := parseInt(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Maintenance.ScheduleCleanupDays = val
case "Auth.RefererURLs":
cfg.Auth.RefererURLs = parseStringList(v.Value)
case "Auth.DisableBasic":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Auth.DisableBasic = val
case "GitHub.Enable":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.GitHub.Enable = val
case "GitHub.NewUsers":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.GitHub.NewUsers = val
case "GitHub.ClientID":
cfg.GitHub.ClientID = v.Value
case "GitHub.ClientSecret":
cfg.GitHub.ClientSecret = v.Value
case "GitHub.AllowedUsers":
cfg.GitHub.AllowedUsers = parseStringList(v.Value)
case "GitHub.AllowedOrgs":
cfg.GitHub.AllowedOrgs = parseStringList(v.Value)
case "GitHub.EnterpriseURL":
cfg.GitHub.EnterpriseURL = v.Value
case "OIDC.Enable":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.OIDC.Enable = val
case "OIDC.NewUsers":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.OIDC.NewUsers = val
case "OIDC.OverrideName":
cfg.OIDC.OverrideName = v.Value
case "OIDC.IssuerURL":
cfg.OIDC.IssuerURL = v.Value
case "OIDC.ClientID":
cfg.OIDC.ClientID = v.Value
case "OIDC.ClientSecret":
cfg.OIDC.ClientSecret = v.Value
case "OIDC.Scopes":
cfg.OIDC.Scopes = v.Value
case "OIDC.UserInfoEmailPath":
cfg.OIDC.UserInfoEmailPath = v.Value
case "OIDC.UserInfoEmailVerifiedPath":
cfg.OIDC.UserInfoEmailVerifiedPath = v.Value
case "OIDC.UserInfoNamePath":
cfg.OIDC.UserInfoNamePath = v.Value
case "Mailgun.Enable":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Mailgun.Enable = val
case "Mailgun.APIKey":
cfg.Mailgun.APIKey = v.Value
case "Mailgun.EmailDomain":
cfg.Mailgun.EmailDomain = v.Value
case "Slack.Enable":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Slack.Enable = val
case "Slack.ClientID":
cfg.Slack.ClientID = v.Value
case "Slack.ClientSecret":
cfg.Slack.ClientSecret = v.Value
case "Slack.AccessToken":
cfg.Slack.AccessToken = v.Value
case "Slack.SigningSecret":
cfg.Slack.SigningSecret = v.Value
case "Slack.InteractiveMessages":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Slack.InteractiveMessages = val
case "Twilio.Enable":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Twilio.Enable = val
case "Twilio.VoiceName":
cfg.Twilio.VoiceName = v.Value
case "Twilio.VoiceLanguage":
cfg.Twilio.VoiceLanguage = v.Value
case "Twilio.AccountSID":
cfg.Twilio.AccountSID = v.Value
case "Twilio.AuthToken":
cfg.Twilio.AuthToken = v.Value
case "Twilio.AlternateAuthToken":
cfg.Twilio.AlternateAuthToken = v.Value
case "Twilio.FromNumber":
cfg.Twilio.FromNumber = v.Value
case "Twilio.MessagingServiceSID":
cfg.Twilio.MessagingServiceSID = v.Value
case "Twilio.DisableTwoWaySMS":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Twilio.DisableTwoWaySMS = val
case "Twilio.SMSCarrierLookup":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Twilio.SMSCarrierLookup = val
case "Twilio.SMSFromNumberOverride":
cfg.Twilio.SMSFromNumberOverride = parseStringList(v.Value)
case "SMTP.Enable":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.SMTP.Enable = val
case "SMTP.From":
cfg.SMTP.From = v.Value
case "SMTP.Address":
cfg.SMTP.Address = v.Value
case "SMTP.DisableTLS":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.SMTP.DisableTLS = val
case "SMTP.SkipVerify":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.SMTP.SkipVerify = val
case "SMTP.Username":
cfg.SMTP.Username = v.Value
case "SMTP.Password":
cfg.SMTP.Password = v.Value
case "Webhook.Enable":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Webhook.Enable = val
case "Webhook.AllowedURLs":
cfg.Webhook.AllowedURLs = parseStringList(v.Value)
case "Feedback.Enable":
val, err := parseBool(v.ID, v.Value)
if err != nil {
return cfg, err
}
cfg.Feedback.Enable = val
case "Feedback.OverrideURL":
cfg.Feedback.OverrideURL = v.Value
default:
return cfg, validation.NewFieldError("ID", fmt.Sprintf("unknown config ID '%s'", v.ID))
}
}
return cfg, nil
}