Skip to content

CDN - PowerShell Functionality and Doc Improvements #2687

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

Merged
merged 14 commits into from
Aug 2, 2016
Merged

Conversation

CamSoper
Copy link
Contributor

Made a ton of improvements for usability and documentation.

  • Modified all "Get-" cmdlets to return collections where a specific resource wasn't named.
  • Modified all cmdlets to accept pipeline input objects. E.g., Get-AzureRmCdnProfile now returns all profiles a user has access to. Get-AzureRmCdnProfile | Get-AzureRmCdnEndpoint will list all endpoints on all profiles a user has access to. Get-AzureRmCdnProfile | Get-AzureRmCdnEndpoint | Get-AzureRmCdnCustomDomain will list all the custom domains. Etc., etc.
  • Modified collection outputs to enumerate properly for Where-Object and ForEach-Object
  • Cleaned up cmdlet parameter help for grammar and consistency
  • Cleaned up help XML for grammar and consistency.
  • Refactored anyplace that was using exceptions for flow control, since this is generally frowned upon.
  • Annotated my commits.
  • Created new tests for improved pipeline functionality
  • Re-recorded all test sessions.

Still to-do: The help XML needs Examples.

@kuangweizhang

@azurecla
Copy link

Hi @CamSoper, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution!


It looks like you're working at Microsoft (casoper). If you're full-time, we DON'T require a contribution license agreement.



If you are a vendor, DO please sign the electronic contribution license agreement. It will take 2 minutes and there's no faxing! https://cla.azure.com.

TTYL, AZPRBOT;

@azuresdkci
Copy link

Can one of the admins verify this patch?

@hovsepm
Copy link
Contributor

hovsepm commented Jul 29, 2016

@azuresdkci add to whitelist

@@ -9,7 +9,7 @@
@{

# Version number of this module.
ModuleVersion = '1.0.5'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert this change. It is part of our process to update versions in each release.

@hovsepm
Copy link
Contributor

hovsepm commented Jul 29, 2016

revert version change.


Refers to: src/ResourceManager/Cdn/Commands.Cdn/Properties/AssemblyInfo.cs:30 in a669f26. [](commit_id = a669f26, deletion_comment = False)

@CamSoper
Copy link
Contributor Author

Should be fixed now. Sorry about that, @hovsepm !

@markcowl
Copy link
Member

markcowl commented Jul 29, 2016

@CamSoper Test failures, looks like some tests need to be re-recorded

@CamSoper
Copy link
Contributor Author

@markcowl Light is green, trap is clean!

@CamSoper
Copy link
Contributor Author

@kuangweizhang - @hovsepm needs you to bless this, please. :)

Thanks!


var existingCustomDomain = CdnManagementClient.CustomDomains.ListByEndpoint(EndpointName, ProfileName, ResourceGroupName).Where(cd => cd.Name == CustomDomainName).FirstOrDefault();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should ignore case when compare the custom domain name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment for other places

@kuangweizhang
Copy link

Just some comments on comparing the name of the resources, otherwise, LGTM

@CamSoper
Copy link
Contributor Author

Thanks, @kuangweizhang!

Implemented the changes as suggested. Should be good to merge, I think.

$endpointName = "sdktest-cee91bb1-996a-44f1-96e6-dceaa6707def"
$hostName = "sdktest-3acbafc1-3f50-4fa4-9132-6d8c944d67e9.azureedge-test.net"
$customDomainName = getAssetName
$endpointName = "sdktest-b0939e74-75ba-4558-afe6-edc5c19ea713"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best practice is to make setup part of test execution, so that these values do not have to be updated whenever the test is re-recorded. Please file an issue to do setup as part of test execution

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get what you're saying, and believe me, I wanted to do this differently too, however the two CustomDomain tests rely on a non-injectable outside resource - a DNS CNAME that must be setup manually on DNS. That's why the original authors ( @kuangweizhang ? Qinyuan? ) did it this way.

@@ -18,38 +18,61 @@
using Microsoft.Azure.Commands.Cdn.Models.CustomDomain;
using Microsoft.Azure.Commands.Cdn.Properties;
using Microsoft.Azure.Management.Cdn;
using System.Linq;
using Microsoft.Azure.Commands.Cdn.Models.Endpoint;

namespace Microsoft.Azure.Commands.Cdn.CustomDomain
{
[Cmdlet(VerbsCommon.Get, "AzureRmCdnCustomDomain"), OutputType(typeof(PSCustomDomain))]
public class GetAzureRmCdnCustomDomain : AzureCdnCmdletBase
Copy link
Member

@markcowl markcowl Aug 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all cmdlets where you are adding a parameter set - you need to have a DefaultParameterSetName promprty in your Cmdlet attribute. And to avoid breaks, this should match the parameter set name containign the previous cmdlet parameters

@markcowl
Copy link
Member

markcowl commented Aug 1, 2016

@CamSoper Some comments, three things that apply across the board:

(1) Your remove cmdlets must not use the pattern Force || ShouldProcess, this prevents ConfirmPreference and WhatIf parameters from working correctly. The best option would be to remove the ConfirmImpact.High and simply use ShouldProcess to determine whether a prompt occurs. This doesn't show a prompt unless the user asks for it bu lowering ConfirmPreference or specifying -Confirm. A less good option would be to remove ConfirmImpact.High and use

If (ShouldProcess(targe, message)) {
   if (Force || ShouldContinue(shouldContinuePrompt)) {
   ... cmdlet execution
  }
}

This acts as above, except that, in addition, the ShouldContinue prompt always occurs unless the user specifies - Force.
An even less good option would be to use only ShouldProcess with ConfirmImpact.High. This requires users to specify -Conforim:$false to avoid prompting. You can see: https://gist.github.com/markcowl/338e16fe5c8bbf195aff9f8af0db585d for a more detailed dscussion.

(2) For any cmdlet where you have added a parameter set, the DefaultParameterSetName property og the Cmdlet attribute should be set to the old parameter set, this avoids breaking changes (and you should always have a default parameter set if there is more thna one)

(3) For any cmdlet you ar5e changing that makes a change or has side effects, I have asked for supporting the SHouldProcess pattern - this allows users to execute the cmdlet with -WhatIf to determine what it would do if executed.

@markcowl
Copy link
Member

markcowl commented Aug 2, 2016

on demand run here:http://azuresdkci.cloudapp.net/view/1-AzurePowerShell/job/powershell-demand/1058/

LGTM once the tests pass.

@markcowl markcowl merged commit 698277c into Azure:dev Aug 2, 2016
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.

6 participants