in config/stack.go [115:150]
func (s *Stack) findTFFolder(path string) (string, error) {
if s.Config.PathTerraform != "" {
return s.Config.PathTerraform, nil
}
mains := []string{}
err := filepath.Walk(path, func(walkpath string, info os.FileInfo, err error) error {
if info == nil {
return fmt.Errorf("info is nil: walkpath: %s err: %s", walkpath, err)
}
if info.Name() == "main.tf" {
dir := filepath.Dir(walkpath)
mains = append(mains, dir)
return err
}
return nil
})
if err != nil {
return "", fmt.Errorf("findTFFolder: could not find a terraform folder:, %s", err)
}
// I want the top most main file here. And that should be the shortest
sort.Slice(mains, func(i, j int) bool {
return len(mains[i]) < len(mains[j])
})
if len(mains) > 0 {
return filepath.Rel(path, mains[0])
}
return "", nil
}