Skip to content

Commit 544f3c5

Browse files
authored
Added warning message for cmdlets in Az.Cdn (#17789)
* Adde warning message for cmdlets in Az.Cdn * Add change log * polish warning message
1 parent fc81227 commit 544f3c5

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

src/Cdn/Cdn/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Added breaking change messages for all cmdlets in Az.CDN module
2223

2324
## Version 1.8.2
2425
* Added breaking change messages for upcoming breaking change release of version 2.0.0

src/Cdn/Cdn/Common/AzureCdnCmdletBase.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
using System;
1616
using System.Collections.Generic;
17+
using System.Globalization;
18+
19+
using Microsoft.Azure.Commands.Cdn.Helpers;
1720
using Microsoft.Azure.Commands.Common.Authentication;
1821
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1922
using Microsoft.Azure.Commands.ResourceManager.Common;
@@ -25,7 +28,6 @@ namespace Microsoft.Azure.Commands.Cdn.Common
2528
/// <summary>
2629
/// Base class of Azure Cdn Cmdlet.
2730
/// </summary>
28-
[GenericBreakingChange("When you bump up Az.CDN module version, there will be changes to parameters and output, please use the new version", "2.0.0")]
2931
public class AzureCdnCmdletBase : AzureRMCmdlet
3032
{
3133
private ICdnManagementClient _cdnManagementClient;
@@ -79,5 +81,13 @@ public void ConfirmAction(bool force, string actionMessage, Action action)
7981
action();
8082
}
8183
}
84+
85+
protected override void BeginProcessing()
86+
{
87+
CdnMessageHelper.WriteMessage(this,
88+
$"Breaking changes in the cmdlet: { MyInvocation.InvocationName}" + Environment.NewLine +
89+
"- When you bump up Az.CDN module version, there will be changes to parameters and output, please use the new version: 2.0.0");
90+
base.BeginProcessing();
91+
}
8292
}
8393
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
2+
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Management.Automation;
6+
using System.Text;
7+
8+
namespace Microsoft.Azure.Commands.Cdn.Helpers
9+
{
10+
internal static class CdnMessageHelper
11+
{
12+
private const string SuppressEnvVar = BreakingChangeAttributeHelper.SUPPRESS_ERROR_OR_WARNING_MESSAGE_ENV_VARIABLE_NAME;
13+
14+
private static bool IsMessageSuppressed =>
15+
bool.TryParse(Environment.GetEnvironmentVariable(SuppressEnvVar), out bool result) && result;
16+
17+
internal static void WriteMessage(Cmdlet cmdlet, string message)
18+
{
19+
if (!IsMessageSuppressed)
20+
{
21+
cmdlet.WriteWarning(message);
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)