diff --git a/src/command_modules/azure-cli-acr/README.rst b/src/command_modules/azure-cli-acr/README.rst index bd32643d6b4..dd076706c26 100644 --- a/src/command_modules/azure-cli-acr/README.rst +++ b/src/command_modules/azure-cli-acr/README.rst @@ -17,6 +17,7 @@ Commands to manage Azure container registries create : Creates a container registry. delete : Deletes a container registry. list : Lists all the available container registries under the current subscription. + login : Login to a container registry through Docker. show : Gets the properties of the specified container registry. update : Updates a container registry. @@ -152,20 +153,6 @@ List repositories in a given container registry List repositories in a given container registry with credentials az acr repository list -n myRegistry -u myUsername -p myPassword -Login to a container registry -------------- -:: - - Command - az acr login: Login to a container registry through Docker. - - Arguments - --registry-url -u [Required]: The login server of the container registry. - - Examples - Login to a container registry - az acr login -u myregistry.azurecr.io - Show tags of a given repository in a given container registry ------------- :: @@ -185,3 +172,13 @@ Show tags of a given repository in a given container registry az acr repository show-tags -n myRegistry --repository myRepository Show tags of a given repository in a given container registry with credentials az acr repository show-tags -n myRegistry --repository myRepository -u myUsername -p myPassword + +Login to a container registry +------------- +:: + + Command + az acr login: Login to a container registry through Docker. + + Arguments + --name -n [Required]: The name of the container registry. diff --git a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_help.py b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_help.py index 7599c76db71..4e8603ad258 100644 --- a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_help.py +++ b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_help.py @@ -59,15 +59,6 @@ az acr update -n myRegistry --admin-enabled true """ -helps['acr login'] = """ - type: command - short-summary: Login to a container registry through Docker. - examples: - - name: Login to a registry - text: - az acr login -u myregistry.azurecr.io - """ - helps['acr repository list'] = """ type: command examples: diff --git a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_params.py b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_params.py index f2a82a5d32c..922fd0e9874 100644 --- a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_params.py +++ b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_params.py @@ -42,10 +42,6 @@ options_list=('--password', '-p'), help='The password used to log into a container registry') -register_cli_argument('acr', 'registry_url', - options_list=('--registry-url', '-u'), - help='The login server of the container registry') - register_cli_argument('acr create', 'registry_name', completer=None, validator=validate_registry_name) register_cli_argument('acr create', 'resource_group_name', diff --git a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_utils.py b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_utils.py index 7cd3503410a..f70de6a4fec 100644 --- a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_utils.py +++ b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_utils.py @@ -8,9 +8,9 @@ from json import loads import requests +from azure.cli.core._profile import Profile from azure.cli.core._util import CLIError from azure.cli.core.commands.parameters import get_resources_in_subscription -from azure.cli.core._profile import Profile from ._constants import ( ACR_RESOURCE_PROVIDER, diff --git a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/custom.py b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/custom.py index fd1ee08c20f..55f8b31a5ae 100644 --- a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/custom.py +++ b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/custom.py @@ -17,7 +17,8 @@ get_resource_group_name_by_registry_name, arm_deploy_template, random_storage_account_name, - docker_login_to_registry + docker_login_to_registry, + get_registry_by_name ) import azure.cli.core._logging as _logging @@ -116,12 +117,6 @@ def acr_show(registry_name, resource_group_name=None): return client.get_properties(resource_group_name, registry_name) -def acr_login(registry_url): - '''Login to a container registry through Docker. - :param str registry_url: The url of container registry - ''' - docker_login_to_registry(registry_url) - def acr_update_get(client, registry_name, resource_group_name=None): @@ -165,3 +160,11 @@ def acr_update_set(client, resource_group_name = get_resource_group_name_by_registry_name(registry_name) return client.update(resource_group_name, registry_name, parameters) + +def acr_login(registry_name): + '''Login to a container registry through Docker. + :param str registry_name: The name of container registry + ''' + registry, _ = get_registry_by_name(registry_name) + login_server = registry.login_server #pylint: disable=no-member + docker_login_to_registry(login_server)