|
7 | 7 | from scaleway import Client
|
8 | 8 | from scaleway.account.v2 import AccountV2API
|
9 | 9 | from scaleway.function.v1beta1 import FunctionV1Beta1API
|
10 |
| -from scaleway.registry.v1 import RegistryV1API |
11 | 10 | from scaleway_core.api import ScalewayException
|
12 |
| -from scaleway_core.utils import WaitForOptions |
13 | 11 |
|
14 | 12 | from .utils import create_client
|
15 | 13 |
|
@@ -42,30 +40,17 @@ def _create_scaleway_project(client: Client) -> ProjectID:
|
42 | 40 |
|
43 | 41 | def _cleanup_project(client: Client, project_id: ProjectID):
|
44 | 42 | """Delete all Scaleway resources created in the temporary project."""
|
45 |
| - function_api = FunctionV1Beta1API(client) |
| 43 | + api = FunctionV1Beta1API(client) |
46 | 44 |
|
47 |
| - namespaces = function_api.list_namespaces_all(project_id=project_id) |
| 45 | + namespaces = api.list_namespaces_all(project_id=project_id) |
48 | 46 | for namespace in namespaces:
|
49 |
| - function_api.delete_namespace(namespace_id=namespace.id) |
50 |
| - |
51 |
| - registry_api = RegistryV1API(client) |
52 |
| - registries = registry_api.list_namespaces_all(project_id=project_id) |
53 |
| - for registry in registries: |
54 |
| - registry_api.delete_namespace(namespace_id=registry.id) |
| 47 | + api.delete_namespace(namespace_id=namespace.id) |
55 | 48 |
|
56 | 49 | # All deletions have been scheduled,
|
57 | 50 | # we can wait for their completion sequentially
|
58 | 51 | for namespace in namespaces:
|
59 | 52 | try:
|
60 |
| - function_api.wait_for_namespace(namespace_id=namespace.id) |
61 |
| - except ScalewayException as e: |
62 |
| - if e.status_code != 404: |
63 |
| - raise e |
64 |
| - for registry in registries: |
65 |
| - try: |
66 |
| - registry_api.wait_for_namespace( |
67 |
| - namespace_id=registry.id, options=WaitForOptions(timeout=600) |
68 |
| - ) |
| 53 | + api.wait_for_namespace(namespace_id=namespace.id) |
69 | 54 | except ScalewayException as e:
|
70 | 55 | if e.status_code != 404:
|
71 | 56 | raise e
|
|
0 commit comments