Skip to content

Commit 049fa4e

Browse files
author
Mai Nguyen (from Dev Box)
committed
style
1 parent 5c446f5 commit 049fa4e

3 files changed

Lines changed: 17 additions & 19 deletions

File tree

src/acrtransfer/azext_acrtransfer/exportpipeline.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,52 +18,50 @@
1818

1919
def _extract_storage_account_resource_id(subscription_id, resource_group_name, container_uri):
2020
"""Extract storage account resource ID from container URI.
21-
Used for permission guidance messages
21+
Used for permission guidance messages
2222
Expected format: https://<storage-account-name>.blob.core.windows.net/<container-name>
2323
"""
2424
try:
2525
parsed = urlparse(container_uri)
2626
storage_account_name = parsed.hostname.split('.')[0]
2727
return f"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Storage/storageAccounts/{storage_account_name}"
28-
except Exception:
28+
except Exception: # pylint: disable=broad-exception-caught
2929
return "<storage-account-resource-id>"
3030

3131

3232
def _extract_keyvault_resource_id(subscription_id, resource_group_name, keyvault_secret_uri):
3333
"""Extract key vault resource ID from secret URI.
34-
Used for permission guidance messages
34+
Used for permission guidance messages
3535
Expected format: https://<keyvault-name>.vault.azure.net/secrets/<secret-name>
3636
"""
3737
try:
3838
parsed = urlparse(keyvault_secret_uri)
3939
keyvault_name = parsed.hostname.split('.')[0]
4040
return f"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.KeyVault/vaults/{keyvault_name}"
41-
except Exception:
41+
except Exception: # pylint: disable=broad-exception-caught
4242
return "<key-vault-resource-id>"
4343

4444

4545
def _display_permission_guidance(storage_access_mode, principal_id, subscription_id, resource_group_name, container_uri, keyvault_secret_uri=None):
4646
"""Display permission guidance for the managed identity."""
47-
48-
4947
if storage_access_mode == 'ManagedIdentity':
5048
storage_resource_id = _extract_storage_account_resource_id(subscription_id, resource_group_name, container_uri)
5149
role = "Storage Blob Data Contributor"
5250

5351
logger.warning("")
54-
logger.warning(f"Please ensure that the Managed Identity of the pipeline (Object ID: {principal_id}) has the necessary permissions to access the Storage Account Blob Container.")
52+
logger.warning("Please ensure that the Managed Identity of the pipeline (Object ID: %s) has the necessary permissions to access the Storage Account Blob Container.", principal_id)
5553
logger.warning("Please run:")
56-
logger.warning(f" az role assignment create --assignee \"{principal_id}\" --role \"{role}\" --scope \"{storage_resource_id}\"")
54+
logger.warning(" az role assignment create --assignee \"%s\" --role \"%s\" --scope \"%s\"", principal_id, role, storage_resource_id)
5755
logger.warning("Note: If the Storage Account is in a different resource group, update the --scope parameter accordingly.")
5856
logger.warning("")
5957
elif storage_access_mode == 'SasToken' and keyvault_secret_uri:
6058
keyvault_resource_id = _extract_keyvault_resource_id(subscription_id, resource_group_name, keyvault_secret_uri)
6159
role = "Key Vault Secrets User"
6260

6361
logger.warning("")
64-
logger.warning(f"Please ensure that the Managed Identity of the pipeline (Object ID: {principal_id}) has the necessary permissions to access the Key Vault Secret containing the Storage Account SAS Key.")
62+
logger.warning("Please ensure that the Managed Identity of the pipeline (Object ID: %s) has the necessary permissions to access the Key Vault Secret containing the Storage Account SAS Key.", principal_id)
6563
logger.warning("Please run:")
66-
logger.warning(f" az role assignment create --assignee \"{principal_id}\" --role \"{role}\" --scope \"{keyvault_resource_id}\"")
64+
logger.warning(" az role assignment create --assignee \"%s\" --role \"%s\" --scope \"%s\"", principal_id, role, keyvault_resource_id)
6765
logger.warning("Note: If the Key Vault is in a different resource group, update the --scope parameter accordingly.")
6866
logger.warning("")
6967

src/acrtransfer/azext_acrtransfer/importpipeline.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@
1717

1818
def _extract_storage_account_resource_id(subscription_id, resource_group_name, container_uri):
1919
"""Extract storage account resource ID from container URI.
20-
Used for permission guidance messages
20+
Used for permission guidance messages
2121
Expected format: https://<storage-account-name>.blob.core.windows.net/<container-name>
2222
"""
2323
try:
2424
# Parse the URI to get storage account name
2525
parsed = urlparse(container_uri)
2626
storage_account_name = parsed.hostname.split('.')[0]
2727
return f"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Storage/storageAccounts/{storage_account_name}"
28-
except Exception:
28+
except Exception: # pylint: disable=broad-exception-caught
2929
return "<storage-account-resource-id>"
3030

3131

3232
def _extract_keyvault_resource_id(subscription_id, resource_group_name, keyvault_secret_uri):
3333
"""Extract key vault resource ID from secret URI.
34-
Used for permission guidance messages
34+
Used for permission guidance messages
3535
Expected format: https://<keyvault-name>.vault.azure.net/secrets/<secret-name>
3636
"""
3737
try:
3838
parsed = urlparse(keyvault_secret_uri)
3939
keyvault_name = parsed.hostname.split('.')[0]
4040
return f"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.KeyVault/vaults/{keyvault_name}"
41-
except Exception:
41+
except Exception: # pylint: disable=broad-exception-caught
4242
return "<key-vault-resource-id>"
4343

4444

@@ -50,19 +50,19 @@ def _display_permission_guidance(storage_access_mode, principal_id, subscription
5050
role = "Storage Blob Data Reader"
5151

5252
logger.warning("")
53-
logger.warning(f"Please ensure that the Managed Identity of the pipeline (Object ID: {principal_id}) has the necessary permissions to access the Storage Account Blob Container.")
53+
logger.warning("Please ensure that the Managed Identity of the pipeline (Object ID: %s) has the necessary permissions to access the Storage Account Blob Container.", principal_id)
5454
logger.warning("Please run:")
55-
logger.warning(f" az role assignment create --assignee \"{principal_id}\" --role \"{role}\" --scope \"{storage_resource_id}\"")
55+
logger.warning(" az role assignment create --assignee \"%s\" --role \"%s\" --scope \"%s\"", principal_id, role, storage_resource_id)
5656
logger.warning("Note: If the Storage Account is in a different resource group, update the --scope parameter accordingly.")
5757
logger.warning("")
5858
elif storage_access_mode == 'SasToken':
5959
keyvault_resource_id = _extract_keyvault_resource_id(subscription_id, resource_group_name, keyvault_secret_uri)
6060
role = "Key Vault Secrets User"
6161

6262
logger.warning("")
63-
logger.warning(f"Please ensure that the Managed Identity of the pipeline (Object ID: {principal_id}) has the necessary permissions to access the Key Vault Secret containing the Storage Account SAS Key.")
63+
logger.warning("Please ensure that the Managed Identity of the pipeline (Object ID: %s) has the necessary permissions to access the Key Vault Secret containing the Storage Account SAS Key.", principal_id)
6464
logger.warning("Please run:")
65-
logger.warning(f" az role assignment create --assignee \"{principal_id}\" --role \"{role}\" --scope \"{keyvault_resource_id}\"")
65+
logger.warning(" az role assignment create --assignee \"%s\" --role \"%s\" --scope \"%s\"", principal_id, role, keyvault_resource_id)
6666
logger.warning("Note: If the Key Vault is in a different resource group, update the --scope parameter accordingly.")
6767
logger.warning("")
6868

src/acrtransfer/azext_acrtransfer/pipelinerun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def get_pipelinerun(client, resource_group_name, registry_name, pipeline_run_nam
9393
logger.warning("Authenticating to Storage Account using Entra Managed Identity.")
9494
elif storage_access_mode == 'SasToken':
9595
logger.warning("Authenticating to Storage Account using Storage SAS Token.")
96-
except Exception:
96+
except Exception: # pylint: disable=broad-exception-caught
9797
logger.warning("Unable to determine authentication method used for this pipeline run.")
9898

9999
return result

0 commit comments

Comments
 (0)