From d4a438223dd9910521addf63c3232ae53d9f99bf Mon Sep 17 00:00:00 2001 From: Sylvia Lei Date: Fri, 17 Jan 2020 12:54:36 +0800 Subject: [PATCH 1/3] prompt for user confirmation when delete registry --- src/azure-cli/azure/cli/command_modules/acr/custom.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/acr/custom.py b/src/azure-cli/azure/cli/command_modules/acr/custom.py index fdaf39bbd50..1be3bd934d8 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acr/custom.py @@ -11,7 +11,8 @@ get_registry_by_name, validate_managed_registry, validate_sku_update, - get_resource_group_name_by_registry_name + get_resource_group_name_by_registry_name, + user_confirmation ) from ._docker_utils import get_login_credentials from .network_rule import NETWORK_RULE_NOT_SUPPORTED @@ -68,7 +69,7 @@ def acr_create(cmd, def acr_delete(cmd, client, registry_name, resource_group_name=None): - logger.warning('To avoid accidental removal, in a future release "az acr delete" will prompt for confirmation') + user_confirmation("Are you sure you want to delete the registry '{}'?".format(registry_name)) 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) From 22733f1e456363e8a7e597c10aa51978e60dc4c9 Mon Sep 17 00:00:00 2001 From: Sylvia Lei Date: Fri, 17 Jan 2020 18:39:30 +0800 Subject: [PATCH 2/3] modify the implementation of confirmation for acr_delete, also modify tests accordingly --- src/azure-cli/azure/cli/command_modules/acr/custom.py | 4 ++-- .../command_modules/acr/tests/latest/test_acr_commands.py | 6 +++--- .../acr/tests/latest/test_acr_network_rule_commands.py | 2 +- .../acr/tests/latest/test_acr_task_commands.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/acr/custom.py b/src/azure-cli/azure/cli/command_modules/acr/custom.py index 1be3bd934d8..43171e7888f 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acr/custom.py @@ -68,8 +68,8 @@ def acr_create(cmd, return lro_poller -def acr_delete(cmd, client, registry_name, resource_group_name=None): - user_confirmation("Are you sure you want to delete the registry '{}'?".format(registry_name)) +def acr_delete(cmd, client, registry_name, resource_group_name=None, yes=False): + user_confirmation("Are you sure you want to delete the registry '{}'?".format(registry_name), yes) 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) diff --git a/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands.py b/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands.py index c85bbd26888..b60ac8d7fb2 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands.py +++ b/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands.py @@ -80,7 +80,7 @@ def _core_registry_scenario(self, registry_name, resource_group, location): assert password2 != renewed_password2 # test acr delete - self.cmd('acr delete -n {} -g {}'.format(registry_name, resource_group)) + self.cmd('acr delete -n {} -g {} -y'.format(registry_name, resource_group)) def test_check_name_availability(self): # the chance of this randomly generated name has a duplication is rare @@ -178,7 +178,7 @@ def test_acr_create_webhook(self, resource_group, resource_group_location): # test webhook delete self.cmd('acr webhook delete -n {webhook_name} -r {registry_name}') # test acr delete - self.cmd('acr delete -n {registry_name} -g {rg}') + self.cmd('acr delete -n {registry_name} -g {rg} -y') @ResourceGroupPreparer() def test_acr_create_replication(self, resource_group, resource_group_location): @@ -225,7 +225,7 @@ def test_acr_create_replication(self, resource_group, resource_group_location): # test replication delete self.cmd('acr replication delete -n {replication_name} -r {registry_name}') # test acr delete - self.cmd('acr delete -n {registry_name} -g {rg}') + self.cmd('acr delete -n {registry_name} -g {rg} -y') @ResourceGroupPreparer() @record_only() diff --git a/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_network_rule_commands.py b/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_network_rule_commands.py index a89a23d2f31..943e12fe26e 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_network_rule_commands.py +++ b/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_network_rule_commands.py @@ -102,5 +102,5 @@ def test_acr_network_rule(self, resource_group, resource_group_location): checks=[self.check('virtualNetworkRules', []), self.check('ipRules', [])]) - self.cmd('acr delete -g {rg} -n {registry_name}') + self.cmd('acr delete -g {rg} -n {registry_name} -y') self.cmd('network vnet delete -g {rg} -n {vnet_name}') diff --git a/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_task_commands.py b/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_task_commands.py index 24a03dfa6ac..a8db686d22e 100644 --- a/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_task_commands.py +++ b/src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_task_commands.py @@ -101,4 +101,4 @@ def test_acr_task(self, resource_group): self.cmd('acr task delete -n {task_name} -r {registry_name}') # test acr delete - self.cmd('acr delete -n {registry_name} -g {rg}') + self.cmd('acr delete -n {registry_name} -g {rg} -y') From bd6bbd19b3b3a54f91fc2e646e98875dd81f1488 Mon Sep 17 00:00:00 2001 From: Sylvia Lei Date: Mon, 20 Jan 2020 11:20:00 +0800 Subject: [PATCH 3/3] Sort the ACR change log in alphabetic order --- src/azure-cli/HISTORY.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index caf62efa72a..cd34712e958 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +**ACR** + +* [BREAKING CHANGE] `az acr delete` will prompt + **AppConfig** * Support import/export of keyvault references from/to appservice