* Add date and tz functions to templates
This commit adds the date and tz functions to templates. This means
users can now format time in a specified format and also change
the timezone to their specific locale.
An example of how these functions work, and can be composed together,
can be seen here:
{{ .StartsAt | tz "Europe/Paris" | date "15:04:05 MST" }}
Signed-off-by: George Robinson <george.robinson@grafana.com>
---------
Signed-off-by: George Robinson <george.robinson@grafana.com>
* Add template/email.tmpl to the clean target
The change ensures that all assets can be regenerated from scratch in
the CI.
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
* Update email assets after #3420
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
---------
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
According to schema.org's faq both https and http are fine, but https is preferred going forward: https://schema.org/docs/faq.html#19
Why am I making this change? To make some security code scanner happy :)
Signed-off-by: Alvin Lin <alvinlin123@gmail.com>
* Add msteams
Signed-off-by: Jack Zhang <jack4zhang@gmail.com>
---------
Signed-off-by: Jack Zhang <jack4zhang@gmail.com>
Signed-off-by: Jack <jack4zhang@gmail.com>
This commit fixes data corruption in templates that use the title
function as it used a shared cases.Title when casers should not
be shared between goroutines. When templates that used the title
function were executed at the same time, data corruption would occur
in the text that was being cased. This is fixed using a separate
caser for each function call.
Add tests to assertDefaultFuncs are thread-safe
Signed-off-by: George Robinson <george.robinson@grafana.com>
* Separate the template creating functions for as-lib use
Fixes#3217
Signed-off-by: Furkan <furkan.turkal@trendyol.com>
---------
Signed-off-by: Furkan <furkan.turkal@trendyol.com>
This commit implements the Stringer interface for Pairs and KVs.
It changes how Pairs are printed in templates from
map[name1:value1 name2:value2] to name1=value1, name2=value2. KVs
work similar, but are first sorted into pairs before being printed.
Signed-off-by: George Robinson <george.robinson@grafana.com>
Cisco's Webex has been one of the most requested notifiers on Grafana for a while now, please see: https://github.com/grafana/grafana/issues/11750#issue-318358659
Given it's straightforward implementation, low maintance overhead and request demand, I think it's worth including this directly in the Alertmanager.
Signed-off-by: gotjosh <josue.abreu@gmail.com>
* Update Go to 1.18
* Update circleci machine image.
* Switch maildev to new upstream image location.
* Update Go modules to 1.17 format.
* Make dependabot monthly to match prometheus/prometheus.
Signed-off-by: SuperQ <superq@gmail.com>
* Automate CSS-inlining for default HTML email template
The original HTML email template was added in `template/email.html`.
It looks like the CSS was manually inlined. Most likely using the
premailer.dialect.ca web form, which is mentioned in the README for
the Mailgun transactional-email-templates project. The resulting HTML
with inlined CSS was then copied into `template/default.tmpl`. This
has resulted in `email.html` and `default.tmpl` diverging at times.
This commit adds build automation to inline the CSS automatically
using [juice][1]. The Go template containing the resulting HTML has
been moved into its own file to avoid the script that performs the CSS
inlining having to parse the `default.tmpl` file to insert it there.
Fixes#1939.
[1]: https://www.npmjs.com/package/juice
Signed-off-by: Brad Ison <bison@xvdf.io>
* Update asset/assets_vfsdata.go
Signed-off-by: Brad Ison <bison@xvdf.io>
Since it's impossible to create a string slice in a Go template by
default, add a function to work around this problem.
The use case is to make it easy to call KV.Remove with an arbitrary
slice inside a template.
Signed-off-by: Vincent Rischmann <vincent@rischmann.fr>
* do not split receiver by slash
I'm not sure why this was originally done, because a slash seems to be perfectly
valid in a receiver definition. The only issue i encountered was that linking
from a fired alert was not working, because of the splitting performed here.
Signed-off-by: Tim Reddehase <tim.reddehase@xing.com>
* urlquery escape Receiver by default for URL
If Receiver is allowed to contain slashes and other special characters
we need to percent encode them properly.
Signed-off-by: Tim Reddehase <tim.reddehase@xing.com>
* rerun make asset/assets_vfsdata.go
Signed-off-by: Tim Reddehase <tim.reddehase@xing.com>
* Migrate from go-bindata to vfsgen
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
* Ensure idempotent generation for vfsgen
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
* asset: update generated files
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
* Fix asset paths for Windows platforms
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
* Regenerate assets
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
* Add vfs wrapper that returns constant mod time
This is identical to what we had with go-bindata and avoids the extra
step of storing the identity of the complete file system in another
location.
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
* Additional cleanup
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
* Include Makefile.common
* Fix the bindata.go files to make the style target happy
* Inline `.PHONY` statements
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
* WECHAT support by ybyang2/berlinsaint
* correct the whitespace
* add some TestFile and modify some naming errors by ybyang2/berlinsaint
* modify wechat retry test expect
* template error
* add newline
Signed-off-by: yb_home <berlinsaint@126.com>
* fmt some pr code
* use the @stuartnelson3 the test-ci-wechat bingdata.go
* notify go add wechat