forked from coop-cloud/abra
fix: template without weird breakages
This commit is contained in:
parent
c5a74e9f6b
commit
321ba1e0ec
|
@ -1,8 +1,10 @@
|
|||
package recipe
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"text/template"
|
||||
|
@ -74,20 +76,20 @@ recipe and domain in the sample environment config).
|
|||
path.Join(config.RECIPES_DIR, recipeName, ".env.sample"),
|
||||
}
|
||||
for _, path := range toParse {
|
||||
file, err := os.OpenFile(path, os.O_RDWR, 0664)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
tpl, err := template.ParseFiles(path)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := tpl.Execute(file, meta); err != nil {
|
||||
var templated bytes.Buffer
|
||||
if err := tpl.Execute(&templated, meta); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(path, templated.Bytes(), 0644); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
newGitRepo := path.Join(config.RECIPES_DIR, recipeName)
|
||||
|
|
Loading…
Reference in New Issue