将发布时间戳附加到头盔模板名称

Adv*_*bly 7 kubernetes kubernetes-helm

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.

abi*_*net 5

要格式化时间戳记,可以date FORMAT TIME从sprig doc 使用:

{{ date "20060102150405" .Release.Time }}

请参阅此处的格式选项http://golang.org/src/pkg/time/format.go

但是由于升级,以时间戳记名称不是一个好主意。

  • 对于像我一样不熟悉的人来说,Helm 是用 Go 语言编写的,因此他指向 Go 文档。奇怪的“20060102150405”实际上是要使用的时间格式,Go 似乎将其时间格式基于此示例日期“Mon Jan 2 15:04:05 MST 2006”,因此您只需重写该日期即可,无论您想要什么格式化。至少这是我的理解... (4认同)
  • 告诉您不要在名称中使用时间戳,但是我实际上并没有将其用作Web应用程序的名称-实际上是将其用作图表的名称的,图表的名称仅在安装后才部署一次性作业以运行特定的性能测试在堆栈上。 (3认同)