Skip to content

Commit 0778e5e

Browse files
committed
Lint fixes and tests
1 parent 8197d93 commit 0778e5e

File tree

5 files changed

+9009
-26
lines changed

5 files changed

+9009
-26
lines changed

src/azure-cli/azure/cli/command_modules/rdbms/_params.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,6 @@ def _flexible_server_params(command_group):
10091009
c.argument('principal_type', options_list=['--type', '-t'], default='User', arg_type=get_enum_type(['User', 'Group', 'ServicePrincipal', 'Unknown']), help='Type of the Microsoft Entra administrator.')
10101010
c.argument('identity', help='Name or ID of identity used for Microsoft Entra Authentication.', validator=validate_identity)
10111011

1012-
10131012
# server advanced threat protection settings
10141013
for scope in ['update', 'show']:
10151014
argument_context_string = '{} flexible-server advanced-threat-protection-setting {}'.format(command_group, scope)

src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_commands.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
from azure.cli.command_modules.rdbms.validators import validate_private_endpoint_connection_id
77
from azure.cli.core.commands import CliCommandType
8-
from azure.cli.core.breaking_change import register_command_group_deprecate, register_default_value_breaking_change,\
9-
register_argument_deprecate, register_other_breaking_change, register_logic_breaking_change
8+
from azure.cli.core.breaking_change import register_command_group_deprecate, register_default_value_breaking_change, \
9+
register_argument_deprecate, register_other_breaking_change, register_logic_breaking_change
1010

1111
from azure.cli.command_modules.rdbms._client_factory import (
1212
cf_postgres_flexible_servers,
@@ -39,15 +39,24 @@
3939
# from .validators import db_up_namespace_processor
4040

4141

42-
register_logic_breaking_change('postgres flexible-server create', 'Update default value of "--sku-name"', target_version='May 2025',
43-
detail='The default value will be changed from "Standard_D2s_v3" to a supported sku based on regional capabilities.')
44-
register_default_value_breaking_change('postgres flexible-server create', '--version', '16', '17', target_version='May 2025')
45-
register_default_value_breaking_change('postgres flexible-server create', '--create-default-database', 'Enabled', 'Disabled', target_version='May 2025')
46-
register_argument_deprecate('postgres flexible-server create', '--active-directory-auth', '--microsoft-entra-auth', target_version='May 2025')
47-
register_argument_deprecate('postgres flexible-server update', '--active-directory-auth', '--microsoft-entra-auth', target_version='May 2025')
48-
register_command_group_deprecate('postgres flexible-server ad-admin', redirect='microsoft-entra-admin', target_version='May 2025')
42+
register_logic_breaking_change('postgres flexible-server create', 'Update default value of "--sku-name"',
43+
target_version='May 2025',
44+
detail='The default value will be changed from "Standard_D2s_v3" to a '
45+
'supported sku based on regional capabilities.')
46+
register_default_value_breaking_change('postgres flexible-server create', '--version', '16', '17',
47+
target_version='May 2025')
48+
register_default_value_breaking_change('postgres flexible-server create', '--create-default-database', 'Enabled',
49+
'Disabled', target_version='May 2025')
50+
register_argument_deprecate('postgres flexible-server create', '--active-directory-auth', '--microsoft-entra-auth',
51+
target_version='May 2025')
52+
register_argument_deprecate('postgres flexible-server update', '--active-directory-auth', '--microsoft-entra-auth',
53+
target_version='May 2025')
54+
register_command_group_deprecate('postgres flexible-server ad-admin', redirect='microsoft-entra-admin',
55+
target_version='May 2025')
4956
register_other_breaking_change('postgres flexible-server update', target_version='May 2025',
50-
message='User confirmation will be needed for compute and storage updates that trigger a restart of the VM.')
57+
message='User confirmation will be needed for compute and storage updates '
58+
'that trigger a restart of the VM.')
59+
5160

5261
# pylint: disable=too-many-locals, too-many-statements, line-too-long
5362
def load_flexibleserver_command_table(self, _):

src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def flexible_server_create(cmd, client,
5757
resource_group_name=None, server_name=None,
5858
location=None, backup_retention=None,
5959
sku_name=None, tier=None,
60-
storage_gb=None, version=None, active_directory_auth=None,
60+
storage_gb=None, version=None, active_directory_auth=None, microsoft_entra_auth=None,
6161
admin_name=None, admin_id=None, admin_type=None,
6262
password_auth=None, administrator_login=None, administrator_login_password=None,
6363
tags=None, database_name=None,
@@ -105,7 +105,7 @@ def flexible_server_create(cmd, client,
105105
backup_byok_key=backup_byok_key,
106106
performance_tier=performance_tier,
107107
create_cluster=create_cluster,
108-
password_auth=password_auth, active_directory_auth=active_directory_auth,
108+
password_auth=password_auth, active_directory_auth=active_directory_auth, microsoft_entra_auth=microsoft_entra_auth,
109109
admin_name=admin_name, admin_id=admin_id, admin_type=admin_type,)
110110

111111
cluster = None
@@ -139,7 +139,8 @@ def flexible_server_create(cmd, client,
139139
standby_availability_zone=standby_availability_zone)
140140

141141
is_password_auth_enabled = bool(password_auth is not None and password_auth.lower() == 'enabled')
142-
is_microsoft_entra_auth_enabled = bool(active_directory_auth is not None and active_directory_auth.lower() == 'enabled')
142+
is_microsoft_entra_auth_enabled = bool(active_directory_auth is not None and active_directory_auth.lower() == 'enabled') or \
143+
bool(microsoft_entra_auth is not None and microsoft_entra_auth.lower() == 'enabled')
143144
if is_password_auth_enabled:
144145
administrator_login_password = generate_password(administrator_login_password)
145146

@@ -149,7 +150,7 @@ def flexible_server_create(cmd, client,
149150
backup_byok_identity=backup_byok_identity,
150151
backup_byok_key=backup_byok_key)
151152

152-
auth_config = postgresql_flexibleservers.models.AuthConfig(active_directory_auth=active_directory_auth,
153+
auth_config = postgresql_flexibleservers.models.AuthConfig(active_directory_auth='Enabled' if is_microsoft_entra_auth_enabled else 'Disabled',
153154
password_auth=password_auth)
154155

155156
# Create postgresql
@@ -309,7 +310,7 @@ def flexible_server_update_custom_func(cmd, client, instance,
309310
maintenance_window=None,
310311
byok_identity=None, byok_key=None,
311312
backup_byok_identity=None, backup_byok_key=None,
312-
active_directory_auth=None, password_auth=None,
313+
active_directory_auth=None, microsoft_entra_auth=None, password_auth=None,
313314
private_dns_zone_arguments=None,
314315
public_access=None,
315316
tags=None,
@@ -423,8 +424,8 @@ def flexible_server_update_custom_func(cmd, client, instance,
423424

424425
auth_config = instance.auth_config
425426
administrator_login = instance.administrator_login if instance.administrator_login else None
426-
if active_directory_auth:
427-
auth_config.active_directory_auth = active_directory_auth
427+
if active_directory_auth or microsoft_entra_auth:
428+
auth_config.active_directory_auth = active_directory_auth if active_directory_auth else microsoft_entra_auth
428429
if password_auth:
429430
administrator_login, administrator_login_password = _update_login(server_name, resource_group_name, auth_config,
430431
password_auth, administrator_login, administrator_login_password)

0 commit comments

Comments
 (0)