Skip to content

Commit

Permalink
[ACR] hotfix based on #18786 and #18850 (#18853)
Browse files Browse the repository at this point in the history
  • Loading branch information
00Kai0 authored Jul 14, 2021
1 parent dd328f0 commit a15f723
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 35 deletions.
8 changes: 6 additions & 2 deletions src/azure-cli/azure/cli/command_modules/acr/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ def acr_build(cmd, # pylint: disable=too-many-locals

platform_os, platform_arch, platform_variant = get_validate_platform(cmd, platform)

DockerBuildRequest, PlatformProperties = cmd.get_models('DockerBuildRequest', 'PlatformProperties')
DockerBuildRequest, PlatformProperties = cmd.get_models(
'DockerBuildRequest',
'PlatformProperties',
operation_group='runs')

docker_build_request = DockerBuildRequest(
agent_pool_name=agent_pool_name,
image_names=image_names,
Expand All @@ -119,7 +123,7 @@ def acr_build(cmd, # pylint: disable=too-many-locals
log_template=log_template
)

queued = LongRunningOperation(cmd.cli_ctx)(client_registries.schedule_run(
queued = LongRunningOperation(cmd.cli_ctx)(client_registries.begin_schedule_run(
resource_group_name=resource_group_name,
registry_name=registry_name,
run_request=docker_build_request))
Expand Down
41 changes: 21 additions & 20 deletions src/azure-cli/azure/cli/command_modules/acr/connected_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def acr_connected_registry_create(cmd, # pylint: disable=too-many-locals, too-m
"Enabling the data endpoint might affect your firewall rules.\nTo enable data endpoint run:" +
"\n\taz acr update -n {} --data-endpoint-enabled true".format(registry_name))

ErrorResponseException = cmd.get_models('ErrorResponseException')
from azure.core.exceptions import HttpResponseError as ErrorResponseException
parent = None
mode = mode.capitalize()
if parent_name:
Expand Down Expand Up @@ -129,11 +129,10 @@ def acr_connected_registry_create(cmd, # pylint: disable=too-many-locals, too-m
)

try:
return client.create(subscription_id=subscription_id,
resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name,
connected_registry_create_parameters=connected_registry_create_parameters)
return client.begin_create(resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name,
connected_registry_create_parameters=connected_registry_create_parameters)
except ValidationError as e:
raise CLIError(e)

Expand Down Expand Up @@ -202,10 +201,10 @@ def acr_connected_registry_update(cmd, # pylint: disable=too-many-locals, too-m
)

try:
return client.update(resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name,
connected_registry_update_parameters=connected_registry_update_parameters)
return client.begin_update(resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name,
connected_registry_update_parameters=connected_registry_update_parameters)
except ValidationError as e:
raise CLIError(e)

Expand All @@ -224,7 +223,7 @@ def acr_connected_registry_delete(cmd,
try:
connected_registry = acr_connected_registry_show(
cmd, client, connected_registry_name, registry_name, resource_group_name)
result = client.delete(resource_group_name, registry_name, connected_registry_name)
result = client.begin_delete(resource_group_name, registry_name, connected_registry_name)
sync_token = get_token_from_id(cmd, connected_registry.parent.sync_properties.token_id)
sync_token_name = sync_token.name
sync_scope_map_name = sync_token.scope_map_id.split('/scopeMaps/')[1]
Expand Down Expand Up @@ -264,14 +263,12 @@ def acr_connected_registry_deactivate(cmd,
resource_group_name=None):
_, resource_group_name = validate_managed_registry(
cmd, registry_name, resource_group_name)
subscription_id = get_subscription_id(cmd.cli_ctx)

user_confirmation("Are you sure you want to deactivate the connected registry '{}' in '{}'?".format(
connected_registry_name, registry_name), yes)
return client.deactivate(subscription_id=subscription_id,
resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name)
return client.begin_deactivate(resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name)


def acr_connected_registry_list(cmd,
Expand Down Expand Up @@ -355,7 +352,7 @@ def _create_sync_token(cmd,
sync_token_name = SYNC_TOKEN_NAME.format(connected_registry_name)
logger.warning("If sync token '%s' already exists, it properties will be overwritten", sync_token_name)
Token = cmd.get_models('Token')
poller = token_client.create(
poller = token_client.begin_create(
resource_group_name,
registry_name,
sync_token_name,
Expand Down Expand Up @@ -520,12 +517,16 @@ def _update_repo_permissions(cmd,
return None
current_actions = list(final_actions_set)
logger.warning(msg)
return scope_map_client.update(
ScopeMapUpdateParameters = cmd.get_models('ScopeMapUpdateParameters')
scope_map_update_parameters = ScopeMapUpdateParameters(
description=description,
actions=current_actions
)
return scope_map_client.begin_update(
resource_group_name,
registry_name,
sync_scope_map_name,
description,
current_actions
scope_map_update_parameters
)


Expand Down
9 changes: 6 additions & 3 deletions src/azure-cli/azure/cli/command_modules/acr/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def acr_pack_build(cmd, # pylint: disable=too-many-locals
raise CLIError('Building with Buildpacks requires a valid source location.')

platform_os, platform_arch, platform_variant = get_validate_platform(cmd, platform)
OS = cmd.get_models('OS')
OS = cmd.get_models('OS', operation_group='task_runs')
if platform_os != OS.linux.value.lower():
raise CLIError('Building with Buildpacks is only supported on Linux.')

Expand All @@ -74,7 +74,10 @@ def acr_pack_build(cmd, # pylint: disable=too-many-locals
pack_image_tag=pack_image_tag,
no_pull='--no-pull' if not pull else '')

EncodedTaskRunRequest, PlatformProperties = cmd.get_models('EncodedTaskRunRequest', 'PlatformProperties')
EncodedTaskRunRequest, PlatformProperties = cmd.get_models(
'EncodedTaskRunRequest',
'PlatformProperties',
operation_group='task_runs')

request = EncodedTaskRunRequest(
encoded_task_content=base64.b64encode(yaml_body.encode()).decode(),
Expand All @@ -92,7 +95,7 @@ def acr_pack_build(cmd, # pylint: disable=too-many-locals
agent_pool_name=agent_pool_name
)

queued = LongRunningOperation(cmd.cli_ctx)(client_registries.schedule_run(
queued = LongRunningOperation(cmd.cli_ctx)(client_registries.begin_schedule_run(
resource_group_name=resource_group_name,
registry_name=registry_name,
run_request=request))
Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/acr/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def acr_run(cmd, # pylint: disable=too-many-locals
platform_os, platform_arch, platform_variant = get_validate_platform(cmd, platform)

EncodedTaskRunRequest, FileTaskRunRequest, PlatformProperties = cmd.get_models(
'EncodedTaskRunRequest', 'FileTaskRunRequest', 'PlatformProperties')
'EncodedTaskRunRequest', 'FileTaskRunRequest', 'PlatformProperties', operation_group='runs')

if source_location:
request = FileTaskRunRequest(
Expand Down Expand Up @@ -100,7 +100,7 @@ def acr_run(cmd, # pylint: disable=too-many-locals
log_template=log_template
)

queued = LongRunningOperation(cmd.cli_ctx)(client_registries.schedule_run(
queued = LongRunningOperation(cmd.cli_ctx)(client_registries.begin_schedule_run(
resource_group_name=resource_group_name,
registry_name=registry_name,
run_request=request))
Expand Down
22 changes: 14 additions & 8 deletions src/azure-cli/azure/cli/command_modules/acr/scope_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ def acr_scope_map_create(cmd,

actions = parse_scope_map_actions(repository_actions_list, gateway_actions_list)

scope_map = {
'actions': actions,
'description': description
}
ScopeMap = cmd.get_models('ScopeMap')

scope_map = ScopeMap(
actions=actions,
description=description
)

return client.begin_create(
resource_group_name,
Expand All @@ -68,7 +70,7 @@ def acr_scope_map_delete(cmd,
return None

resource_group_name = get_resource_group_name_by_registry_name(cmd.cli_ctx, registry_name, resource_group_name)
return client.delete(resource_group_name, registry_name, scope_map_name)
return client.begin_delete(resource_group_name, registry_name, scope_map_name)


def acr_scope_map_update(cmd,
Expand Down Expand Up @@ -106,12 +108,16 @@ def acr_scope_map_update(cmd,
final_actions_set = set(current_scope_map.actions).union(add_actions_set).difference(remove_actions_set)
current_actions = list(final_actions_set)

return client.update(
ScopeMapUpdateParameters = cmd.get_models('ScopeMapUpdateParameters')
scope_map_update_parameters = ScopeMapUpdateParameters(
description=description,
actions=current_actions
)
return client.begin_update(
resource_group_name,
registry_name,
scope_map_name,
description,
current_actions
scope_map_update_parameters
)


Expand Down

0 comments on commit a15f723

Please sign in to comment.