mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-25 07:32:19 +00:00
GroupByAll and a duplicate GroupBy were showing up in the marshaled config, which we don't want. Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
This commit is contained in:
parent
34f78c9146
commit
082b1efed0
@ -526,9 +526,9 @@ func (c *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
type Route struct {
|
||||
Receiver string `yaml:"receiver,omitempty" json:"receiver,omitempty"`
|
||||
|
||||
GroupByStr []string `yaml:"group_by,omitempty" json:"group_by,omitempty"`
|
||||
GroupBy []model.LabelName
|
||||
GroupByAll bool
|
||||
GroupByStr []string `yaml:"group_by,omitempty" json:"group_by,omitempty"`
|
||||
GroupBy []model.LabelName `yaml:"-" json:"-"`
|
||||
GroupByAll bool `yaml:"-" json:"-"`
|
||||
|
||||
Match map[string]string `yaml:"match,omitempty" json:"match,omitempty"`
|
||||
MatchRE map[string]Regexp `yaml:"match_re,omitempty" json:"match_re,omitempty"`
|
||||
|
@ -469,6 +469,47 @@ func TestJSONUnmarshal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarshalIdempotency(t *testing.T) {
|
||||
c, _, err := LoadFile("testdata/conf.good.yml")
|
||||
if err != nil {
|
||||
t.Errorf("Error parsing %s: %s", "testdata/conf.good.yml", err)
|
||||
}
|
||||
|
||||
marshaled, err := yaml.Marshal(c)
|
||||
if err != nil {
|
||||
t.Fatal("YAML Marshaling failed:", err)
|
||||
}
|
||||
|
||||
c = new(Config)
|
||||
if err := yaml.Unmarshal(marshaled, c); err != nil {
|
||||
t.Fatal("YAML Unmarshaling failed:", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGroupByAllNotMarshaled(t *testing.T) {
|
||||
in := `
|
||||
route:
|
||||
receiver: team-X-mails
|
||||
group_by: [...]
|
||||
|
||||
receivers:
|
||||
- name: 'team-X-mails'
|
||||
`
|
||||
c, err := Load(in)
|
||||
if err != nil {
|
||||
t.Fatal("load failed:", err)
|
||||
}
|
||||
|
||||
dat, err := yaml.Marshal(c)
|
||||
if err != nil {
|
||||
t.Fatal("YAML Marshaling failed:", err)
|
||||
}
|
||||
|
||||
if strings.Contains(string(dat), "groupbyall") {
|
||||
t.Fatal("groupbyall found in config file")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyFieldsAndRegex(t *testing.T) {
|
||||
boolFoo := true
|
||||
var regexpFoo Regexp
|
||||
|
Loading…
Reference in New Issue
Block a user