|
13 | 13 | # limitations under the License. |
14 | 14 | from __future__ import annotations |
15 | 15 |
|
16 | | -from collections.abc import Callable, Iterable, Mapping |
| 16 | +import graphlib |
| 17 | +import json |
17 | 18 | from concurrent.futures import ThreadPoolExecutor |
18 | 19 | from functools import partial |
19 | | -import json |
20 | | -from typing import Any |
| 20 | +from pathlib import Path |
| 21 | +from typing import TYPE_CHECKING, Any |
21 | 22 |
|
22 | 23 | import click |
23 | | -from rapyuta_io import Client |
24 | 24 | import yaml |
25 | 25 | from benedict import benedict |
26 | 26 | from munch import munchify |
27 | 27 |
|
28 | | -from yaspin.api import Yaspin |
29 | | - |
30 | 28 | from riocli.apply.util import ( |
31 | 29 | get_resource_class, |
32 | 30 | init_jinja_environment, |
|
44 | 42 | from riocli.utils import dump_all_yaml, print_centered_text, run_bash |
45 | 43 | from riocli.utils.graph import GraphVisualizer, Graphviz |
46 | 44 | from riocli.utils.spinner import with_spinner |
47 | | -from riocli.v2client import Client as v2Client |
48 | | - |
49 | | -DEFAULT_MAX_WORKERS = 6 |
50 | | -DELETE_POLICY_LABEL = "rapyuta.io/deletionPolicy" |
51 | 45 |
|
52 | 46 | if TYPE_CHECKING: |
53 | 47 | from collections.abc import Callable, Iterable, Mapping |
@@ -288,8 +282,8 @@ def _delete_manifest( |
288 | 282 |
|
289 | 283 | def _get_dependency_graph( |
290 | 284 | self, objects: dict[str, Model] |
291 | | - ) -> tuple[TopologicalSorter[str], GraphVisualizer]: |
292 | | - graph: TopologicalSorter[str] = TopologicalSorter() |
| 285 | + ) -> tuple[graphlib.TopologicalSorter[str], GraphVisualizer]: |
| 286 | + graph: graphlib.TopologicalSorter[str] = graphlib.TopologicalSorter() |
293 | 287 | diagram = Graphviz(direction="LR", format="svg") |
294 | 288 |
|
295 | 289 | for key, obj in objects.items(): |
@@ -533,18 +527,18 @@ def worker_func(w: str) -> Exception | None: |
533 | 527 | def _can_delete(obj: Model) -> bool: |
534 | 528 | metadata = obj.get("metadata") |
535 | 529 | if metadata is None: |
536 | | - return False |
| 530 | + return True |
537 | 531 |
|
538 | 532 | labels: dict[str, str] = metadata.get("labels") |
539 | 533 | if labels is None: |
540 | | - return False |
| 534 | + return True |
541 | 535 |
|
542 | 536 | policy = labels.get(DELETE_POLICY_LABEL) |
543 | 537 | if policy is None: |
544 | | - return False |
| 538 | + return True |
545 | 539 |
|
546 | 540 | if not isinstance(policy, str): |
547 | | - return False |
| 541 | + return True |
548 | 542 |
|
549 | 543 | # If a resource has a label with DELETE_POLICY_LABEL set |
550 | 544 | # to 'retain', it should not be deleted. |
|
0 commit comments