Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
ACR_RESOURCE_PROVIDER = 'Microsoft.ContainerRegistry'
ACR_RESOURCE_TYPE = ACR_RESOURCE_PROVIDER + '/registries'
STORAGE_RESOURCE_TYPE = 'Microsoft.Storage/storageAccounts'
WEBHOOK_RESOURCE_TYPE = ACR_RESOURCE_TYPE + '/webhooks'
REPLICATION_RESOURCE_TYPE = ACR_RESOURCE_TYPE + '/replications'
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_storage_service_client():
def get_acr_service_client():
'''Returns the client for managing container registries.
'''
from azure.mgmt.containerregistry import ContainerRegistryManagementClient
from .azure.mgmt.containerregistry import ContainerRegistryManagementClient
return get_mgmt_service_client(ContainerRegistryManagementClient)

def get_acr_api_version():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@

from collections import OrderedDict

from ._utils import get_resource_group_name_by_resource_id

_registry_map = {
'name': 'NAME',
'resourceGroup': 'RESOURCE GROUP',
'location': 'LOCATION',
'loginServer': 'LOGIN SERVER',
'creationDate': 'CREATION DATE',
'adminUserEnabled': 'ADMIN ENABLED'
'adminUserEnabled': 'ADMIN ENABLED',
'isEnabled': 'ENABLED',
'scope': 'SCOPE',
'actions': 'ACTIONS',
'serviceUri': 'SERVICE URI',
'customHeaders': 'HEADERS'
}

_order_map = {
Expand All @@ -25,7 +28,12 @@
'ADMIN ENABLED': 13,
'USERNAME': 31,
'PASSWORD': 32,
'PASSWORD2': 33
'PASSWORD2': 33,
'ENABLED': 41,
'SCOPE': 42,
'ACTIONS': 43,
'SERVICE URI': 44,
'HEADERS': 45
}

