fix: template env files too
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
f8191ac248
commit
c5a74e9f6b
|
@ -78,6 +78,7 @@ recipe and domain in the sample environment config).
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
tpl, err := template.ParseFiles(path)
|
tpl, err := template.ParseFiles(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
@ -260,15 +261,27 @@ func TemplateAppEnvSample(recipeName, appName, server, domain string) error {
|
||||||
return fmt.Errorf("%s already exists?", appEnvPath)
|
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)
|
err = ioutil.WriteFile(appEnvPath, envSample, 0664)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue