Skip to content

Commit

Permalink
Merge pull request #297 from jukie/jukie/fix-binpath
Browse files Browse the repository at this point in the history
Fix init function
  • Loading branch information
MatrixCrawler committed Mar 28, 2024
2 parents a487630 + 408dc99 commit 2bda316
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions lib/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,25 @@ var (
installLocation = "/tmp"
)

// initialize : removes existing symlink to terraform binary// I Don't think this is needed
func initialize() {

/* Step 1 */
/* initilize default binary path for terraform */
/* assumes that terraform is installed here */
/* we will find the terraform path instalation later and replace this variable with the correct installed bin path */
installedBinPath := "/usr/local/bin/terraform"
// initialize : removes existing symlink to terraform binary based on provided binPath
func initialize(binPath string) {

/* find terraform binary location if terraform is already installed*/
cmd := NewCommand("terraform")
cmd := NewCommand(binPath)
next := cmd.Find()

/* overrride installation default binary path if terraform is already installed */
/* find the last bin path */
for path := next(); len(path) > 0; path = next() {
installedBinPath = path
binPath = path
}

/* check if current symlink to terraform binary exist */
symlinkExist := CheckSymlink(installedBinPath)
symlinkExist := CheckSymlink(binPath)

/* remove current symlink if exist*/
if symlinkExist {
RemoveSymlink(installedBinPath)
RemoveSymlink(binPath)
}

}
Expand Down Expand Up @@ -90,7 +84,7 @@ func Install(tfversion string, binPath string, mirrorURL string) {
*/
binPath = InstallableBinLocation(binPath)

initialize() //initialize path
initialize(binPath) //initialize path
installLocation = GetInstallLocation() //get installation location - this is where we will put our terraform binary file

goarch := runtime.GOARCH
Expand Down

0 comments on commit 2bda316

Please sign in to comment.