forked from coop-cloud/abra
fix: template env files too
This commit is contained in:
parent
f8191ac248
commit
c5a74e9f6b
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue