Skip to content

Commit eb96999

Browse files
authored
[ACR] OnPrem: Connected-registry create: Mode default value changed to readOnly (#28807)
1 parent 7d4f0fe commit eb96999

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
542542

543543
with self.argument_context('acr connected-registry create') as c:
544544
c.argument('log_level', help='Set the log level for logging on the instance. Accepted log levels are Debug, Information, Warning, Error, and None.', required=False, default="Information")
545-
c.argument('mode', arg_type=get_enum_type(['ReadOnly', 'ReadWrite']), options_list=['--mode', '-m'], help='Determine the access it will have when synchronized.', required=False, default="ReadWrite")
545+
c.argument('mode', arg_type=get_enum_type(['ReadOnly', 'ReadWrite']), options_list=['--mode', '-m'], help='Determine the access it will have when synchronized.', required=False, default="ReadOnly")
546546
c.argument('client_token_list', options_list=['--client-tokens'], nargs='+', help='Specify the client access to the repositories in the connected registry. It can be in the format [TOKEN_NAME01] [TOKEN_NAME02]...')
547547
c.argument('sync_window', options_list=['--sync-window', '-w'], help='Required parameter if --sync-schedule is present. Used to determine the schedule duration. Uses ISO 8601 duration format.')
548548
c.argument('sync_schedule', options_list=['--sync-schedule', '-s'], help='Optional parameter to define the sync schedule. Uses cron expression to determine the schedule. If not specified, the instance is considered always online and attempts to sync every minute.', required=False, default="* * * * *")

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# --------------------------------------------------------------------------------------------
55

66
from enum import Enum
7-
import re
87
from msrest.exceptions import ValidationError
98
from knack.log import get_logger
109
from knack.util import CLIError
@@ -22,6 +21,7 @@
2221
parse_scope_map_actions,
2322
validate_managed_registry
2423
)
24+
from .custom import acr_update_custom
2525

2626

2727
class ConnectedRegistryModes(Enum):
@@ -59,23 +59,22 @@ def acr_connected_registry_create(cmd, # pylint: disable=too-many-locals, too-m
5959
sync_window=None,
6060
log_level=None,
6161
sync_audit_logs_enabled=False,
62-
notifications=None):
62+
notifications=None,
63+
yes=False):
6364

6465
if bool(sync_token_name) == bool(repositories):
6566
raise CLIError("argument error: either --sync-token or --repository must be provided, but not both.")
6667
# Check needed since the sync token gateway actions must be at least 5 characters long.
6768
if len(connected_registry_name) < 5:
6869
raise InvalidArgumentValueError("argument error: Connected registry name must be at least 5 characters long.")
69-
if re.match(r'\w*[A-Z]\w*', connected_registry_name):
70-
raise InvalidArgumentValueError("argument error: Connected registry name must use only lowercase.")
71-
registry, resource_group_name = get_registry_by_name(cmd.cli_ctx, registry_name, resource_group_name)
7270
subscription_id = get_subscription_id(cmd.cli_ctx)
71+
registry, resource_group_name = get_registry_by_name(cmd.cli_ctx, registry_name, resource_group_name)
7372

7473
if not registry.data_endpoint_enabled:
75-
raise CLIError("Can't create the connected registry '{}' ".format(connected_registry_name) +
76-
"because the cloud registry '{}' data endpoint is disabled. ".format(registry_name) +
77-
"Enabling the data endpoint might affect your firewall rules.\nTo enable data endpoint run:" +
78-
"\n\taz acr update -n {} --data-endpoint-enabled true".format(registry_name))
74+
user_confirmation("Dedicated data enpoints must be enabled to use connected-registry. Enabling might " +
75+
"impact your firewall rules. Are you sure you want to enable it for '{}' registry?".format(
76+
registry_name), yes)
77+
acr_update_custom(cmd, registry, resource_group_name, data_endpoint_enabled=True)
7978

8079
from azure.core.exceptions import HttpResponseError as ErrorResponseException
8180
parent = None

src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_connectedregistry_commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_acr_connectedregistry(self, resource_group):
5151
checks=self.check('dataEndpointEnabled', True))
5252

5353
# Create a default connected registry.
54-
self.cmd('acr connected-registry create -n {cr_name} -r {registry_name} --repository {repo_1} {repo_2} {repo_3}',
54+
self.cmd('acr connected-registry create -n {cr_name} -r {registry_name} -m ReadWrite --repository {repo_1} {repo_2} {repo_3}',
5555
checks=[self.check('name', '{cr_name}'),
5656
self.check('mode', 'ReadWrite'),
5757
self.check('logging.logLevel', 'Information'),
@@ -61,7 +61,7 @@ def test_acr_connectedregistry(self, resource_group):
6161
# Create a custom connected-registry with a previously created token.
6262
self.cmd('acr token create -r {registry_name} -n {syncToken} --repository {repo_1} content/read metadata/read --gateway {root_name} config/read config/write message/read message/write --no-passwords')
6363
self.cmd('acr token create -r {registry_name} -n {clientToken} --repository {repo_1} content/read --no-passwords')
64-
self.cmd('acr connected-registry create -n {root_name} -r {registry_name} --sync-token {syncToken} -m ReadOnly --log-level Warning -s "{syncSchedule}" -w PT4H --client-tokens {clientToken} --notifications {notificationStr}',
64+
self.cmd('acr connected-registry create -n {root_name} -r {registry_name} --sync-token {syncToken} --log-level Warning -s "{syncSchedule}" -w PT4H --client-tokens {clientToken} --notifications {notificationStr}',
6565
checks=[self.check('name', '{root_name}'),
6666
self.check('mode', 'ReadOnly'),
6767
self.check('provisioningState', 'Succeeded'),

0 commit comments

Comments
 (0)