I'm struggling with finding a way to include the Release.Time builtin as part of a helm name.
If I just include it as:
name: {{ template "myapp.name" . }}-{{ .Release.Time }}
Dry run shows this:
name: myapp-seconds:1534946206 nanos:143228281
It seems like this is a *timestamp.Timestamp object or something because {{ .Release.Time | trimPrefix "seconds:" | trunc 10 }}
outputs wrong type for value; expected string; got *timestamp.Timestamp
I can hack the string parsing by doing: {{ .Release.Time | toString | trimPrefix "seconds:" | trunc 10 }}
, but it seems like I should be able to call something on the Timestamp object to get the seconds. Is anyone aware of where the docs are for this? I can't find any reference to it at https://godoc.org/github.com/Masterminds/sprig.
The first option was to modify the datastore (ie. ConfigMap in Helm v2 and Secrets in Helm v3) that stores the resource manifest by replacing the existing (incorrect) release name string with the desired (correct) value. Helm v3 stores the resource manifest in a zipped, double base64 encoded secret in the namespace.
{{- (with the dash and space added) indicates that whitespace should be chomped left, while -}} means whitespace to the right should be consumed. Be careful!
trunc 63 truncates it to 63 characters in length.
In my case, by adding the following annotation I was able to achieve this, I am also using helmfile as the wrapper of my helm templates.
annotations:
deploymentTime: {{ now | date "2006-01-02T15:04:05" }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With