2020-04-27 21:19:27 +00:00
|
|
|
// Code generated by qtc from "alertmanager_request.qtpl". DO NOT EDIT.
|
|
|
|
// See https://github.com/valyala/quicktemplate for details.
|
|
|
|
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:1
|
2020-04-27 21:19:27 +00:00
|
|
|
package notifier
|
|
|
|
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:1
|
2020-04-27 21:19:27 +00:00
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:7
|
2020-04-27 21:19:27 +00:00
|
|
|
import (
|
|
|
|
qtio422016 "io"
|
|
|
|
|
|
|
|
qt422016 "github.com/valyala/quicktemplate"
|
|
|
|
)
|
|
|
|
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:7
|
2020-04-27 21:19:27 +00:00
|
|
|
var (
|
|
|
|
_ = qtio422016.Copy
|
|
|
|
_ = qt422016.AcquireByteBuffer
|
|
|
|
)
|
|
|
|
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:7
|
2020-04-27 21:19:27 +00:00
|
|
|
func streamamRequest(qw422016 *qt422016.Writer, alerts []Alert, generatorURL func(string, string) string) {
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:7
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`[`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:9
|
2020-04-27 21:19:27 +00:00
|
|
|
for i, alert := range alerts {
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:9
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`{"startsAt":`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:11
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().Q(alert.Start.Format(time.RFC3339Nano))
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:11
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`,"generatorURL":`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:12
|
2020-05-10 16:58:17 +00:00
|
|
|
qw422016.N().Q(generatorURL(strconv.FormatUint(alert.GroupID, 10), strconv.FormatUint(alert.ID, 10)))
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:12
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`,`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:13
|
2020-04-27 21:19:27 +00:00
|
|
|
if !alert.End.IsZero() {
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:13
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`"endsAt":`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:14
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().Q(alert.End.Format(time.RFC3339Nano))
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:14
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`,`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:15
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:15
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`"labels": {"alertname":`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:17
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().Q(alert.Name)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:18
|
2020-04-27 21:19:27 +00:00
|
|
|
for k, v := range alert.Labels {
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:18
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`,`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:19
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().Q(k)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:19
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`:`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:19
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().Q(v)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:20
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:20
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`},"annotations": {`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:23
|
2020-04-27 21:19:27 +00:00
|
|
|
c := len(alert.Annotations)
|
|
|
|
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:24
|
2020-04-27 21:19:27 +00:00
|
|
|
for k, v := range alert.Annotations {
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:25
|
2020-04-27 21:19:27 +00:00
|
|
|
c = c - 1
|
|
|
|
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:26
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().Q(k)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:26
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`:`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:26
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().Q(v)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:26
|
2020-04-27 21:19:27 +00:00
|
|
|
if c > 0 {
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:26
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`,`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:26
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:27
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:27
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`}}`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:30
|
2020-04-27 21:19:27 +00:00
|
|
|
if i != len(alerts)-1 {
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:30
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`,`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:30
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:31
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:31
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016.N().S(`]`)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
|
|
|
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
func writeamRequest(qq422016 qtio422016.Writer, alerts []Alert, generatorURL func(string, string) string) {
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
streamamRequest(qw422016, alerts, generatorURL)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
qt422016.ReleaseWriter(qw422016)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|
|
|
|
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
func amRequest(alerts []Alert, generatorURL func(string, string) string) string {
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
qb422016 := qt422016.AcquireByteBuffer()
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
writeamRequest(qb422016, alerts, generatorURL)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
qs422016 := string(qb422016.B)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
qt422016.ReleaseByteBuffer(qb422016)
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
return qs422016
|
2020-05-16 19:42:33 +00:00
|
|
|
//line app/vmalert/notifier/alertmanager_request.qtpl:33
|
2020-04-27 21:19:27 +00:00
|
|
|
}
|