--- a/kubectl/command.go Tue Feb 20 16:47:05 2018 -0600
+++ b/kubectl/command.go Tue Feb 20 17:24:04 2018 -0600
@@ -18,6 +18,7 @@
"github.com/aphistic/gomol"
@@ -71,6 +72,45 @@
+func templateEnvironmentFile(filename string, env []string) error { + raw, err := ioutil.ReadFile(filename) + // replace the environment variables in it + data, err := environment.Mapper(string(raw), env) + // write the templated data back out + err = ioutil.WriteFile(filename, []byte(data), 0700) +func templateEnvironmentDirectory(directory string, env []string) error { + files, err := ioutil.ReadDir(directory) + for _, file := range files { + absFile := filepath.Join(directory, file.Name()) + err = templateEnvironmentFile(absFile, env) // templateEnvironment will copy files from the workspace into the scratch
// directory and replace environment variables with those that convey knows
@@ -92,23 +132,21 @@
// figure out the full path to it
absFile := filepath.Join(scratchDir, resolvedFile)
- raw, err := ioutil.ReadFile(absFile)
+ // check if we're looking at a file or a directory + entry, err := os.Stat(absFile) - // replace the environment variables in it
- data, err := environment.Mapper(string(raw), env)
+ err = templateEnvironmentDirectory(absFile, env) + err = templateEnvironmentFile(absFile, env) - // write the templated data back out
- err = ioutil.WriteFile(absFile, []byte(data), 0700)