コード例 #1
0
// DelSilence deletes the silence with the sid at the given time.
func (am *Alertmanager) DelSilence(at float64, sil *TestSilence) {
	silences := alertmanager.NewSilenceAPI(am.client)

	am.t.Do(at, func() {
		if err := silences.Del(context.Background(), sil.ID); err != nil {
			am.t.Errorf("Error deleting silence %v: %s", sil, err)
		}
	})
}
コード例 #2
0
// SetSilence updates or creates the given Silence.
func (am *Alertmanager) SetSilence(at float64, sil *TestSilence) {
	silences := alertmanager.NewSilenceAPI(am.client)

	am.t.Do(at, func() {
		sid, err := silences.Set(context.Background(), sil.nativeSilence(am.opts))
		if err != nil {
			am.t.Errorf("Error setting silence %v: %s", sil, err)
			return
		}
		sil.ID = sid
	})
}