Skip to content
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

[Az.Resources] change version commparator from double to version #13559

Merged
merged 3 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Resources/Resources.sln
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Global
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.Build.0 = Release|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Release|Any CPU.Build.0 = Release|Any CPU
{6BD4D521-DAFB-472B-A803-81F053AB1396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6BD4D521-DAFB-472B-A803-81F053AB1396}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6BD4D521-DAFB-472B-A803-81F053AB1396}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
1 change: 1 addition & 0 deletions src/Resources/Resources/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Fixed an issue where What-If shows two resource group scopes with different casing
* Updated `Export-AzResourceGroup` to use the SDK.
* Added culture info to parse methods
* Changed Double parser for version parser

## Version 3.0.0
* Fixed parsing bug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ public override void ExecuteCmdlet()
}
// ensure that if ConditionVersion is empty in any way, it becomes null
ConditionVersion = string.IsNullOrEmpty(ConditionVersion) ? null : string.IsNullOrWhiteSpace(ConditionVersion) ? null : ConditionVersion;
double _conditionVersion = double.Parse(ConditionVersion ?? "2.0", CultureInfo.InvariantCulture);
if (_conditionVersion < 2.0)
var _conditionVersion = Version.Parse(ConditionVersion ?? "2.0");
if (_conditionVersion.Major < 2)
{
WriteExceptionError(new ArgumentException("Argument -ConditionVersion must be greater or equal than 2.0"));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ public override void ExecuteCmdlet()
}

// If ConditionVersion is changed, validate it's in the allowed values
var oldConditionVersion = double.Parse(InputObject.ConditionVersion ?? "0.0");
var newConditionVersion = double.Parse(fetchedRole.ConditionVersion ?? "2.0");
var oldConditionVersion = Version.Parse(InputObject.ConditionVersion ?? "0.0");
var newConditionVersion = Version.Parse(fetchedRole.ConditionVersion ?? "2.0");

// A condition version can change but currently we don't support downgrading to 1.0
// we only verify the change if it's a downgrade
if ((oldConditionVersion > newConditionVersion) && (newConditionVersion < 2.0))
if ((oldConditionVersion > newConditionVersion) && (newConditionVersion.Major < 2))
{
throw new ArgumentException("Condition version different than '2.0' is not supported for update operations");
}
Expand Down