From 0ecc4b5e52bfa93504695971cf29d4b4b7203499 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 17 Mar 2021 16:06:19 -0700 Subject: [PATCH] add annotation warning to isotime func usage --- command/hcl2_upgrade.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/command/hcl2_upgrade.go b/command/hcl2_upgrade.go index ab6f4ca8d..8f6af2046 100644 --- a/command/hcl2_upgrade.go +++ b/command/hcl2_upgrade.go @@ -120,6 +120,7 @@ var ( amazonSecretsManagerMap = map[string]map[string]interface{}{} localsVariableMap = map[string]string{} timestamp = false + isotime = false ) type BlockParser interface { @@ -337,9 +338,11 @@ func transposeTemplatingCalls(s []byte) []byte { }, "isotime": func(a ...string) string { if len(a) == 0 { - return "${legacy_isotime()}" + // returns rfc3339 formatted string. + return "${timestamp()}" } // otherwise a valid isotime func has one input. + isotime = true 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:]", "") }`) } + 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 p.WithAnnotations { out.Write([]byte(localsVarHeader))