Commit Graph

28 Commits

Author SHA1 Message Date
Vincent Rischmann 66a0ed21bd template: add the default template function stringSlice (#2101)
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>
2019-11-13 09:32:51 +00:00
Tim Reddehase d517f786ef Allow slashes in receivers (#2011)
* 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>
2019-08-28 10:01:47 +02:00
stuart nelson e7275537ff
Merge pull request #1945 from kfdm/webhook-fingerprint
Add Fingerprint to template data
2019-07-22 17:02:29 +02:00
Simon Pasquier bb3df011a3
Move break at the beginning fo the for loop (#1928)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-07-04 15:31:09 +02:00
Paul Traylor 6fbbda75ed Add Fingerprint to template data
Signed-off-by: Paul Traylor <paul.traylor@linecorp.com>
2019-06-28 17:35:32 +09:00
Simon Pasquier 3558e6fd9e Migrate from go-bindata to vfsgen (#1532)
* 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>
2018-09-24 15:12:40 +02:00
Waldemar Biller 4e8a910b9d Lookup parts in strings using regexp.MatchString (#1452)
Signed-off-by: Waldemar Biller <wbiller@gmail.com>
2018-07-03 10:55:47 +01:00
stuart nelson a7009a9db7 Stn/add receiver support (#872)
Add ability to filter alerts by receiver in UI. This adds changes both in the Elm UI, as well as the Go backend.
2017-06-26 18:20:26 +02:00
James O'Gorman 00e3b98614 template: Add reReplaceAll function (#639)
This allows for using regexp replacement in templates.
2017-03-04 12:07:31 +00:00
Julius Volz ecd856a401 Add safeHtml template function.
Fixes https://github.com/prometheus/alertmanager/issues/314
2016-04-20 16:17:30 +02:00
Christoph Oelmueller 04b61f6d9a fix template error if no template string is defined 2016-04-01 10:23:34 +02:00
Fabian Reinartz 24b8c22a83 Expose alert interval in template data 2016-02-12 11:00:33 +01:00
Fabian Reinartz 0594d170f6 Upgrade webhook protocol 2016-02-12 10:34:00 +01:00
Fabian Reinartz 897b3a0366 Use missingkey=zero option in templates 2016-02-05 15:41:15 +01:00
Fabian Reinartz 76f884b328 Allow zero matching template files 2015-12-09 14:51:18 +01:00
Fabian Reinartz 4ada2398f2 Set previous inhibition/silence state 2015-12-04 10:58:56 +01:00
Fabian Reinartz 1629e9d166 Statically compile default templates 2015-12-01 18:39:57 +01:00
Fabian Reinartz 6dc397de5c Transfer template functions into types+methods 2015-11-30 18:40:22 +01:00
Brian Brazil 71a1c76e52 Use title rather than toTitle.
It turns out that 'title case' is a thing in unicode,
in the same way upper/lower case is.

What our users will want is the first character of a word
being titlecased, which `title` will do.
2015-11-28 11:08:24 +00:00
Fabian Reinartz 9fbc76a52f Improve PagerDuty templating 2015-11-27 14:02:34 +01:00
Fabian Reinartz 38b6ed118d Iterate over templating 2015-11-26 12:56:09 +01:00
beorn7 93ffa534a5 PR with changes after code review
Now to be reverse-reveiewed.
2015-11-23 18:24:57 +01:00
Brian Brazil faa88831f4 First-pass at improving template system.
- Cut back to bare minimum to make the rest simpler
- Consistency in config naming
- Have one data strucutre that's the same for all templates
- Pass in common labels to templates
- Support templates almost everywhere
- Support multiple SMTP recipients
- Support non-ASCII SMTP headers
- Handle colour logic via templates
- Make $subjects have consistent output, go maps aren't sorted.
- Make tests pass when v6 is disabled
2015-11-18 14:59:05 +00:00
Fabian Reinartz 66488d433b add title and regexp replace template functions 2015-10-12 08:55:20 +02:00
Fabian Reinartz f9f32c7136 Add test for silence deletion 2015-10-12 08:49:49 +02:00
Fabian Reinartz 5dc2f6e9b1 Add license headers 2015-10-11 17:24:49 +02:00
Fabian Reinartz ce74f8363b Simplify initialization
No longer update components based on a new configuration. Generally,
destroying and recreating has no performance impact and is less
error-prone.
This also removes the Reloadable interface and simplifies the entire
startup contraption.
2015-10-11 16:54:39 +02:00
Fabian Reinartz 3a2db95a8e Create and use custom template package 2015-10-11 13:32:24 +02:00