Remote Alertmanager: Send SMTP config (#106337)
* (WIP) Remote Alertmanager: Send SMTP config * send SMTP configs separately * bring back deleted fields * actually send stuff over * remove redundant type, fix comments * smtp -> smtpConfig * also send SmtpFrom an StaticHeaders separately * tests * restore defaults.ini
This commit is contained in:
@@ -22,8 +22,11 @@ type UserGrafanaConfig struct {
|
||||
Default bool `json:"default"`
|
||||
Promoted bool `json:"promoted"`
|
||||
ExternalURL string `json:"external_url"`
|
||||
SmtpFrom string `json:"smtp_from"`
|
||||
StaticHeaders map[string]string `json:"static_headers"`
|
||||
SmtpConfig SmtpConfig `json:"smtp_config"`
|
||||
|
||||
// TODO: Remove once everything can be sent in the 'SmtpConfig' field.
|
||||
SmtpFrom string `json:"smtp_from"`
|
||||
StaticHeaders map[string]string `json:"static_headers"`
|
||||
}
|
||||
|
||||
func (mc *Mimir) ShouldPromoteConfig() bool {
|
||||
@@ -57,8 +60,11 @@ func (mc *Mimir) CreateGrafanaAlertmanagerConfig(ctx context.Context, cfg *apimo
|
||||
Default: isDefault,
|
||||
Promoted: mc.promoteConfig,
|
||||
ExternalURL: mc.externalURL,
|
||||
SmtpFrom: mc.smtpFrom,
|
||||
StaticHeaders: mc.staticHeaders,
|
||||
SmtpConfig: mc.smtpConfig,
|
||||
|
||||
// TODO: Remove once everything can be sent only in the 'smtp_config' field.
|
||||
SmtpFrom: mc.smtpFrom,
|
||||
StaticHeaders: mc.staticHeaders,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -48,10 +48,25 @@ type Mimir struct {
|
||||
metrics *metrics.RemoteAlertmanager
|
||||
promoteConfig bool
|
||||
externalURL string
|
||||
smtpConfig SmtpConfig
|
||||
|
||||
// TODO: Remove once everything can be sent in the 'smtp' field.
|
||||
smtpFrom string
|
||||
staticHeaders map[string]string
|
||||
}
|
||||
|
||||
type SmtpConfig struct {
|
||||
EhloIdentity string `json:"ehlo_identity"`
|
||||
FromAddress string `json:"from_address"`
|
||||
FromName string `json:"from_name"`
|
||||
Host string `json:"host"`
|
||||
Password string `json:"password"`
|
||||
SkipVerify bool `json:"skip_verify"`
|
||||
StartTLSPolicy string `json:"start_tls_policy"`
|
||||
StaticHeaders map[string]string `json:"static_headers"`
|
||||
User string `json:"user"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
URL *url.URL
|
||||
TenantID string
|
||||
@@ -60,6 +75,9 @@ type Config struct {
|
||||
Logger log.Logger
|
||||
PromoteConfig bool
|
||||
ExternalURL string
|
||||
Smtp SmtpConfig
|
||||
|
||||
// TODO: Remove once everything can be sent in the 'smtp_config' field.
|
||||
SmtpFrom string
|
||||
StaticHeaders map[string]string
|
||||
}
|
||||
@@ -105,6 +123,9 @@ func New(cfg *Config, metrics *metrics.RemoteAlertmanager, tracer tracing.Tracer
|
||||
metrics: metrics,
|
||||
promoteConfig: cfg.PromoteConfig,
|
||||
externalURL: cfg.ExternalURL,
|
||||
smtpConfig: cfg.Smtp,
|
||||
|
||||
// TODO: Remove once everything can be sent in the 'smtp_config' field.
|
||||
smtpFrom: cfg.SmtpFrom,
|
||||
staticHeaders: cfg.StaticHeaders,
|
||||
}, nil
|
||||
|
||||
Reference in New Issue
Block a user