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

{RDBMS} az postgres flexible-server create: Fix the comparator for sorting sku name so it also sort the core number too when displaying the error message #30582

Merged
Merged
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
17 changes: 14 additions & 3 deletions src/azure-cli/azure/cli/command_modules/rdbms/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,24 @@ def _pg_tier_validator(tier, sku_info):


def compare_sku_names(sku_1, sku_2):
regex_pattern = r"_v(\d)"
regex_pattern = r"\D+(?P<core_number>\d+)\D+(?P<version>\d*)"

sku_1_match = re.search(regex_pattern, sku_1)
sku_2_match = re.search(regex_pattern, sku_2)

return (int(sku_2_match.group(1)) if sku_2_match else 0) - \
(int(sku_1_match.group(1)) if sku_1_match else 0)
# the case where version number is different, sort by the version number first
if sku_1_match.group('version') and int(sku_2_match.group('version')) > int(sku_1_match.group('version')):
return 1
if sku_1_match.group('version') and int(sku_2_match.group('version')) < int(sku_1_match.group('version')):
return -1

# the case where version number is the same, we want to sort by the core number
if int(sku_2_match.group('core_number')) > int(sku_1_match.group('core_number')):
return 1
if int(sku_2_match.group('core_number')) < int(sku_1_match.group('core_number')):
return -1

return 0


def _pg_sku_name_validator(sku_name, sku_info, tier, instance):
Expand Down
Loading