Skip to content

Commit d136207

Browse files
committed
Catch empty lists
1 parent 064fcb8 commit d136207

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

data_safe_haven/commands/config.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,22 @@ def available() -> None:
6565
)
6666
raise typer.Exit(1) from exc
6767
azure_sdk = AzureSdk(context.subscription_name)
68-
blobs = azure_sdk.list_blobs(
69-
container_name=context.storage_container_name,
70-
prefix="sre",
71-
resource_group_name=context.resource_group_name,
72-
storage_account_name=context.storage_account_name,
73-
)
68+
try:
69+
blobs = azure_sdk.list_blobs(
70+
container_name=context.storage_container_name,
71+
prefix="sref",
72+
resource_group_name=context.resource_group_name,
73+
storage_account_name=context.storage_account_name,
74+
)
75+
except DataSafeHavenAzureStorageError as exc:
76+
logger.critical("Ensure SHM is deployed before attempting to use SRE configs.")
77+
raise typer.Exit(1) from exc
78+
if not blobs:
79+
logger.critical(f"No configurations found for context '{context.name}'.")
80+
raise typer.Exit(1)
7481
console.print(f"Available SRE configurations for context '{context.name}':")
7582
for blob in blobs:
7683
console.print(blob)
77-
# try:
78-
# sre_configs = SREConfig.available(context)
79-
# except DataSafeHavenAzureStorageError as exc:
80-
# logger.critical("Ensure SHM is deployed before attempting to use SRE configs.")
81-
# raise typer.Exit(1) from exc
82-
# except DataSafeHavenError as exc:
83-
# logger.critical("No configurations found for the selected context.")
84-
# raise typer.Exit(1) from exc
85-
# for sre_config in sre_configs:
86-
# console.print(sre_config.name)
8784

8885

8986
@config_command_group.command()

0 commit comments

Comments
 (0)