Skip to content

Commit 4ba8c72

Browse files
committed
docs: better descibe email_config.to fromat
Signed-off-by: Christoph Maser <christoph.maser+github@gmail.com>
1 parent 1eb83c2 commit 4ba8c72

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-5
lines changed

config/config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ receivers:
200200
func TestTimeIntervalHasName(t *testing.T) {
201201
in := `
202202
time_intervals:
203-
- name:
203+
- name:
204204
time_intervals:
205205
- times:
206206
- start_time: '09:00'

config/notifiers_test.go

+43
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ package config
1515

1616
import (
1717
"errors"
18+
"net/mail"
19+
"reflect"
1820
"strings"
1921
"testing"
2022

@@ -60,6 +62,47 @@ headers:
6062
}
6163
}
6264

65+
func TestEmailToAllowsMultipleAdresses(t *testing.T) {
66+
in := `
67+
to: 'a@example.com, ,b@example.com,c@example.com'
68+
`
69+
var cfg EmailConfig
70+
err := yaml.UnmarshalStrict([]byte(in), &cfg)
71+
if err != nil {
72+
t.Fatal(err)
73+
}
74+
75+
expected := []*mail.Address{
76+
{Address: "a@example.com"},
77+
{Address: "b@example.com"},
78+
{Address: "c@example.com"},
79+
}
80+
81+
res, err := mail.ParseAddressList(cfg.To)
82+
if err != nil {
83+
t.Fatal(err)
84+
}
85+
86+
if !reflect.DeepEqual(res, expected) {
87+
t.Fatalf("expected %v, got %v", expected, res)
88+
}
89+
}
90+
91+
func TestEmailDisallowMalformed(t *testing.T) {
92+
in := `
93+
to: 'a@'
94+
`
95+
var cfg EmailConfig
96+
err := yaml.UnmarshalStrict([]byte(in), &cfg)
97+
if err != nil {
98+
t.Fatal(err)
99+
}
100+
_, err = mail.ParseAddressList(cfg.To)
101+
if err == nil {
102+
t.Fatalf("no error returned, expected:\n%v", "mail: no angle-addr")
103+
}
104+
}
105+
63106
func TestPagerdutyTestRoutingKey(t *testing.T) {
64107
t.Run("error if no routing key or key file", func(t *testing.T) {
65108
in := `

docs/configuration.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ You can use this mode if you suspect there is an issue with fallback mode or UTF
487487

488488
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.
489489

490-
Just like Alertmanager server, `amtool` will log a warning if the configuration is incompatible or contains disagreement:
490+
Just like Alertmanager server, `amtool` will log a warning if the configuration is incompatible or contains disagreement:
491491

492492
```
493493
amtool check-config config.yml
@@ -503,7 +503,7 @@ Found:
503503
- 0 templates
504504
```
505505

506-
You will know if a configuration is compatible with UTF-8 strict mode when no warnings are logged in `amtool`:
506+
You will know if a configuration is compatible with UTF-8 strict mode when no warnings are logged in `amtool`:
507507

508508
```
509509
amtool check-config config.yml
@@ -644,7 +644,7 @@ Here are some more examples:
644644
```
645645
646646
As shown below, in the short-form, it's better to use double quotes to avoid problems with special characters like commas:
647-
647+
648648
```yaml
649649
matchers: [ "foo = \"bar,baz\"", "dings != bums" ]
650650
```
@@ -867,6 +867,7 @@ webhook_url_file: <filepath>
867867
[ send_resolved: <boolean> | default = false ]
868868
869869
# The email address to send notifications to.
870+
# Allows a comma separated list of rfc5322 compliant email addresses.
870871
to: <tmpl_string>
871872
872873
# The sender's address.
@@ -1458,6 +1459,6 @@ room_id: <string>
14581459
# Message template.
14591460
[ message: <tmpl_string> default = '{{ template "webex.default.message" .}}' ]
14601461
1461-
# The HTTP client's configuration. You must use this configuration to supply the bot token as part of the HTTP `Authorization` header.
1462+
# The HTTP client's configuration. You must use this configuration to supply the bot token as part of the HTTP `Authorization` header.
14621463
[ http_config: <http_config> | default = global.http_config ]
14631464
```

0 commit comments

Comments
 (0)