Skip to content

Commit 3d0621a

Browse files
committed
garbage collection cli
1 parent d904e61 commit 3d0621a

18 files changed

+2198
-28539
lines changed

src/azure-cli-core/azure/cli/core/profiles/_shared.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def default_api_version(self):
195195
'role_definitions': '2022-05-01-preview',
196196
'provider_operations_metadata': '2018-01-01-preview'
197197
}),
198-
ResourceType.MGMT_CONTAINERREGISTRY: SDKProfile('2023-11-01-preview', {
198+
ResourceType.MGMT_CONTAINERREGISTRY: SDKProfile('2024-11-01-preview', {
199199
'agent_pools': '2019-06-01-preview',
200200
'tasks': '2019-06-01-preview',
201201
'task_runs': '2019-06-01-preview',
@@ -439,6 +439,7 @@ def default_api_version(self):
439439
'VERSION_2021_08_01_PREVIEW': "2021-08-01-preview",
440440
'VERSION_2022_02_01_PREVIEW': "2022-02-01-preview",
441441
'VERSION_2023_11_01_PREVIEW': "2023-11-01-preview",
442+
'VERSION_2024_11_01_PREVIEW': "2024-11-01-preview",
442443
},
443444
ResourceType.MGMT_CONTAINERSERVICE: {
444445
# src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py:50

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
VERSION_2021_08_01_PREVIEW = "2021-08-01-preview"
1212
VERSION_2022_02_01_PREVIEW = "2022-02-01-preview"
1313
VERSION_2023_01_01_PREVIEW = "2023-01-01-preview"
14+
VERSION_2024_11_01_PREVIEW = "2024-11-01-preview"
1415

1516

1617
def get_acr_service_client(cli_ctx, api_version=None):
@@ -81,4 +82,4 @@ def cf_acr_agentpool(cli_ctx, *_):
8182

8283

8384
def cf_acr_connected_registries(cli_ctx, *_):
84-
return get_acr_service_client(cli_ctx, VERSION_2021_08_01_PREVIEW).connected_registries
85+
return get_acr_service_client(cli_ctx, VERSION_2024_11_01_PREVIEW).connected_registries

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
535535
c.argument('cleanup', help='It will aslo delete the sync token and the scope map resources.')
536536
c.argument('no_children', help='Used to remove all children from the list.', action='store_true')
537537
c.argument('sync_audit_logs_enabled', options_list=['--audit-logs-enabled'], help='Indicate whether audit log synchronization is enabled. It is enabled by default.', required=False, arg_type=get_three_state_flag(), deprecate_info=c.deprecate(hide=True))
538-
539538
c.argument('parent_protocol', arg_type=get_enum_type(['http', 'https']), options_list=['--parent-protocol'], help='Specify the protocol used to communicate with its parent.', required=True)
540539
c.argument('generate_password', arg_type=get_enum_type(['1', '2']), options_list=['--generate-password'], help='Select which password you want to generate, and it is required to retrieve the password from the sync token.')
541540

@@ -547,6 +546,10 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
547546
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="* * * * *")
548547
c.argument('sync_message_ttl', help='Determine how long the sync messages will be kept in the cloud. Uses ISO 8601 duration format.', required=False, default="P2D")
549548
c.argument('notifications', options_list=['--notifications'], nargs='+', help='List of artifact pattern for which notifications need to be generated. Use the format "--notifications [PATTERN1 PATTERN2 ...]".')
549+
c.argument('garbage_collection_enabled', options_list=['--garbage-collection-enabled'],
550+
help='Indicate whether garbage collection is enabled. It is enabled by default.',arg_type=get_three_state_flag(),required=False, default="true")
551+
c.argument('garbage_collection_schedule', options_list=['--garbage-collection-schedule'],
552+
help='Used to determine garbage collection schedule. Uses cron expression to determine the schedule. If not specified, garbage collection is set to run once a day.',required=False, default="0 0 * * *")
550553

551554
with self.argument_context('acr connected-registry update') as c:
552555
c.argument('log_level', help='Set the log level for logging on the instance. Accepted log levels are Debug, Information, Warning, Error, and None.')
@@ -561,7 +564,9 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
561564
help='List of artifact pattern to be added to notifications list. Use the format "--add-notifications [PATTERN1 PATTERN2 ...]".')
562565
c.argument('remove_notifications', options_list=['--remove-notifications'], nargs='*',
563566
help='List of artifact pattern to be removed from notifications list. Use the format "--remove-notifications [PATTERN1 PATTERN2 ...]".')
564-
567+
c.argument('garbage_collection_enabled', options_list=['--garbage-collection-enabled'],
568+
help='Indicate whether garbage collection is enabled. It is enabled by default.',arg_type=get_three_state_flag())
569+
c.argument('garbage_collection_schedule', options_list=['--garbage-collection-schedule'], help='Used to determine garbage collection schedule. Uses cron expression to determine the schedule. If not specified, garbage collection is set to run once a day.')
565570
with self.argument_context('acr connected-registry permissions') as c:
566571
c.argument('add_repos', options_list=['--add'], nargs='*',
567572
help='repository permissions to be added to the targeted connected registry and it\'s ancestors sync scope maps. Use the format "--add [REPO1 REPO2 ...]" per flag. ' + repo_valid_actions)

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def acr_connected_registry_create(cmd, # pylint: disable=too-many-locals, too-m
6060
log_level=None,
6161
sync_audit_logs_enabled=False,
6262
notifications=None,
63+
garbage_collection_enabled=None,
64+
garbage_collection_schedule=None,
6365
yes=False):
6466

6567
if bool(sync_token_name) == bool(repositories):
@@ -111,8 +113,8 @@ def acr_connected_registry_create(cmd, # pylint: disable=too-many-locals, too-m
111113
notifications_set = set(notifications) \
112114
if notifications else set()
113115

114-
ConnectedRegistry, LoggingProperties, SyncProperties, ParentProperties = cmd.get_models(
115-
'ConnectedRegistry', 'LoggingProperties', 'SyncProperties', 'ParentProperties')
116+
ConnectedRegistry, LoggingProperties, SyncProperties, ParentProperties, GarbageCollectionProperties = cmd.get_models(
117+
'ConnectedRegistry', 'LoggingProperties', 'SyncProperties', 'ParentProperties','GarbageCollectionProperties')
116118
connected_registry_create_parameters = ConnectedRegistry(
117119
provisioning_state=None,
118120
mode=mode,
@@ -130,6 +132,10 @@ def acr_connected_registry_create(cmd, # pylint: disable=too-many-locals, too-m
130132
log_level=log_level,
131133
audit_log_status='Enabled' if sync_audit_logs_enabled else 'Disabled'
132134
),
135+
garbage_collection=GarbageCollectionProperties(
136+
enabled=garbage_collection_enabled,
137+
schedule=garbage_collection_schedule
138+
),
133139
notifications_list=list(notifications_set) if notifications_set else None
134140
)
135141

@@ -155,7 +161,9 @@ def acr_connected_registry_update(cmd, # pylint: disable=too-many-locals, too-m
155161
sync_message_ttl=None,
156162
sync_audit_logs_enabled=None,
157163
add_notifications=None,
158-
remove_notifications=None):
164+
remove_notifications=None,
165+
garbage_collection_enabled=None,
166+
garbage_collection_schedule=None):
159167
_, resource_group_name = validate_managed_registry(
160168
cmd, registry_name, resource_group_name)
161169
subscription_id = get_subscription_id(cmd.cli_ctx)
@@ -211,8 +219,8 @@ def acr_connected_registry_update(cmd, # pylint: disable=too-many-locals, too-m
211219

212220
notifications_list = list(notifications_set) if notifications_set != current_notifications_set else None
213221

214-
ConnectedRegistryUpdateParameters, SyncUpdateProperties, LoggingProperties = cmd.get_models(
215-
'ConnectedRegistryUpdateParameters', 'SyncUpdateProperties', 'LoggingProperties')
222+
ConnectedRegistryUpdateParameters, SyncUpdateProperties, LoggingProperties, GarbageCollectionProperties = cmd.get_models(
223+
'ConnectedRegistryUpdateParameters', 'SyncUpdateProperties', 'LoggingProperties','GarbageCollectionProperties')
216224
connected_registry_update_parameters = ConnectedRegistryUpdateParameters(
217225
sync_properties=SyncUpdateProperties(
218226
schedule=sync_schedule,
@@ -223,6 +231,10 @@ def acr_connected_registry_update(cmd, # pylint: disable=too-many-locals, too-m
223231
log_level=log_level,
224232
audit_log_status=sync_audit_logs_enabled
225233
),
234+
garbage_collection=GarbageCollectionProperties(
235+
enabled=garbage_collection_enabled,
236+
schedule=garbage_collection_schedule
237+
),
226238
client_token_ids=client_token_list,
227239
notifications_list=notifications_list
228240
)

0 commit comments

Comments
 (0)