hashicorp/consul-template

Ability to Add time to the timestamp function

wmyre opened this issue · 2 comments

wmyre commented

Consul Template version

consul-template v0.35.0 ()

Configuration

{{ timestamp }}

I'd like the ability to use the Time.Add() Go function to add time to timestamps. This seems difficult to do currently when using pipelines and other functions because of the inability to convert back to proper types. Example if I wanted to get the unix time and add time to the unix time and convert it back to ISO8601 I am unable to because there's no function to convert the int64 type back to a string since Time.Format() expects a string. The easiest solution here seems to be to just add the Time.Add() function

wmyre commented

using a plugin instead.

I think something like the following should work as well:
(adding 123 seconds in this example)

{{ sprig_dateInZone "2006-01-02T15:04:05Z" (sprig_now | sprig_date_modify "+123s") "UTC" }}

which gets rendered as

2023-12-12T17:09:50Z