Skip to content

[Insights] Introduce announced breaking changes, implement ShouldProcess, rename parameters to singluar names and add aliases to keep it non-breaking #4875

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 10 commits into from
Nov 3, 2017

Conversation

gucalder
Copy link
Contributor

@gucalder gucalder commented Oct 27, 2017

Description

  • Deprecation of two cmdlets as announced in April 2017: Get-AzureRmUsage (API not being used), Add-AzureRmLogAlertRule (functionality moved to Azure ActivityLogAlerts API introduced in Ignite)
  • Change the output type of the following cmdlets as announced in April 2017: Get-AzureRmAlertRule (flattening output,) Remove-AzureRmAlertRule (from list to single object,) Get-AzurRmAutoscaleSetting (minor change,) Remove-AzureRmLogProfile (from Boolean to object,) and Get-AzureRmLog, Get-AzureRmAlertHistory, and Get-AzureRmAutoscaleHistory (minor changes)
  • Add the ShouldProcess functionality to these cmdlets Add-AzureRmMetricAlertRule, Add-AzureRmWebtestAlertRule, Remove-AzureRmAlertRule, Add-AzureRmAutoscaleSetting, Remove-AzureRmAutoscaleSetting, Add-AzureRmLogProfile, and Remove-AzureRmLogProfile. Remove the cmdlets from the exceptions list. Keep exceptions for the Force parameter.
  • Add aliases (i.e. singular nouns) to those parameters that are currently using plural nouns. Also add deprecation warnings for the plural names.

This replaces PR #4873 issued from AuxMon organization.


This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

… and adding aliases to keep the change non-breaking, implementing ShouldProcess, announcing deprecation of plural parameter names

# Conflicts:
#	tools/StaticAnalysis/Exceptions/BreakingChangeIssues.csv
@gucalder
Copy link
Contributor Author

I think there are two empty lines at the end of the file Exceptions\BreakingChangeIssues.csv and they are breaking the StaticAnalysis.

@gucalder
Copy link
Contributor Author

I do not know what the issue was this time. It failed very quickly.

Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

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

@gucalder some initial comments

