Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sprig template functions #3770

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TheMeier
Copy link
Contributor

fixes #3726
fixes #3762
fixes #603

@TheMeier TheMeier force-pushed the issues/3726 branch 2 times, most recently from 9cb7ae1 to 9f54419 Compare March 20, 2024 17:59
@TheMeier
Copy link
Contributor Author

Looks like circleci has a problem :(

@TheMeier
Copy link
Contributor Author

can I get a review @gotjosh

template/template.go Outdated Show resolved Hide resolved
@TheMeier TheMeier force-pushed the issues/3726 branch 2 times, most recently from 7872000 to 5a449ad Compare March 22, 2024 09:54
@TheMeier TheMeier marked this pull request as draft March 23, 2024 14:42
@TheMeier TheMeier marked this pull request as ready for review March 24, 2024 16:21
@TheMeier TheMeier force-pushed the issues/3726 branch 3 times, most recently from 189905b to bb6eb2e Compare March 24, 2024 16:40
@TheMeier
Copy link
Contributor Author

TheMeier commented Mar 24, 2024

Also I noticed the code is actually prepared to allow for users to pass custom functions to the templating.
https://github.com/prometheus/alertmanager/blob/main/template/template.go#L68C23-L70
https://github.com/prometheus/alertmanager/blob/main/template/template_test.go#L406-L468

But that is not accessible from what I have seen in code and docs.
If it is accessible it is a bigger issue if you consider users might use an alertmanager provided by someone else, since the user could execute harmful code. So I wonder if option for template.New and template.FromGlobs should be removed.

@grobinson-grafana
Copy link
Contributor

Also I noticed the code is actually prepared to allow for users to pass custom functions to the templating. https://github.com/prometheus/alertmanager/blob/main/template/template.go#L68C23-L70 https://github.com/prometheus/alertmanager/blob/main/template/template_test.go#L406-L468

But that is not accessible from what I have seen in code and docs. If it is accessible it is a bigger issue if you consider users might use an alertmanager provided by someone else, since the user could execute harmful code. So I wonder if option for template.New and template.FromGlobs should be removed.

This is all internal code. Users cannot add their own functions without changing and re-compiling the code.

@verdel
Copy link

verdel commented Apr 13, 2024

@grobinson-grafana, @TheMeier, how can we speed up the review of this PR?

The functionality to be added, if this PR is accepted, will eliminate a large number of existing limitations. For example, time-related functions will allow for creating links to Grafana dashboards with a time range tied to the time the alert was triggered.

@TheMeier
Copy link
Contributor Author

@grobinson-grafana, @TheMeier, how can we speed up the review of this PR?

The functionality to be added, if this PR is accepted, will eliminate a large number of existing limitations. For example, time-related functions will allow for creating links to Grafana dashboards with a time range tied to the time the alert was triggered.

The only ones who can help here are the maintainers. I guess they are busy with other stuff, so you just have to wait

@verdel
Copy link

verdel commented Apr 15, 2024

The only ones who can help here are the maintainers. I guess they are busy with other stuff, so you just have to wait

Yep, I'll be hoping that they can find the time. This feature would indeed be very useful.

@grobinson-grafana
Copy link
Contributor

While we figure out whether or not to accept sprig, I've opened a PR that adds much requested date and timezone functions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants