fix: template env files too
continuous-integration/drone/push Build is passing Details

This commit is contained in:
decentral1se 2021-12-26 04:38:34 +01:00
parent f8191ac248
commit c5a74e9f6b
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
2 changed files with 18 additions and 4 deletions

View File

@ -78,6 +78,7 @@ recipe and domain in the sample environment config).
if err != nil {
logrus.Fatal(err)
}
defer file.Close()
tpl, err := template.ParseFiles(path)
if err != nil {

View File

@ -2,6 +2,7 @@ package config
import (
"fmt"
"html/template"
"io/ioutil"
"os"
"path"
@ -260,15 +261,27 @@ func TemplateAppEnvSample(recipeName, appName, server, domain string) error {
return fmt.Errorf("%s already exists?", appEnvPath)
}
envSample = []byte(strings.Replace(string(envSample), fmt.Sprintf("%s.example.com", recipeName), domain, -1))
envSample = []byte(strings.Replace(string(envSample), "example.com", domain, -1))
err = ioutil.WriteFile(appEnvPath, envSample, 0664)
if err != nil {
return err
}
logrus.Debugf("copied %s to %s", envSamplePath, appEnvPath)
file, err := os.OpenFile(appEnvPath, os.O_RDWR, 0664)
if err != nil {
return err
}
defer file.Close()
tpl, err := template.ParseFiles(appEnvPath)
if err != nil {
return err
}
if err := tpl.Execute(file, struct{ Name string }{recipeName}); err != nil {
return err
}
logrus.Debugf("copied & templated %s to %s", envSamplePath, appEnvPath)
return nil
}