-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* If no TEMPLATE is given as positional arg we scan the working directory for *.nomad files. If only 1 match is found we use that to proceed. * If no -var-file is given we check the working directory for files (in this order) named: - levant.yaml - levant.yml - levant.tf The first match will be used.
- Loading branch information
Yorick Gersie
committed
Dec 12, 2017
1 parent
67e17fe
commit 282b74e
Showing
4 changed files
with
57 additions
and
12 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