Search code examples
kuberneteskubernetes-helm

helm 3 .Release.time.Seconds does not exist


I am now working in the migration from helm 2 to 3.

I am using the value of .Release.time.Seconds in my charts. I have seen that in helm 3 .Release.time does not exists. Trying to use now as it is explained in this stackoverflow question, I can do the instalation, but I do not get the expected value.

For example, with the following code:

 template:
    metadata:
      labels:
        dateInSeconds: "{{ .Release.Time.Seconds }}" 

The label gets the value dateInSeconds: 1611923156

If I use the now function:

 template:
    metadata:
      labels:
        dateInSeconds: {{ now | quote }}  

The label gets the value dateInSeconds: "2021-02-01 12:05:28.6116854 +0100 CET m=+2.394553701"


Solution

  • I have found the solution in sprig. For getting the epoch time I can use unixEpoch.

    So the solution is:

    template:
        metadata:
          labels:
            dateInSeconds: {{ now | unixEpoch | quote}}