Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Update azure-mgmt-containerregistry from 8.0.0 to 8.1.0. Add support …
…for export disable.
  • Loading branch information
Tosin Adewale committed Jul 30, 2021
commit 0dc9f3d33d7749b5707b922824d6102c4aad2ce6
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def default_api_version(self):
'role_definitions': '2018-01-01-preview',
'provider_operations_metadata': '2018-01-01-preview'
}),
ResourceType.MGMT_CONTAINERREGISTRY: SDKProfile('2020-11-01-preview', {
ResourceType.MGMT_CONTAINERREGISTRY: SDKProfile('2021-06-01-preview', {
'agent_pools': '2019-06-01-preview',
'tasks': '2019-06-01-preview',
'task_runs': '2019-06-01-preview',
Expand Down
1 change: 1 addition & 0 deletions src/azure-cli/azure/cli/command_modules/acr/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
c.argument('cmd', options_list=['--__cmd__'])
c.argument('cmd_value', help="Commands to execute.", options_list=['--cmd'])
c.argument('zone_redundancy', is_preview=True, arg_type=get_enum_type(ZoneRedundancy), help="Indicates whether or not zone redundancy should be enabled for this registry or replication. For more information, such as supported locations, please visit https://aka.ms/acr/az. Zone-redundancy cannot be updated. Defaults to 'Disabled'.")
c.argument('allow_exports', arg_type=get_three_state_flag(), is_preview=True, help="Configure exportPolicy to allow/disallow artifacts from being exported from this registry. Artifacts can be exported via import or transfer operations. For more information, please visit https://aka.ms/acr/export-policy.")

for scope in ['acr create', 'acr update']:
with self.argument_context(scope, arg_group='Network Rule') as c:
Expand Down
18 changes: 18 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acr/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def acr_create(cmd,
public_network_enabled=None,
zone_redundancy=None,
allow_trusted_services=None,
allow_exports=None,
tags=None):

if default_action and sku not in get_premium_sku(cmd):
Expand All @@ -72,6 +73,7 @@ def acr_create(cmd,
_configure_cmk(cmd, registry, resource_group_name, identity, key_encryption_key)

_handle_network_bypass(cmd, registry, allow_trusted_services)
_handle_export_policy(cmd, registry, allow_exports)

lro_poller = client.begin_create(resource_group_name, registry_name, registry)

Expand Down Expand Up @@ -112,6 +114,7 @@ def acr_update_custom(cmd,
public_network_enabled=None,
allow_trusted_services=None,
anonymous_pull_enabled=None,
allow_exports=None,
tags=None):
if sku is not None:
Sku = cmd.get_models('Sku')
Expand All @@ -137,6 +140,7 @@ def acr_update_custom(cmd,
instance.anonymous_pull_enabled = anonymous_pull_enabled

_handle_network_bypass(cmd, instance, allow_trusted_services)
_handle_export_policy(cmd, instance, allow_exports)

return instance

Expand All @@ -153,6 +157,20 @@ def _handle_network_bypass(cmd, registry, allow_trusted_services):
if allow_trusted_services else NetworkRuleBypassOptions.none)


def _handle_export_policy(cmd, registry, allow_exports):
if allow_exports is not None:
Policies, ExportPolicy, ExportPolicyStatus = cmd.get_models('Policies','ExportPolicy', 'ExportPolicyStatus')

if registry.policies is None:
registry.policies = Policies()

status = ExportPolicyStatus.DISABLED if not allow_exports else ExportPolicyStatus.ENABLED
try:
registry.policies.export_policy.status = status
except AttributeError:
registry.policies.export_policy = ExportPolicy(status=status)


def acr_update_get(cmd):
"""Returns an empty RegistryUpdateParameters object.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ def test_acr_image_import(self, resource_group):
# Case 9: Import image from an Azure Container Registry with personal access token
self.cmd('acr import -n {registry_name} --source {resource_imageV2} -p {token}')


@ResourceGroupPreparer()
def test_acr_export_policy(self, resource_group):
pass


@ResourceGroupPreparer()
def test_acr_create_with_audits(self, resource_group):
registry_name = self.create_random_name('clireg', 20)
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ azure-mgmt-cognitiveservices==12.0.0
azure-mgmt-compute==22.0.0
azure-mgmt-consumption==2.0.0
azure-mgmt-containerinstance==1.5.0
azure-mgmt-containerregistry==8.0.0
azure-mgmt-containerregistry==8.1.0
azure-mgmt-containerservice==16.0.0
azure-mgmt-core==1.2.1
azure-mgmt-cosmosdb==6.4.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ azure-mgmt-cognitiveservices==12.0.0
azure-mgmt-compute==22.0.0
azure-mgmt-consumption==2.0.0
azure-mgmt-containerinstance==1.5.0
azure-mgmt-containerregistry==8.0.0
azure-mgmt-containerregistry==8.1.0
azure-mgmt-containerservice==16.0.0
azure-mgmt-core==1.2.1
azure-mgmt-cosmosdb==6.4.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ azure-mgmt-cognitiveservices==12.0.0
azure-mgmt-compute==22.0.0
azure-mgmt-consumption==2.0.0
azure-mgmt-containerinstance==1.5.0
azure-mgmt-containerregistry==8.0.0
azure-mgmt-containerregistry==8.1.0
azure-mgmt-containerservice==16.0.0
azure-mgmt-core==1.2.1
azure-mgmt-cosmosdb==6.4.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
'azure-mgmt-compute~=22.0.0',
'azure-mgmt-consumption~=2.0',
'azure-mgmt-containerinstance~=1.4',
'azure-mgmt-containerregistry==8.0.0',
'azure-mgmt-containerregistry==8.1.0',
'azure-mgmt-containerservice~=16.0.0',
'azure-mgmt-cosmosdb~=6.4.0',
'azure-mgmt-databoxedge~=1.0.0',
Expand Down