{
// Calling with detailed output
cmdlet.DetailedOutput = true;
cmdlet.ExecuteCmdlet();
Assert.Null(selected); // Incorrect nameOrTargetUri clause with detailed output on
// Assert.Null(selected); // Incorrect nameOrTargetUri clause with detailed output on
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder please remove this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@@ -104,7 +104,8 @@ public class GetAzureRmLogCommand : LogsCmdletBase
/// <returns>The query filter with the conditions for particular parameters added</returns>
protected override string ProcessParticularParameters(string currentQueryFilter)
{
this.SetMaxEventsIfPresent(currentQueryFilter, this.MaxEvents);
WriteWarning("Parameter name change: The parameter plural names for the parameters will be deprecated in May 2018 in favor of the singular versions of the same names.");
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder please update the warning message to include the name of the cmdlet - this will help users running this cmdlet in a script easily find which cmdlet the warning message is coming from. Please do this for all warnings in cmdlets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I am including the cmdlet name in all warning messages.

@@ -53,7 +53,7 @@ public abstract class AddAzureRmAlertRuleCommandBase : ManagementCmdletBase
/// </summary>
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
[ValidateNotNullOrEmpty]
public string ResourceGroup { get; set; }
public string ResourceGroupName { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder please add an alias to ResourceGroup to avoid undocumented breaking changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alias added... everywhere including documentation

@@ -41,7 +41,7 @@ public class GetAzureRmAlertRuleCommand : ManagementCmdletBase
[Parameter(ParameterSetName = GetAzureRmAlertRuleWithNameParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
[Parameter(ParameterSetName = GetAzureRmAlertRuleWithUriParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
[ValidateNotNullOrEmpty]
public string ResourceGroup { get; set; }
public string ResourceGroupName { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder same comment about adding an alias to ResourceGroup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -63,7 +64,7 @@ public class AddAzureRmAutoscaleSettingCommand : ManagementCmdletBase
[Parameter(ParameterSetName = AddAzureRmAutoscaleSettingCreateParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
[Parameter(ParameterSetName = AddAzureRmAutoscaleSettingUpdateParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
[ValidateNotNullOrEmpty]
public string ResourceGroup { get; set; }
public string ResourceGroupName { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder same comment about adding an alias to ResourceGroup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -37,7 +37,7 @@ public class GetAzureRmAutoscaleSettingCommand : ManagementCmdletBase
/// </summary>
[Parameter(ParameterSetName = GetAzureRmAutoscaleSettingParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
[ValidateNotNullOrEmpty]
public string ResourceGroup { get; set; }
public string ResourceGroupName { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder same comment about adding an alias to ResourceGroup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -41,6 +41,7 @@ public class AddAzureRmAutoscaleSettingCommand : ManagementCmdletBase
/// </summary>
[Parameter(ParameterSetName = AddAzureRmAutoscaleSettingUpdateParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The complete spec of an AutoscaleSetting")]
[ValidateNotNullOrEmpty]
[Alias("InputObject")]
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder I would make InputObject the actual name of the parameter and add an alias to SettingSpec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -32,7 +32,7 @@ public class RemoveAzureRmAutoscaleSettingCommand : ManagementCmdletBase
/// </summary>
[Parameter(ParameterSetName = RemoveAzureRmAutoscaleSettingParamGroup, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource group name")]
[ValidateNotNullOrEmpty]
public string ResourceGroup { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder same comment about adding an alias to ResourceGroup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -56,48 +56,57 @@ public class AddAzureRmLogProfileCommand : ManagementCmdletBase
/// </summary>
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The retention in days")]
[ValidateNotNullOrEmpty]
public int? RetentionInDays { get; set; }
[Alias("RetentionInDays")]
public int? RetentionInDay { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder for parameters with units (e.g., InDays, InMinutes, etc.), you don't have to worry about making them singluar

…nto release50ShouldProcOutChange

# Conflicts:
#	src/ResourceManager/Insights/Commands.Insights/help/Add-AzureRmAutoscaleSetting.md
#	src/ResourceManager/Insights/Commands.Insights/help/Add-AzureRmLogAlertRule.md
#	src/ResourceManager/Insights/Commands.Insights/help/Add-AzureRmLogProfile.md
#	src/ResourceManager/Insights/Commands.Insights/help/Add-AzureRmMetricAlertRule.md
#	src/ResourceManager/Insights/Commands.Insights/help/Add-AzureRmWebtestAlertRule.md
#	src/ResourceManager/Insights/Commands.Insights/help/Get-AzureRmAlertRule.md
#	src/ResourceManager/Insights/Commands.Insights/help/Get-AzureRmAutoscaleSetting.md
#	src/ResourceManager/Insights/Commands.Insights/help/Get-AzureRmLog.md
#	src/ResourceManager/Insights/Commands.Insights/help/Get-AzureRmMetric.md
#	src/ResourceManager/Insights/Commands.Insights/help/Get-AzureRmMetricDefinition.md
#	src/ResourceManager/Insights/Commands.Insights/help/Get-AzureRmUsage.md
#	src/ResourceManager/Insights/Commands.Insights/help/New-AzureRmAlertRuleEmail.md
#	src/ResourceManager/Insights/Commands.Insights/help/New-AzureRmAlertRuleWebhook.md
#	src/ResourceManager/Insights/Commands.Insights/help/New-AzureRmAutoscaleNotification.md
#	src/ResourceManager/Insights/Commands.Insights/help/New-AzureRmAutoscaleProfile.md
#	src/ResourceManager/Insights/Commands.Insights/help/New-AzureRmAutoscaleWebhook.md
#	src/ResourceManager/Insights/Commands.Insights/help/Remove-AzureRmAlertRule.md
#	src/ResourceManager/Insights/Commands.Insights/help/Remove-AzureRmAutoscaleSetting.md
#	tools/StaticAnalysis/Exceptions/BreakingChangeIssues.csv
/// <param name="withTimeStamp">true if the message should include a timestamp, false (default) it no timestamp should be included</param>
protected void WriteIdentifiedWarning(string topic, string message, bool withTimeStamp = false)
{
string formattedMessage = Utilities.FormatIdentifiedMessage(
Copy link
Member

@cormacpayne cormacpayne Nov 1, 2017

Choose a reason for hiding this comment

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

@gucalder we are going to be creating our own mechanism for custom obsolete messages and attributes soon, similar to what you are doing here, so we recommend just making this simple for the time being since it will change in the near future ☺️

Rather than using the type of the class, I would just pass in the hard-coded name from the cmdlet itself as another parameter of this function (i.e., string cmdletName, and from the GetAzureRmMetricDefinitionCommand class, you can just call this.WriteIdenfitiedWarning("Get-AzureRmMetricDefinition", "Parameter deprecation", " The DetailedOutput parameter will be deprecated in a future breaking change release").

@@ -72,6 +73,8 @@ protected string ProcessParameters()
/// </summary>
protected override void ProcessRecordInternal()
{
this.WriteIdentifiedWarning("Parameter deprecation", "The DetailedOutput parameter will be deprecated in May 2018.");
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder I would change "May 2018" to "future breaking change release" - even though the next breaking change release should be May 2018, we cannot be 100% positive that is when it is right now

@@ -36,11 +36,11 @@ public abstract class LogsCmdletBase : MonitorClientCmdletBase
private const int MaxNumberOfReturnedRecords = 1000;
private int MaxRecords = 0;

internal const string SubscriptionLevelName = "GetBySubscription";
Copy link
Member

Choose a reason for hiding this comment

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

@gucalder please revert the change made to these parameter set names - we want parameter sets to be singular strings with pascal casing. I'm not sure if this was just changed because of a merge or not.

Copy link
Contributor Author

@gucalder gucalder Nov 1, 2017

Choose a reason for hiding this comment

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

Sorry I did not see this before I pushed the changes for the other comments.
Do you need me to make the names of the constants back to what they were? (I will need to change at least one of them since ResourceGroupName is the name of a parameter now. That's why I change them all.
Or do I need to change the value of the constants?

Copy link
Member

Choose a reason for hiding this comment

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

@gucalder sorry, I made this comment a few hours after when I was looking at a couple of last minute things on this PR. We've received feedback that parameter set names should be a string with no spaces instead of the space-delimited string you are currently using. I recently merged a PR where we fix this in all cmdlets who were using them. If it wouldn't be too much trouble, would you mind revert the set names back to what they were originally, but updating them to reflect the changes you made? That would be great ☺️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok.
The content of each of those constants is now a single string, Pascal casing. I also updated the documentation to reflect that.

Copy link
Member

Choose a reason for hiding this comment

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

@gucalder great, let me know when you push that update out

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 checked the files and I have already pushed all those changes for parameter groups names: they are all single strings, Pascal casing.

@cormacpayne
Copy link
Member

@markcowl markcowl changed the base branch from preview to release-5.0.0 November 2, 2017 23:25
@cormacpayne cormacpayne merged commit baab3b7 into release-5.0.0 Nov 3, 2017
@markcowl markcowl deleted the release50ShouldProcOutChange branch November 14, 2017 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants