-
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
Conversation
|
PTAL @danieljurek @heaths |
| $ResourceGroupName = "rg-$BaseName" | ||
| } | ||
|
|
||
| if (![string]::IsNullOrWhiteSpace($ServiceDirectory)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is unnecessary. Put [ValidateIsNotNullOrEmpty()] on the parameter as well and just use line 123. IT's better to do most validation in PowerShell parameters because it will validate and return correct errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 remove-test-resources.yml in each repo before the PRs that this merge opens get merged or we'll be broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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. ValidateNullOrEmpty only applies if they specify the parameter. That's the norm with well-written PowerShell scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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:
...
[ValidateNotNullOrEmpty()]
[string] $ServiceDirectory,
...
if ($ServiceDirectory) {
$root = [System.IO.Path]::Combine("$PSScriptRoot/../../../sdk", $ServiceDirectory) | Resolve-Path
...
}
I'll start updating the template invocations ahead of this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need the [Parameter()] attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think we should not put ValidateNotNullOrEmpty as that will be a breaking change for all the consumers of our eng\common. So at least initially I'd stick with what we is here right now. We can later decide to fix up all the places and then we can add this if we feel it is interesting.
The more and more dependencies we get on the stuff under eng/common the more we are going to have to be careful about making breaking changes as it will become very difficult to keep things working in all the places if we don't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 -ServiceDirectory. If they didn't (it didn't exist), there's no harm. This is how PowerShell works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
|
This should also include an update to the "In CI" section of https://github.com/Azure/azure-sdk-tools/blob/master/eng/common/TestResources/README.md It should add the |
weshaggard
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @azabbasi for adding this extension point.
|
@azabbasi when this change makes it into your working branch you may need to handle the merge carefully, especially if there are any differences between what you have here and what you committed in your branch. |
…n and using preconditions. (Azure#549) * Update az_span_copy and az_span_append by returning the span and using preconditions. * Update all call sites to span copy, append, append_uint8 across the repo. * Fix tests and appendu32toa bug related to digit_count. * Fix compiler error by explicitly casting sizeof to int32_t. * Fix another compiler error by explicitly casting sizeof to int32_t. * Address feedback. * React to recent changes to master and use new az_span_copy semantics.
Since there are certain actions that might need to be taken prior to deletion of test resources, we will invoke custom scripts in the service directory named : remove-test-resources-pre.ps1