Skip to content

Commit 7564bd7

Browse files
committed
fix linter
1 parent 9180def commit 7564bd7

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ class CLISecurityDomainOperation(str, Enum):
348348
'Policy definition as JSON, or a path to a file containing JSON policy definition.')
349349
c.extra('default_cvm_policy', action='store_true',
350350
help='Use default policy under which the key can be exported for CVM disk encryption.')
351-
c.extra('default_data_disk_policy', action='store_true',
351+
c.extra('default_data_disk_policy', action='store_true', options_list=['--default-data-disk-policy', '--default-dd-policy'],
352352
help='Use default policy under which the key can be exported for data disk encryption.')
353353
c.extra('immutable', arg_type=get_three_state_flag(), is_preview=True,
354354
help='Mark a release policy as immutable. '

src/azure-cli/azure/cli/command_modules/keyvault/_validators.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from azure.cli.core.commands.client_factory import get_mgmt_service_client
2020
from azure.cli.core.commands.validators import validate_tags
21-
from azure.cli.core.azclierror import RequiredArgumentMissingError, InvalidArgumentValueError, MutuallyExclusiveArgumentError, AzureInternalError
21+
from azure.cli.core.azclierror import RequiredArgumentMissingError, InvalidArgumentValueError, AzureInternalError
2222
from azure.cli.core.profiles import ResourceType
2323
from azure.cli.core.util import get_file_json, shell_safe_json_parse
2424

@@ -208,7 +208,8 @@ def validate_key_type(ns):
208208
setattr(ns, 'kty', kty)
209209

210210

211-
def _fetch_default_release_policy(cli_ctx, vault_url, type = 'cvm'):
211+
# pylint: disable=line-too-long
212+
def _fetch_default_release_policy(cli_ctx, vault_url, policy_type='cvm'):
212213
try:
213214
# get vault/hsm location
214215
mgmt_client = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_KEYVAULT)
@@ -233,9 +234,7 @@ def _fetch_default_release_policy(cli_ctx, vault_url, type = 'cvm'):
233234
_endpoint = cli_ctx.cloud.endpoints.resource_manager
234235
if _endpoint.endswith('/'):
235236
_endpoint = _endpoint[:-1]
236-
default_release_policy_url = f"{_endpoint}/subscriptions/{get_subscription_id(cli_ctx)}" \
237-
f"/providers/Microsoft.Attestation/Locations/{location}" \
238-
f"/defaultProvider?api-version=2020-10-01"
237+
default_release_policy_url = f"{_endpoint}/subscriptions/{get_subscription_id(cli_ctx)}/providers/Microsoft.Attestation/Locations/{location}/defaultProvider?api-version=2020-10-01"
239238
response = send_raw_request(cli_ctx, 'get', default_release_policy_url)
240239
if response.status_code != 200:
241240
raise AzureInternalError(f"Fail to fetch default release policy from {default_release_policy_url}")
@@ -244,7 +243,7 @@ def _fetch_default_release_policy(cli_ctx, vault_url, type = 'cvm'):
244243
import json
245244
res_json = json.loads(response.text)
246245
attest_uri = res_json['properties']['attestUri']
247-
if type == 'cvm':
246+
if policy_type == 'cvm':
248247
default_release_policy = {
249248
'version': '1.0.0',
250249
'anyOf': [
@@ -267,28 +266,28 @@ def _fetch_default_release_policy(cli_ctx, vault_url, type = 'cvm'):
267266
'authority': attest_uri,
268267
'allOf': [
269268
{
270-
"anyOf": [
269+
'anyOf': [
271270
{
272-
"claim": "x-ms-isolation-tee.x-ms-attestation-type",
273-
"equals": "sevsnpvm"
271+
'claim': 'x-ms-isolation-tee.x-ms-attestation-type',
272+
'equals': 'sevsnpvm'
274273
},
275274
{
276-
"claim": "x-ms-isolation-tee.x-ms-attestation-type",
277-
"equals": "tdxvm"
275+
'claim': 'x-ms-isolation-tee.x-ms-attestation-type',
276+
'equals': 'tdxvm'
278277
}
279278
]
280279
},
281280
{
282-
"claim": "x-ms-isolation-tee.x-ms-compliance-status",
283-
"equals": "azure-compliant-cvm"
281+
'claim': 'x-ms-isolation-tee.x-ms-compliance-status',
282+
'equals': 'azure-compliant-cvm'
284283
}
285284
]
286285
}
287286
]
288287
}
289288
return default_release_policy
290289
except Exception as ex: # pylint: disable=broad-except
291-
raise AzureInternalError(f"Fail to fetch default cvm policy: {ex}")
290+
raise AzureInternalError(f"Fail to fetch default release policy: {ex}")
292291

293292

294293
def process_key_release_policy(cmd, ns):
@@ -316,7 +315,9 @@ def process_key_release_policy(cmd, ns):
316315
if ns.release_policy and default_data_disk_policy:
317316
raise InvalidArgumentValueError('Can not specify both `--policy` and `--default-data-disk-policy`')
318317
if default_cvm_policy and default_data_disk_policy:
319-
raise MutuallyExclusiveArgumentError('`--default-cvm-policy` and `--default-data-disk-policy` are mutually exclusive')
318+
from azure.cli.core.azclierror import MutuallyExclusiveArgumentError
319+
raise MutuallyExclusiveArgumentError('`--default-cvm-policy` and `--default-data-disk-policy` '
320+
'are mutually exclusive')
320321

321322
import json
322323
KeyReleasePolicy = cmd.loader.get_sdk('KeyReleasePolicy', mod='_models',

0 commit comments

Comments
 (0)