def output_format(result):
Expand All @@ -41,10 +49,6 @@ def _format_group(item):
'''
registry_info = {_registry_map[key]: str(item[key]) for key in item if key in _registry_map}

if 'id' in item and item['id']:
resource_group_name = get_resource_group_name_by_resource_id(item['id'])
registry_info['RESOURCE GROUP'] = resource_group_name

return OrderedDict(sorted(registry_info.items(), key=lambda t: _order_map[t[0]]))

def credential_format(item):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
short-summary: Manage repositories for Azure container registries.
"""

helps['acr webhook'] = """
type: group
short-summary: Manage webhooks for Azure container registries.
"""

helps['acr replication'] = """
type: group
short-summary: Manage replications for Azure container registries.
"""

helps['acr check-name'] = """
type: command
short-summary: Checks whether the container registry name is available for use.
Expand All @@ -47,7 +57,10 @@
type: command
short-summary: Creates a container registry.
examples:
- name: Create a container registry with a new storage account.
- name: Create a container registry with managed storage account. Applicable to Standard/Premium SKU.
text: >
az acr create -n MyRegistry -g MyResourceGroup --sku Standard
- name: Create a container registry with a new storage account. Applicable to Basic SKU.
text: >
az acr create -n MyRegistry -g MyResourceGroup --sku Basic
"""
Expand All @@ -56,7 +69,7 @@
type: command
short-summary: Deletes a container registry.
examples:
- name: Delete a container registry
- name: Delete a container registry.
text: >
az acr delete -n MyRegistry
"""
Expand Down Expand Up @@ -135,3 +148,129 @@
text:
az acr repository show-tags -n MyRegistry --repository MyRepository
"""

helps['acr webhook list'] = """
type: command
short-summary: Lists all the webhooks for the specified container registry.
examples:
- name: List webhooks and show the results in a table.
text: >
az acr webhook list -r MyRegistry -o table
"""

helps['acr webhook create'] = """
type: command
short-summary: Creates a webhook for a container registry.
examples:
- name: Create a webhook for a container registry that will deliver Docker push and delete events to the specified service URI.
text: >
az acr webhook create -n MyWebhook -r MyRegistry --uri http://myservice.com --actions push delete
- name: Create a webhook for a container registry that will deliver Docker push events to the specified service URI with Basic authentication header.
text: >
az acr webhook create -n MyWebhook -r MyRegistry --uri http://myservice.com --actions push --headers "Authorization=Basic 000000"
"""

helps['acr webhook delete'] = """
type: command
short-summary: Deletes a webhook from a container registry.
examples:
- name: Delete a webhook from a container registry.
text: >
az acr webhook delete -n MyWebhook -r MyRegistry
"""

helps['acr webhook show'] = """
type: command
short-summary: Gets the properties of the specified webhook.
examples:
- name: Get the properties of the specified webhook.
text: >
az acr webhook show -n MyWebhook -r MyRegistry
"""

helps['acr webhook update'] = """
type: command
short-summary: Updates a webhook.
examples:
- name: Update headers for a webhook
text: >
az acr webhook update -n MyWebhook -r MyRegistry --headers "Authorization=Basic 000000"
- name: Update service URI and actions for a webhook
text: >
az acr webhook update -n MyWebhook -r MyRegistry --uri http://myservice.com --actions push delete
- name: Disable a webhook
text: >
az acr webhook update -n MyWebhook -r MyRegistry --is-enabled false
"""

helps['acr webhook get-config'] = """
type: command
short-summary: Gets the configuration of service URI and custom headers for the webhook.
examples:
- name: Get service URI and headers for the webhook.
text: >
az acr webhook get-config -n MyWebhook -r MyRegistry
"""

helps['acr webhook ping'] = """
type: command
short-summary: Triggers a ping event to be sent to the webhook.
examples:
- name: Triggers a ping event to be sent to the webhook.
text: >
az acr webhook ping -n MyWebhook -r MyRegistry
"""

helps['acr webhook list-events'] = """
type: command
short-summary: Lists recent events for the specified webhook.
examples:
- name: List recent events for the specified webhook.
text: >
az acr webhook list-events -n MyWebhook -r MyRegistry
"""

helps['acr replication list'] = """
type: command
short-summary: Lists all the replications for the specified container registry.
examples:
- name: List replications and show the results in a table.
text: >
az acr replication list -r MyRegistry -o table
"""

helps['acr replication create'] = """
type: command
short-summary: Creates a replication for a container registry.
examples:
- name: Create a replication for a container registry.
text: >
az acr replication create -n MyReplication -r MyRegistry -l westus
"""

helps['acr replication delete'] = """
type: command
short-summary: Deletes a replication from a container registry.
examples:
- name: Delete a replication from a container registry.
text: >
az acr replication delete -n MyReplication -r MyRegistry
"""

helps['acr replication show'] = """
type: command
short-summary: Gets the properties of the specified replication.
examples:
- name: Get the properties of the specified replication.
text: >
az acr replication show -n MyReplication -r MyRegistry
"""

helps['acr replication update'] = """
type: command
short-summary: Updates a replication.
examples:
- name: Update tags for a replication
text: >
az acr replication update -n MyReplication -r MyRegistry --tags key1=value1 key2=value2
"""
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,26 @@
location_type,
tags_type,
deployment_name_type,
get_resource_name_completion_list
get_resource_name_completion_list,
quotes
)
from azure.cli.core.commands.validators import get_default_location_from_resource_group

from ._constants import (
ACR_RESOURCE_TYPE,
STORAGE_RESOURCE_TYPE
STORAGE_RESOURCE_TYPE,
WEBHOOK_RESOURCE_TYPE,
REPLICATION_RESOURCE_TYPE
)
from ._validators import (
validate_registry_name,
validate_headers,
validate_replication_location
)
from ._validators import validate_registry_name

register_cli_argument('acr', 'registry_name', options_list=('--name', '-n'), help='The name of the container registry', completer=get_resource_name_completion_list(ACR_RESOURCE_TYPE))
register_cli_argument('acr', 'storage_account_name', help='The name of an existing storage account', completer=get_resource_name_completion_list(STORAGE_RESOURCE_TYPE))
register_cli_argument('acr', 'sku', help='The SKU of the container registry', choices=['Basic'])
register_cli_argument('acr', 'storage_account_name', help='Provide the name of an existing storage account if you\'re recreating a container registry over a previous registry created storage account. Only applicable to Basic SKU.', completer=get_resource_name_completion_list(STORAGE_RESOURCE_TYPE))
register_cli_argument('acr', 'sku', help='The SKU of the container registry', choices=['Basic', 'Standard', 'Premium'])
register_cli_argument('acr', 'password_name', help='The name of password to regenerate', choices=['password', 'password2'])

register_cli_argument('acr', 'resource_group_name', resource_group_name_type)
Expand All @@ -36,6 +44,18 @@

register_cli_argument('acr create', 'registry_name', completer=None, validator=validate_registry_name)
register_cli_argument('acr create', 'deployment_name', deployment_name_type, validator=None)
register_cli_argument('acr create', 'location', location_type, validator=get_default_location_from_resource_group)
register_cli_argument('acr check-name', 'registry_name', completer=None)
register_cli_argument('acr create', 'storage_account_name', help='Default: A new storage account will be created. Provide the name of an existing storage account if you\'re recreating a container registry over a previous registry created storage account.', completer=get_resource_name_completion_list(STORAGE_RESOURCE_TYPE))
register_cli_argument('acr update', 'storage_account_name', help='Provide the name of an existing storage account if you\'re recreating a container registry over a previous registry created storage account.', completer=get_resource_name_completion_list(STORAGE_RESOURCE_TYPE))

register_cli_argument('acr webhook', 'registry_name', options_list=('--registry', '-r'), help='The name of the container registry', completer=get_resource_name_completion_list(ACR_RESOURCE_TYPE))
register_cli_argument('acr webhook', 'webhook_name', options_list=('--name', '-n'), help='The name of the webhook', completer=get_resource_name_completion_list(WEBHOOK_RESOURCE_TYPE))
register_cli_argument('acr webhook', 'uri', help='The service URI for the webhook to post notifications.')
register_cli_argument('acr webhook', 'headers', nargs='*', help="Space separated custom headers in 'key[=value]' format that will be added to the webhook notifications. Use {} to clear existing headers.".format(quotes), validator=validate_headers)
register_cli_argument('acr webhook', 'actions', nargs='+', help='Space separated list of actions that trigger the webhook to post notifications.', choices=['push', 'pull', 'delete'])
register_cli_argument('acr webhook', 'is_enabled', help='Indicates whether the webhook is enabled.', choices=['true', 'false'])
register_cli_argument('acr webhook create', 'webhook_name', completer=None)

register_cli_argument('acr replication', 'registry_name', options_list=('--registry', '-r'), help='The name of the container registry', completer=get_resource_name_completion_list(ACR_RESOURCE_TYPE))
register_cli_argument('acr replication', 'replication_name', options_list=('--name', '-n'), help='The name of the replication', completer=get_resource_name_completion_list(REPLICATION_RESOURCE_TYPE))
register_cli_argument('acr replication create', 'replication_name', completer=None)
register_cli_argument('acr replication create', 'location', validator=validate_replication_location)
Loading