Skip to content

Commit f38235a

Browse files
authored
{ACR} az acr check-health: fix check-health command by removing outdated API version gate for CMK check (#33117)
1 parent 96720d3 commit f38235a

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/azure-cli/azure/cli/command_modules/acr/check_health.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ def _get_endpoint_and_token_status(cmd, login_server, registry_abac_enabled, rep
321321

322322

323323
def _check_registry_health(cmd, registry_name, repository, ignore_errors):
324-
from azure.cli.core.profiles import ResourceType
325324
if registry_name is None:
326325
logger.warning("Registry name must be provided to check connectivity.")
327326
return
@@ -349,25 +348,24 @@ def _check_registry_health(cmd, registry_name, repository, ignore_errors):
349348
registry and registry.role_assignment_mode == RoleAssignmentMode.ABAC_REPOSITORY_PERMISSIONS
350349
_get_endpoint_and_token_status(cmd, login_server, registry_abac_enabled, repository, ignore_errors)
351350

352-
if cmd.supported_api_version(min_api='2020-11-01-preview', resource_type=ResourceType.MGMT_CONTAINERREGISTRY): # pylint: disable=too-many-nested-blocks
353-
# CMK settings
354-
if registry and registry.encryption and registry.encryption.key_vault_properties: # pylint: disable=too-many-nested-blocks
355-
client_id = registry.encryption.key_vault_properties.identity
356-
valid_identity = False
357-
if registry.identity:
358-
valid_identity = ((client_id == 'system') and
359-
bool(registry.identity.principal_id)) # use system identity?
360-
if not valid_identity and registry.identity.user_assigned_identities:
361-
for k, v in registry.identity.user_assigned_identities.items():
362-
if v.client_id == client_id:
363-
from azure.core.exceptions import HttpResponseError
364-
try:
365-
valid_identity = resolve_identity_client_id(cmd.cli_ctx, k) == client_id
366-
except HttpResponseError:
367-
pass
368-
if not valid_identity:
369-
from ._errors import CMK_MANAGED_IDENTITY_ERROR
370-
_handle_error(CMK_MANAGED_IDENTITY_ERROR.format_error_message(registry_name), ignore_errors)
351+
# CMK settings
352+
if registry and registry.encryption and registry.encryption.key_vault_properties: # pylint: disable=too-many-nested-blocks
353+
client_id = registry.encryption.key_vault_properties.identity
354+
valid_identity = False
355+
if registry.identity:
356+
valid_identity = ((client_id == 'system') and
357+
bool(registry.identity.principal_id)) # use system identity?
358+
if not valid_identity and registry.identity.user_assigned_identities:
359+
for k, v in registry.identity.user_assigned_identities.items():
360+
if v.client_id == client_id:
361+
from azure.core.exceptions import HttpResponseError
362+
try:
363+
valid_identity = resolve_identity_client_id(cmd.cli_ctx, k) == client_id
364+
except HttpResponseError:
365+
pass
366+
if not valid_identity:
367+
from ._errors import CMK_MANAGED_IDENTITY_ERROR
368+
_handle_error(CMK_MANAGED_IDENTITY_ERROR.format_error_message(registry_name), ignore_errors)
371369

372370

373371
def _check_private_endpoint(cmd, registry_name, vnet_of_private_endpoint): # pylint: disable=too-many-locals, too-many-statements

0 commit comments

Comments
 (0)