in astro/config.go [105:153]
func setDefaults(config *conf.Project, rootPath string) error {
logger.Trace.Printf("config: setting defaults, rootPath: \"%v\"", rootPath)
// For cases where we're creating a new project that is not from a
// configuration file (e.g. in tests), we'll use the current working
// directory as the root path.
cwd, err := os.Getwd()
if err != nil {
return err
}
if config.TerraformDefaults.Path == "" && config.TerraformDefaults.Version == nil {
if err := config.TerraformDefaults.SetDefaultPath(); err != nil {
return err
}
}
// Terraform code root is the root path of the config file (if it was
// loaded from a file) otherwise is set to the current working dir.
if config.TerraformCodeRoot == "" {
if rootPath != "" {
absRootPath, err := filepath.Abs(rootPath)
if err != nil {
return err
}
config.TerraformCodeRoot = absRootPath
} else {
config.TerraformCodeRoot = cwd
}
}
if config.SessionRepoDir == "" {
if rootPath != "" {
config.SessionRepoDir = rootPath
} else {
config.SessionRepoDir = cwd
}
}
// Fill in module defaults
for i := range config.Modules {
logger.Trace.Printf("config: applying default TerraformCodeRoot: \"%v\"", config.TerraformCodeRoot)
config.Modules[i].Hooks.ApplyDefaultsFrom(config.Hooks)
config.Modules[i].TerraformCodeRoot = config.TerraformCodeRoot
config.Modules[i].Terraform.ApplyDefaultsFrom(config.TerraformDefaults)
}
return nil
}