fix: template without weird breakages
This commit is contained in:
parent
c5a74e9f6b
commit
321ba1e0ec
|
@ -1,8 +1,10 @@
|
||||||
package recipe
|
package recipe
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
@ -74,20 +76,20 @@ recipe and domain in the sample environment config).
|
||||||
path.Join(config.RECIPES_DIR, recipeName, ".env.sample"),
|
path.Join(config.RECIPES_DIR, recipeName, ".env.sample"),
|
||||||
}
|
}
|
||||||
for _, path := range toParse {
|
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)
|
tpl, err := template.ParseFiles(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
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)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := ioutil.WriteFile(path, templated.Bytes(), 0644); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newGitRepo := path.Join(config.RECIPES_DIR, recipeName)
|
newGitRepo := path.Join(config.RECIPES_DIR, recipeName)
|
||||||
|
|
Loading…
Reference in New Issue