add annotation warning to isotime func usage
This commit is contained in:
parent
6986fb0e81
commit
0ecc4b5e52
|
@ -120,6 +120,7 @@ var (
|
||||||
amazonSecretsManagerMap = map[string]map[string]interface{}{}
|
amazonSecretsManagerMap = map[string]map[string]interface{}{}
|
||||||
localsVariableMap = map[string]string{}
|
localsVariableMap = map[string]string{}
|
||||||
timestamp = false
|
timestamp = false
|
||||||
|
isotime = false
|
||||||
)
|
)
|
||||||
|
|
||||||
type BlockParser interface {
|
type BlockParser interface {
|
||||||
|
@ -337,9 +338,11 @@ func transposeTemplatingCalls(s []byte) []byte {
|
||||||
},
|
},
|
||||||
"isotime": func(a ...string) string {
|
"isotime": func(a ...string) string {
|
||||||
if len(a) == 0 {
|
if len(a) == 0 {
|
||||||
return "${legacy_isotime()}"
|
// returns rfc3339 formatted string.
|
||||||
|
return "${timestamp()}"
|
||||||
}
|
}
|
||||||
// otherwise a valid isotime func has one input.
|
// otherwise a valid isotime func has one input.
|
||||||
|
isotime = true
|
||||||
return fmt.Sprintf("${legacy_isotime(\"%s\")}", a[0])
|
return fmt.Sprintf("${legacy_isotime(\"%s\")}", a[0])
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -775,6 +778,9 @@ func (p *LocalsParser) Write(out *bytes.Buffer) {
|
||||||
}
|
}
|
||||||
fmt.Fprintln(out, `locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }`)
|
fmt.Fprintln(out, `locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }`)
|
||||||
}
|
}
|
||||||
|
if isotime {
|
||||||
|
fmt.Fprintln(out, `# The "legacy_isotime" function has been provided for backwards compatability, but we recommend switching to the timestamp and formatdate functions.`)
|
||||||
|
}
|
||||||
if len(p.LocalsOut) > 0 {
|
if len(p.LocalsOut) > 0 {
|
||||||
if p.WithAnnotations {
|
if p.WithAnnotations {
|
||||||
out.Write([]byte(localsVarHeader))
|
out.Write([]byte(localsVarHeader))
|
||||||
|
|
Loading…
Reference in New Issue