Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix init function #294

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ var (
)

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

/* 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"
installedBinPath := binPath + "terraform"
jukie marked this conversation as resolved.
Show resolved Hide resolved

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

/* overrride installation default binary path if terraform is already installed */
Expand Down Expand Up @@ -75,7 +75,7 @@ func GetInstallLocation() string {

}

//Install : Install the provided version in the argument
// Install : Install the provided version in the argument
func Install(tfversion string, binPath string, mirrorURL string) {

// if !ValidVersionFormat(tfversion) {
Expand All @@ -90,7 +90,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 Expand Up @@ -252,15 +252,15 @@ func GetRecentVersions() ([]string, error) {
return nil, nil
}

//CreateRecentFile : create a recent file
// CreateRecentFile : create a recent file
func CreateRecentFile(requestedVersion string) {

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

WriteLines([]string{requestedVersion}, filepath.Join(installLocation, recentFile))
}

//ConvertExecutableExt : convert excutable with local OS extension
// ConvertExecutableExt : convert excutable with local OS extension
func ConvertExecutableExt(fpath string) string {
switch runtime.GOOS {
case "windows":
Expand All @@ -273,8 +273,8 @@ func ConvertExecutableExt(fpath string) string {
}
}

//InstallableBinLocation : Checks if terraform is installable in the location provided by the user.
//If not, create $HOME/bin. Ask users to add $HOME/bin to $PATH and return $HOME/bin as install location
// InstallableBinLocation : Checks if terraform is installable in the location provided by the user.
// If not, create $HOME/bin. Ask users to add $HOME/bin to $PATH and return $HOME/bin as install location
func InstallableBinLocation(userBinPath string) string {

usr, errCurr := user.Current()
Expand Down