From 9927bbbea2da41aed06b6d5fed577b06c047240e Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Mon, 14 Nov 2022 07:49:00 -0800 Subject: [PATCH 1/2] fix: switch back to replacing .example.com Fixes #355 --- pkg/config/app.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/pkg/config/app.go b/pkg/config/app.go index 756d5efd..1d25eec3 100644 --- a/pkg/config/app.go +++ b/pkg/config/app.go @@ -2,7 +2,6 @@ package config import ( "fmt" - "html/template" "io/ioutil" "os" "path" @@ -321,25 +320,16 @@ 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 { - return err + err = ioutil.WriteFile(appEnvPath, []byte(newContents), 0) + if err != nil { + panic(err) } logrus.Debugf("copied & templated %s to %s", envSamplePath, appEnvPath) -- 2.49.0 From ad38907a047606d53deccb70b85418d6275d6088 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Mon, 14 Nov 2022 09:58:40 -0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20don't=20panic()=20=F0=9F=98=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/config/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/app.go b/pkg/config/app.go index 1d25eec3..85793b8e 100644 --- a/pkg/config/app.go +++ b/pkg/config/app.go @@ -329,7 +329,7 @@ func TemplateAppEnvSample(recipeName, appName, server, domain string) error { err = ioutil.WriteFile(appEnvPath, []byte(newContents), 0) if err != nil { - panic(err) + return err } logrus.Debugf("copied & templated %s to %s", envSamplePath, appEnvPath) -- 2.49.0