Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to LibreDevOpsHelpers are recorded here.

## 3.0.1

### Fixed
- `Invoke-LdoTerraformPlanDestroy` now writes `tfplan-destroy.plan` by default, the file
`Invoke-LdoTerraformDestroy` applies by default. It wrote `tfplan.plan.destroy`, so the pair
called with their defaults (as every Libre DevOps module's `just destroy` does) planned one file
and then failed to find the other. A caller that names `-PlanFile` on both is unaffected.

## 3.0.0

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ function Invoke-LdoTerraformPlanDestroy {
Path to the Terraform configuration folder.

.PARAMETER PlanFile
Output plan file name. Defaults to tfplan.plan.destroy.
Output plan file name. Defaults to tfplan-destroy.plan, the file Invoke-LdoTerraformDestroy
applies by default, so the pair works without naming it.

.PARAMETER PlanArgs
Additional arguments passed through to terraform plan.
Expand All @@ -432,7 +433,7 @@ function Invoke-LdoTerraformPlanDestroy {
[OutputType([void])]
param(
[Parameter(Mandatory)][ValidateNotNullOrEmpty()][string]$CodePath,
[string]$PlanFile = 'tfplan.plan.destroy',
[string]$PlanFile = 'tfplan-destroy.plan',
[string[]]$PlanArgs = @()
)

Expand Down Expand Up @@ -538,7 +539,7 @@ function Invoke-LdoTerraformDestroy {
Additional arguments passed through to terraform apply.

.EXAMPLE
Invoke-LdoTerraformDestroy -CodePath ./terraform -PlanFile tfplan.plan.destroy
Invoke-LdoTerraformDestroy -CodePath ./terraform -PlanFile tfplan-destroy.plan

.OUTPUTS
None
Expand Down
2 changes: 1 addition & 1 deletion LibreDevOpsHelpers/LibreDevOpsHelpers.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = '.\LibreDevOpsHelpers.psm1'

# Version number of this module.
ModuleVersion = '3.0.0'
ModuleVersion = '3.0.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
12 changes: 9 additions & 3 deletions tests/Git.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ Describe 'Get-LdoGitBranch / Get-LdoGitRepositoryUrl (CI env)' {
Describe 'Export-LdoGitContextToTfVar' {
BeforeEach {
$script:saved = @{
GITHUB_REF_NAME = $env:GITHUB_REF_NAME
GITHUB_SERVER_URL = $env:GITHUB_SERVER_URL
GITHUB_REPOSITORY = $env:GITHUB_REPOSITORY
GITHUB_HEAD_REF = $env:GITHUB_HEAD_REF
BUILD_SOURCEBRANCHNAME = $env:BUILD_SOURCEBRANCHNAME
GITHUB_REF_NAME = $env:GITHUB_REF_NAME
GITHUB_SERVER_URL = $env:GITHUB_SERVER_URL
GITHUB_REPOSITORY = $env:GITHUB_REPOSITORY
TF_VAR_deployed_branch = $env:TF_VAR_deployed_branch
TF_VAR_deployed_repo = $env:TF_VAR_deployed_repo
}
# A pull request build sets GITHUB_HEAD_REF, which the branch lookup prefers, so clear it
# (and the Azure DevOps one) for the GITHUB_REF_NAME below to be the answer.
$env:GITHUB_HEAD_REF = ''
$env:BUILD_SOURCEBRANCHNAME = ''
$env:GITHUB_REF_NAME = 'main'
$env:GITHUB_SERVER_URL = 'https://github.com'
$env:GITHUB_REPOSITORY = 'libre-devops/terraform-azurerm-tags'
Expand Down
12 changes: 12 additions & 0 deletions tests/Terraform.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ Describe 'Terraform module surface' {
}
}

Describe 'Destroy plan file defaults' {
It 'plans the file the destroy applies, so the pair works without naming it' {
$default = {
param([string]$Command)
$parameters = (Get-Command $Command).ScriptBlock.Ast.Body.ParamBlock.Parameters
($parameters | Where-Object { $_.Name.VariablePath.UserPath -eq 'PlanFile' }).DefaultValue.Value
}
& $default 'Invoke-LdoTerraformPlanDestroy' | Should -Be 'tfplan-destroy.plan'
& $default 'Invoke-LdoTerraformDestroy' | Should -Be (& $default 'Invoke-LdoTerraformPlanDestroy')
}
}

Describe 'Invoke-LdoTerraformValidate' {
It 'throws when the code path does not exist' {
{ Invoke-LdoTerraformValidate -CodePath (Join-Path ([System.IO.Path]::GetTempPath()) ([guid]::NewGuid())) } |
Expand Down
Loading