-
Notifications
You must be signed in to change notification settings - Fork 227
Make Remove-TestResource invoke custom script prior to deletion of the resource group #549
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
Changes from all commits
2ef8dc4
b0ffa5f
bb9a64a
5d33888
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,9 @@ param ( | |
| [Parameter(ParameterSetName = 'Default+Provisioner', Mandatory = $true)] | ||
| [Parameter(ParameterSetName = 'ResourceGroup+Provisioner', Mandatory = $true)] | ||
| [string] $ProvisionerApplicationSecret, | ||
|
|
||
| [Parameter()] | ||
| [string] $ServiceDirectory, | ||
|
|
||
| [Parameter()] | ||
| [ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud')] | ||
|
|
@@ -116,6 +119,15 @@ if (!$ResourceGroupName) { | |
| $ResourceGroupName = "rg-$BaseName" | ||
| } | ||
|
|
||
| if (![string]::IsNullOrWhiteSpace($ServiceDirectory)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check is unnecessary. Put
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed you pushed another commit, but please make this change as well. We want PowerShell to validate as much as possible - not the script.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The advantage of allowing an empty value here is that invocation would be more simple for the contributor... but only if they coincidentally didn't have one of these pre- scripts (in the majority of cases today you don't need to run a pre- script for resource removal). If we do validation here we'll need to update references to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If they don't want to specify it, don't specify the parameter.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for clarifying... I think the correct syntax would take the form of: I'll start updating the template invocations ahead of this change.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You still need the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually think we should not put The more and more dependencies we get on the stuff under
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not a breaking change. It only applies if you specify the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Combining it with the change to the template which pass empty by default will break pipelines until we can get all the users updated to pass something not-empty. We can come back and fix this later once we have updated all the usages. |
||
| $root = [System.IO.Path]::Combine("$PSScriptRoot/../../../sdk", $ServiceDirectory) | Resolve-Path | ||
| $preRemovalScript = Join-Path -Path $root -ChildPath 'remove-test-resources-pre.ps1' | ||
| if (Test-Path $preRemovalScript) { | ||
| Log "Invoking pre resource removal script '$preRemovalScript'" | ||
| &$preRemovalScript -ResourceGroupName $ResourceGroupName @PSBoundParameters | ||
| } | ||
| } | ||
|
|
||
| Log "Deleting resource group '$ResourceGroupName'" | ||
| if (Retry { Remove-AzResourceGroup -Name "$ResourceGroupName" -Force:$Force }) { | ||
| Write-Verbose "Successfully deleted resource group '$ResourceGroupName'" | ||
|
|
@@ -157,6 +169,10 @@ A service principal ID to provision test resources when a provisioner is specifi | |
| .PARAMETER ProvisionerApplicationSecret | ||
| A service principal secret (password) to provision test resources when a provisioner is specified. | ||
|
|
||
| .PARAMETER ServiceDirectory | ||
| A directory under 'sdk' in the repository root - optionally with subdirectories | ||
| specified - in which to discover pre removal script named 'remove-test-resources-pre.json'. | ||
|
|
||
| .PARAMETER Environment | ||
| Name of the cloud environment. The default is the Azure Public Cloud | ||
| ('PublicCloud') | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.