Skip to content

Conversation

@azabbasi
Copy link
Contributor

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

@azabbasi azabbasi requested a review from a team as a code owner April 28, 2020 00:58
@weshaggard
Copy link
Member

PTAL @danieljurek @heaths

$ResourceGroupName = "rg-$BaseName"
}

if (![string]::IsNullOrWhiteSpace($ServiceDirectory)) {
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

@danieljurek
Copy link
Member

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 ServiceDirectory parameter to that documentation

...
# Run tests

- template: /eng/common/TestResources/remove-test-resources.yml 
  parameters:
    ServiceDirectory: '${{ parameters.ServiceDirectory }}'

Copy link
Member

@weshaggard weshaggard left a 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.

@weshaggard weshaggard merged commit 1a69615 into master Apr 29, 2020
@weshaggard weshaggard deleted the azabbasi/UpdateRemoveTestResourcesScript branch April 29, 2020 21:48
@weshaggard
Copy link
Member

@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.

sima-zhu pushed a commit to sima-zhu/azure-sdk-tools that referenced this pull request Dec 3, 2020
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants