-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from dropje86/issue_10
autoloading of files
- Loading branch information
Showing
4 changed files
with
92 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package helper | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/jrasell/levant/logging" | ||
) | ||
|
||
// GetDefaultTmplFile checks the current working directory for *.nomad files. | ||
// If only 1 is found we return the match. | ||
func GetDefaultTmplFile() (templateFile string) { | ||
if matches, _ := filepath.Glob("*.nomad"); matches != nil { | ||
if len(matches) == 1 { | ||
templateFile = matches[0] | ||
logging.Debug("helper/files: using templatefile `%v`", templateFile) | ||
return templateFile | ||
} | ||
} | ||
return "" | ||
} | ||
|
||
// GetDefaultVarFile checks the current working directory for levant.(yaml|yml|tf) files. | ||
// The first match is returned. | ||
func GetDefaultVarFile() (varFile string) { | ||
if _, err := os.Stat("levant.yaml"); !os.IsNotExist(err) { | ||
logging.Debug("helper/files: using default var-file `levant.yaml`") | ||
return "levant.yaml" | ||
} | ||
if _, err := os.Stat("levant.yml"); !os.IsNotExist(err) { | ||
logging.Debug("helper/files: using default var-file `levant.yml`") | ||
return "levant.yml" | ||
} | ||
if _, err := os.Stat("levant.tf"); !os.IsNotExist(err) { | ||
logging.Debug("helper/files: using default var-file `levant.tf`") | ||
return "levant.tf" | ||
} | ||
logging.Debug("helper/files: no default var-file found") | ||
return "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters