Skip to content

Commit c55d16d

Browse files
committed
[ACR] az acr config content-trust: Begin deprecation of Docker Content Trust feature
1 parent f7c9331 commit c55d16d

29 files changed

+3283
-3826
lines changed

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,6 @@ def format_error_message(self, *args):
6969
)
7070

7171

72-
# NOTARY ERRORS
73-
NOTARY_COMMAND_ERROR = ErrorClass(
74-
"NOTARY_COMMAND_ERROR",
75-
"Please verify if notary is installed."
76-
)
77-
78-
NOTARY_VERSION_ERROR = ErrorClass(
79-
"NOTARY_VERSION_ERROR",
80-
"An error occurred while retrieving notary version. Please make sure that you have the latest Azure CLI version, and that you are using the recommended notary version."
81-
)
82-
83-
8472
# CONNECTIVITY ERRORS
8573
CONNECTIVITY_DNS_ERROR = ErrorClass(
8674
"CONNECTIVITY_DNS_ERROR",

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
short-summary: Configure policies for Azure Container Registries.
7272
"""
7373

74+
# To be deprecated
7475
helps['acr config content-trust'] = """
7576
type: group
7677
short-summary: Manage content-trust policy for Azure Container Registries.
@@ -102,6 +103,7 @@
102103
az acr config authentication-as-arm update -r myregistry --status Enabled
103104
"""
104105

106+
# To be deprecated
105107
helps['acr config content-trust show'] = """
106108
type: command
107109
short-summary: Show the configured content-trust policy for an Azure Container Registry.
@@ -111,6 +113,7 @@
111113
az acr config content-trust show -r myregistry
112114
"""
113115

116+
# To be deprecated
114117
helps['acr config content-trust update'] = """
115118
type: command
116119
short-summary: Update content-trust policy for an Azure Container Registry.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
156156
c.argument('registry_name', options_list=['--registry', '-r', c.deprecate(target='-n', redirect='-r', hide=True), c.deprecate(target='--name', redirect='--registry', hide=True)])
157157
c.argument('status', help="Indicates whether content-trust is enabled.", arg_type=get_enum_type(PolicyStatus))
158158

159+
with self.argument_context('acr config content-trust update') as c:
160+
c.argument('status', help="Indicates whether content-trust is enabled. Only 'disabled' is allowed.", arg_type=get_enum_type([PolicyStatus.disabled]))
161+
159162
with self.argument_context('acr config retention') as c:
160163
c.argument('status', help="Indicates whether retention policy is enabled.", arg_type=get_enum_type(PolicyStatus))
161164
c.argument('registry_name', options_list=['--registry', '-r'])

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

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
MIN_HELM_VERSION = "2.11.0"
2424
HELM_VERSION_REGEX = re.compile(r'(SemVer|Version):"v([.\d]+)"')
2525
ACR_CHECK_HEALTH_MSG = "Try running 'az acr check-health -n {} --yes' to diagnose this issue."
26-
RECOMMENDED_NOTARY_VERSION = "0.6.0"
27-
NOTARY_VERSION_REGEX = re.compile(r'Version:\s+([.\d]+)')
2826
DOCKER_PULL_WRONG_PLATFORM = 'cannot be used on this platform'
2927

3028

@@ -167,46 +165,6 @@ def _get_helm_version(ignore_errors):
167165
_handle_error(obsolete_ver_error, ignore_errors)
168166

169167

170-
def _get_notary_version(ignore_errors):
171-
from ._errors import NOTARY_VERSION_ERROR
172-
from .notary import get_notary_command
173-
from packaging.version import parse # pylint: disable=import-error,no-name-in-module
174-
175-
# Notary command check
176-
notary_command, error = get_notary_command(is_diagnostics_context=True)
177-
178-
if error:
179-
_handle_error(error, ignore_errors)
180-
return
181-
182-
# Notary version check
183-
output, warning, stderr, succeeded = _subprocess_communicate([notary_command, "version"])
184-
185-
if not succeeded:
186-
_handle_error(NOTARY_VERSION_ERROR.append_error_message(stderr), ignore_errors)
187-
return
188-
189-
if warning:
190-
logger.warning(warning)
191-
192-
# Retrieve the notary version if regex pattern is found
193-
match_obj = NOTARY_VERSION_REGEX.search(output)
194-
if match_obj:
195-
output = match_obj.group(1)
196-
197-
logger.warning("Notary version: %s", output)
198-
199-
# Display error if the current version does not match the recommended version
200-
if match_obj and parse(output) != parse(RECOMMENDED_NOTARY_VERSION):
201-
version_msg = "upgrade"
202-
if parse(output) > parse(RECOMMENDED_NOTARY_VERSION):
203-
version_msg = "downgrade"
204-
obsolete_ver_error = NOTARY_VERSION_ERROR.set_error_message(
205-
"Current notary version is not recommended. Please {} your notary client to version {}."
206-
.format(version_msg, RECOMMENDED_NOTARY_VERSION))
207-
_handle_error(obsolete_ver_error, ignore_errors)
208-
209-
210168
# Checks for the connectivity
211169
# Check DNS lookup and access to challenge endpoint
212170
def _get_registry_status(login_server, registry_name, ignore_errors):
@@ -469,6 +427,5 @@ def acr_check_health(cmd, # pylint: disable useless-return
469427

470428
if not in_cloud_console:
471429
_get_helm_version(ignore_errors)
472-
_get_notary_version(ignore_errors)
473430

474431
logger.warning(FAQ_MESSAGE)

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,14 @@ def load_command_table(self, _):
344344
g.command('logs', 'acr_taskrun_logs', client_factory=cf_acr_runs,
345345
table_transformer=None)
346346

347-
with self.command_group('acr config content-trust', acr_policy_util) as g:
347+
def _dct_deprecate_message(self):
348+
msg = "This {} has been deprecated and will be removed in a future release.".format(self.object_type)
349+
msg += " Learn more about the transition from Docker Content Trust to the Notary Project: "
350+
msg += "https://aka.ms/acr/dctdeprecation"
351+
return msg
352+
353+
with self.command_group('acr config content-trust', acr_policy_util,
354+
deprecate_info=self.deprecate(message_func=_dct_deprecate_message, hide=False)) as g:
348355
g.show_command('show', 'acr_config_content_trust_show')
349356
g.command('update', 'acr_config_content_trust_update')
350357

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

Lines changed: 0 additions & 36 deletions
This file was deleted.

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,20 @@ def acr_config_content_trust_update(cmd,
3434
client,
3535
registry_name,
3636
status=None,
37-
resource_group_name=None):
37+
resource_group_name=None,
38+
yes=False):
3839
registry, resource_group_name = validate_premium_registry(
3940
cmd, registry_name, resource_group_name, POLICIES_NOT_SUPPORTED)
4041

42+
warning_message = (
43+
"Content Trust is being deprecated and will be completely removed on March 31, 2028. "
44+
"It cannot be enabled once disabled. Please submit a support ticket if you wish to "
45+
"disable and subsequently re-enable this feature. When disabled, your images will "
46+
"remain in the registry, but all your signatures will be deleted permanently. "
47+
"Are you sure you want to disable content trust?"
48+
)
49+
user_confirmation(warning_message, yes)
50+
4151
policies = registry.policies
4252

4353
if status:

0 commit comments

Comments
 (0)