|
|
|
|
|
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}, |
|
} |
|
} |
|
|
|
|
|
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.RCSSenderID", Type: ConfigTypeString, Description: "The sender ID for RCS messages. Required if RCS is enabled for the MessagingServiceSID.", Value: cfg.Twilio.RCSSenderID}, |
|
{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}, |
|
} |
|
} |
|
|
|
|
|
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}, |
|
} |
|
} |
|
|
|
|
|
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.RCSSenderID": |
|
cfg.Twilio.RCSSenderID = 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 |
|
} |
|
|