fix: switch back to replacing <recipe>.example.com #228

Merged
3wordchant merged 2 commits from unsmart-templating into main 2022-11-24 17:34:01 +00:00
1 changed files with 4 additions and 14 deletions

View File

@ -2,7 +2,6 @@ package config
import (
"fmt"
"html/template"
"io/ioutil"
"os"
"path"
@ -321,24 +320,15 @@ func TemplateAppEnvSample(recipeName, appName, server, domain string) error {
return err
}
file, err := os.OpenFile(appEnvPath, os.O_RDWR, 0664)
if err != nil {
return err
}
defer file.Close()
tpl, err := template.ParseFiles(appEnvPath)
read, err := ioutil.ReadFile(appEnvPath)
if err != nil {
return err
}
type templateVars struct {
Name string
Domain string
}
newContents := strings.Replace(string(read), recipeName+".example.com", domain, -1)
tvars := templateVars{Name: recipeName, Domain: domain}
if err := tpl.Execute(file, tvars); err != nil {
err = ioutil.WriteFile(appEnvPath, []byte(newContents), 0)
if err != nil {
return err
3wordchant marked this conversation as resolved Outdated

return err

`return err`

ugh thought i caught all my half-baked copypasta, fixing!

ugh thought i caught all my half-baked copypasta, fixing!
}