-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#16) * Provide a binary without a version reference in the filename #13 (#15) * Fixes #13 - Provide a binary without a version reference in the filename - Set TFVersion on Copy-TerraformBinary (was pulling from Global scope and working somehow.) - Modified Copy-TerraformBinary to support copying existing versioned installations to static installation. - Refactor private function Copy-TerraformBinary to optionally use a ZipPath other defaults to stable path - Renamed Get-TerraformZip to use Get-TerraformBinary in public namespace - Add switch for automatically switch stable path with Set-TerraformVersion is invokved - Tests * Add CHANGELOG.md for issue #13
- Loading branch information
Showing
23 changed files
with
854 additions
and
45 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
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
2 changes: 1 addition & 1 deletion
2
...Terraform/Private/Get-TerraformBinary.ps1 → ...ke-Terraform/Private/Get-TerraformZip.ps1
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Function Get-TerraformBinary { | ||
Function Get-TerraformZip { | ||
param( | ||
[parameter(Mandatory)] | ||
[string]$TFVersion, | ||
|
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,42 @@ | ||
<# | ||
.SYNOPSIS | ||
Get stable path for terraform binary (ie. terraform.exe or terraform) | ||
.DESCRIPTION | ||
Get stable path for terraform binary (ie. terraform.exe or terraform) | ||
.EXAMPLE | ||
Get-TerraformStableBinary | ||
Returns stable path for terraform binary | ||
.INPUTS | ||
None. You cannot pipe objects to Set-TerraformStableBinary. | ||
.OUTPUTS | ||
Returns a path. | ||
.LINK | ||
Set-TerraformStableBinary | ||
.LINK | ||
Online version: https://github.com/pearcec/Invoke-Terraform | ||
#> | ||
function Get-TerraformStableBinary { | ||
|
||
$installPath = (Get-TerraformConfiguration).TFPath | ||
$binary = 'terraform' | ||
if ($isWindows) { | ||
$binary += '.exe' | ||
} | ||
$binPath = Join-Path -Path $installPath -ChildPath $binary | ||
|
||
if (Test-Path $binPath -PathType leaf ) { | ||
return $binPath | ||
} | ||
Write-Error @" | ||
Terraform static binary not set. Run either: | ||
- Set-TerraformStableBinary | ||
or: | ||
- Set-TerraformAutoStableBinary `$true | ||
- Set-TerraformVersion -TFVersion:[TFversion] | ||
or: | ||
- Set-TerraformAutoStableBinary `$true | ||
- Install-Terraform | ||
"@ | ||
throw '' | ||
} |
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,41 @@ | ||
<# | ||
.SYNOPSIS | ||
Set auto switch binary configuration. | ||
.DESCRIPTION | ||
Set auto switch binary configuration. | ||
.PARAMETER AutoStableBinary | ||
Either true or false. | ||
.EXAMPLE | ||
Set-TerraformAutoStableBinary $true | ||
Sets auto switch binary configuration to true | ||
.INPUTS | ||
None. You cannot pipe objects to Set-TerraformAutoStableBinary. | ||
.OUTPUTS | ||
None. Set-TerraformAutoStableBinary returns nothing. | ||
.LINK | ||
Get-TerraformConfiguration | ||
.LINK | ||
Online version: https://github.com/pearcec/Invoke-Terraform | ||
#> | ||
function Set-TerraformAutoStableBinary { | ||
[cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'High')] | ||
param( | ||
[parameter(Mandatory)] | ||
[boolean]$AutoStableBinary | ||
) | ||
begin { | ||
Write-Debug -Message 'Beginning' | ||
$configurationPath = Get-ConfigurationPath | ||
} | ||
|
||
process { | ||
if ($PSCmdlet.ShouldProcess($configurationPath, "Setting AutoStableBinary configuration to $($AutoStableBinary)")) { | ||
Write-Verbose "Setting AutoStableBinary configuration to $($AutoStableBinary)" | ||
Set-TerraformConfiguration @{ AutoStableBinary = $AutoStableBinary } -Confirm:$False | ||
} | ||
} | ||
end { | ||
Write-Debug -Message 'Ending' | ||
} | ||
} |
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,57 @@ | ||
<# | ||
.SYNOPSIS | ||
Set version for stable terraform binary (ie. terraform.exe or terraform) | ||
.DESCRIPTION | ||
Set version for stable terraform binary (ie. terraform.exe or terraform) | ||
.PARAMETER TFVersion | ||
The preferred version. | ||
.PARAMETER SkipChecksum | ||
Skip release archive checksum verification. | ||
.PARAMETER SkipCodeSignature | ||
Skip code signature verifcation. | ||
.EXAMPLE | ||
Set-TerraformStableBinary | ||
Sets the latest terraform version to the static name terraform.exe or terraform | ||
.EXAMPLE | ||
Set-TerraformStableBinary -TFVersion 0.14.7 | ||
Sets terraform version 0.14.7 to the static name terraform.exe or terraform | ||
.INPUTS | ||
None. You cannot pipe objects to Set-TerraformStableBinary. | ||
.OUTPUTS | ||
None. Set-TerraformStableBinary returns nothing. | ||
.LINK | ||
Get-TerraformStableBinary | ||
.LINK | ||
Online version: https://github.com/pearcec/Invoke-Terraform | ||
#> | ||
function Set-TerraformStableBinary { | ||
[cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'High')] | ||
param( | ||
[string]$TFVersion, | ||
[switch]$SkipChecksum = $False, | ||
[switch]$SkipCodeSignature = $False | ||
) | ||
|
||
begin { | ||
Write-Debug -Message 'Beginning' | ||
if (-not $TFVersion) { | ||
$TFVersion = Get-TerraformLatestRelease | ||
} | ||
} | ||
|
||
process { | ||
if ($PSCmdlet.ShouldProcess($configurationPath, "Setting static terraform binary to TFVesion $($TFVersion)")) { | ||
if (-not (Test-TerraformPath -TFVersion $TFVersion)) { | ||
Write-Verbose "Installing terraform version $($TFVersion)" | ||
Install-TerraformBinary -TFVersion $TFVersion -SkipChecksum:$SkipChecksum -SkipCodeSignature:$SkipCodeSignature | ||
} | ||
Copy-TerraformBinary -TFVersion $TFVersion | ||
} | ||
} | ||
|
||
end { | ||
Write-Debug -Message 'Ending' | ||
} | ||
} |
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
Oops, something went wrong.