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

Please add arithmetics functions min and max #1157

Open
Garagoth opened this issue Dec 3, 2018 · 1 comment
Open

Please add arithmetics functions min and max #1157

Garagoth opened this issue Dec 3, 2018 · 1 comment

Comments

@Garagoth
Copy link

Garagoth commented Dec 3, 2018

Plaese consider adding min() and max() functions to arithmetic functions.
Currently to get mininum value of two variables I am using:
{{ $res := subtract 1 (or (and (gt ($len_loc) $idx) (add 1 $idx)) ($len_loc)) }}
which is... well, not very readable. (subtract and add are to work around $idx being 0 as or sees this as false value. $len_loc is a length of an array).

And this is just for 2 variables... pipelining this would be a nightmare, as opposed to for example:
min $x | min $y | min $i $j

@thevilledev
Copy link
Contributor

Available since #1323 or consul-template v0.25.0

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

No branches or pull requests

3 participants