File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import (
2222 "io/ioutil"
2323 "os"
2424 "strings"
25+ "time"
2526
2627 "github.com/spf13/cobra"
2728 "gopkg.in/yaml.v2"
@@ -123,15 +124,32 @@ func varsToMap(vars []string) map[string]string {
123124 return varMap
124125}
125126
127+ func systemVars () map [string ]string {
128+ sysMap := make (map [string ]string )
129+
130+ currentTime := time .Now ()
131+
132+ sysMap ["YYYY" ] = fmt .Sprintf ("%0.4d" , currentTime .Year ())
133+ sysMap ["MM" ] = fmt .Sprintf ("%0.2d" , currentTime .Month ())
134+ sysMap ["DD" ] = fmt .Sprintf ("%0.2d" , currentTime .Day ())
135+ sysMap ["HH" ] = fmt .Sprintf ("%0.2d" , currentTime .Hour ())
136+ sysMap ["MM" ] = fmt .Sprintf ("%0.2d" , currentTime .Minute ())
137+ sysMap ["SS" ] = fmt .Sprintf ("%0.2d" , currentTime .Second ())
138+
139+ return sysMap
140+ }
141+
126142func processTemplate (varSliceFlag []string , planYaml []byte ) ([]byte , error ) {
127143 type TemplateVars struct {
128144 Var map [string ]string
129145 Env map [string ]string
146+ Sys map [string ]string
130147 }
131148
132149 tmplVars := & TemplateVars {
133150 Var : varsToMap (varSliceFlag ),
134151 Env : envToMap (),
152+ Sys : systemVars (),
135153 }
136154
137155 var tmplBytes bytes.Buffer
You can’t perform that action at this time.
0 commit comments