Add method to update Alertmanager configuration file

This commit is contained in:
Fabian Reinartz 2015-10-02 14:14:30 +02:00
parent 5ba2d4abc1
commit aab576c7c0

View File

@ -92,10 +92,7 @@ func (t *AcceptanceTest) Alertmanager(conf string) *Alertmanager {
t.Fatal(err)
}
am.confFile = cf
if _, err := cf.WriteString(conf); err != nil {
t.Fatal(err)
}
am.UpdateConfig(conf)
am.addr = freeAddress()
@ -268,3 +265,16 @@ func (am *Alertmanager) DelSilence(at float64, sil *TestSilence) {
}
})
}
// UpdateConfig rewrites the configuration file for the Alertmanager. It does not
// initiate config reloading.
func (am *Alertmanager) UpdateConfig(conf string) {
if _, err := am.confFile.WriteString(conf); err != nil {
am.t.Error(err)
return
}
if err := am.confFile.Sync(); err != nil {
am.t.Error(err)
return
}
}