feat: add templating during `.. app new`
continuous-integration/drone/push Build is failing Details

Closes coop-cloud/organising#168
This commit is contained in:
3wc 2021-09-16 15:04:04 +02:00
parent bece2e8351
commit 754fe81e01
2 changed files with 6 additions and 3 deletions

View File

@ -200,7 +200,7 @@ func action(c *cli.Context) error {
}
logrus.Debugf("'%s' sanitised as '%s' for new app", newAppName, sanitisedAppName)
if err := config.CopyAppEnvSample(recipe.Name, newAppName, newAppServer); err != nil {
if err := config.TemplateAppEnvSample(recipe.Name, newAppName, newAppServer, domain, recipe.Name); err != nil {
logrus.Fatal(err)
}

View File

@ -243,8 +243,8 @@ func GetAppNames() ([]string, error) {
return appNames, nil
}
// CopyAppEnvSample copies the example env file for the app into the users env files
func CopyAppEnvSample(appType, appName, server string) error {
// TemplateAppEnvSample copies the example env file for the app into the users env files
func TemplateAppEnvSample(appType, appName, server, domain, recipe string) error {
envSamplePath := path.Join(ABRA_DIR, "apps", appType, ".env.sample")
envSample, err := ioutil.ReadFile(envSamplePath)
if err != nil {
@ -256,6 +256,9 @@ func CopyAppEnvSample(appType, appName, server string) error {
return fmt.Errorf("%s already exists?", appEnvPath)
}
envSample = []byte(strings.Replace(string(envSample), fmt.Sprintf("%s.example.com", recipe), domain, -1));
envSample = []byte(strings.Replace(string(envSample), "example.com", domain, -1));
err = ioutil.WriteFile(appEnvPath, envSample, 0755)
if err != nil {
return err