docs: better descibe `email_config.to` fromat (#3760)

Signed-off-by: Christoph Maser <christoph.maser+github@gmail.com>
This commit is contained in:
Christoph Maser 2024-03-14 13:56:31 +01:00 committed by GitHub
parent 54af8b59ab
commit f82574a376
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 49 additions and 5 deletions

View File

@ -200,7 +200,7 @@ receivers:
func TestTimeIntervalHasName(t *testing.T) { func TestTimeIntervalHasName(t *testing.T) {
in := ` in := `
time_intervals: time_intervals:
- name: - name:
time_intervals: time_intervals:
- times: - times:
- start_time: '09:00' - start_time: '09:00'

View File

@ -15,6 +15,8 @@ package config
import ( import (
"errors" "errors"
"net/mail"
"reflect"
"strings" "strings"
"testing" "testing"
@ -60,6 +62,47 @@ headers:
} }
} }
func TestEmailToAllowsMultipleAdresses(t *testing.T) {
in := `
to: 'a@example.com, ,b@example.com,c@example.com'
`
var cfg EmailConfig
err := yaml.UnmarshalStrict([]byte(in), &cfg)
if err != nil {
t.Fatal(err)
}
expected := []*mail.Address{
{Address: "a@example.com"},
{Address: "b@example.com"},
{Address: "c@example.com"},
}
res, err := mail.ParseAddressList(cfg.To)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(res, expected) {
t.Fatalf("expected %v, got %v", expected, res)
}
}
func TestEmailDisallowMalformed(t *testing.T) {
in := `
to: 'a@'
`
var cfg EmailConfig
err := yaml.UnmarshalStrict([]byte(in), &cfg)
if err != nil {
t.Fatal(err)
}
_, err = mail.ParseAddressList(cfg.To)
if err == nil {
t.Fatalf("no error returned, expected:\n%v", "mail: no angle-addr")
}
}
func TestPagerdutyTestRoutingKey(t *testing.T) { func TestPagerdutyTestRoutingKey(t *testing.T) {
t.Run("error if no routing key or key file", func(t *testing.T) { t.Run("error if no routing key or key file", func(t *testing.T) {
in := ` in := `

View File

@ -487,7 +487,7 @@ You can use this mode if you suspect there is an issue with fallback mode or UTF
You can use `amtool` to validate that an Alertmanager configuration file is compatible with UTF-8 strict mode before enabling it in Alertmanager server. You do not need a running Alertmanager server to do this. You can use `amtool` to validate that an Alertmanager configuration file is compatible with UTF-8 strict mode before enabling it in Alertmanager server. You do not need a running Alertmanager server to do this.
Just like Alertmanager server, `amtool` will log a warning if the configuration is incompatible or contains disagreement: Just like Alertmanager server, `amtool` will log a warning if the configuration is incompatible or contains disagreement:
``` ```
amtool check-config config.yml amtool check-config config.yml
@ -503,7 +503,7 @@ Found:
- 0 templates - 0 templates
``` ```
You will know if a configuration is compatible with UTF-8 strict mode when no warnings are logged in `amtool`: You will know if a configuration is compatible with UTF-8 strict mode when no warnings are logged in `amtool`:
``` ```
amtool check-config config.yml amtool check-config config.yml
@ -644,7 +644,7 @@ Here are some more examples:
``` ```
As shown below, in the short-form, it's better to use double quotes to avoid problems with special characters like commas: As shown below, in the short-form, it's better to use double quotes to avoid problems with special characters like commas:
```yaml ```yaml
matchers: [ "foo = \"bar,baz\"", "dings != bums" ] matchers: [ "foo = \"bar,baz\"", "dings != bums" ]
``` ```
@ -867,6 +867,7 @@ webhook_url_file: <filepath>
[ send_resolved: <boolean> | default = false ] [ send_resolved: <boolean> | default = false ]
# The email address to send notifications to. # The email address to send notifications to.
# Allows a comma separated list of rfc5322 compliant email addresses.
to: <tmpl_string> to: <tmpl_string>
# The sender's address. # The sender's address.
@ -1458,6 +1459,6 @@ room_id: <string>
# Message template. # Message template.
[ message: <tmpl_string> default = '{{ template "webex.default.message" .}}' ] [ message: <tmpl_string> default = '{{ template "webex.default.message" .}}' ]
# The HTTP client's configuration. You must use this configuration to supply the bot token as part of the HTTP `Authorization` header. # The HTTP client's configuration. You must use this configuration to supply the bot token as part of the HTTP `Authorization` header.
[ http_config: <http_config> | default = global.http_config ] [ http_config: <http_config> | default = global.http_config ]
``` ```