forked from toolshed/abra
		
	feat: add templating during .. app new
				
					
				
			Closes coop-cloud/organising#168
This commit is contained in:
		@ -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)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user