Skip to content

Commit

Permalink
added env variable option
Browse files Browse the repository at this point in the history
  • Loading branch information
warrensbox committed Feb 3, 2021
1 parent 25f0e56 commit 96bb53a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ func main() {
installVersion(tfversion, &binPath)
case checkTFModuleFileExist(dir) && len(args) == 0:
installTFProvidedModule(dir, &binPath)
case checkEnvExist() && len(args) == 0 && version == "":
installVersion(os.Getenv("TFVERSION"), custBinPath)
case version != "":
installVersion(version, &binPath)
default:
Expand Down Expand Up @@ -174,6 +176,10 @@ func main() {
case checkTFModuleFileExist(dir) && len(args) == 0:
installTFProvidedModule(dir, custBinPath)

/* if TF environment variable is set */
case checkEnvExist() && len(args) == 0:
installVersion(os.Getenv("TFVERSION"), custBinPath)

// if no arg is provided
default:
listAll := false //set list all false - only official release will be displayed
Expand Down Expand Up @@ -273,6 +279,16 @@ func checkTFModuleFileExist(dir string) bool {
return false
}

// fileExists checks if a file exists and is not a directory before we
// try using it to prevent further errors.
func checkEnvExist() bool {
tfversion := os.Getenv("TFVERSION")
if tfversion != "" {
return true
}
return false
}

/* parses everything in the toml file, return required version and bin path */
func getParamsTOML(binPath string, dir string) (string, string) {
path, _ := homedir.Dir()
Expand Down

0 comments on commit 96bb53a

Please sign in to comment.