Skip to content

Commit 733708a

Browse files
committed
chore: Refactor role binding and unbinding logic; update role management manifests
- Changed the binding structure in `bind.py` to include `newBindings` and `oldBindings`. - Updated the `unbind.py` to reflect the new binding structure. - Modified the `model.py` to streamline role updates by removing unnecessary parameters. - Cleaned up imports in `model.py` and `util.py`. - Removed obsolete manifest files related to deployments, disks, networks, role bindings, user groups, and values. - Added new package manifests for boundary testing and role management. - Updated test cases to reflect changes in package and secret management. - Removed redundant code in test files for better clarity and maintainability.
1 parent c3779d7 commit 733708a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+40
-363
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,6 @@ Pipfile
6161

6262
# Test configuration files (contains sensitive data)
6363
tests/.password
64-
scripts/*
64+
scripts/*
65+
.coverage
66+
Pipfile

riocli/apply/parse.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,18 @@
1313
# limitations under the License.
1414
from __future__ import annotations
1515

16-
from collections.abc import Callable, Iterable, Mapping
16+
import graphlib
17+
import json
1718
from concurrent.futures import ThreadPoolExecutor
1819
from functools import partial
19-
import json
20-
from typing import Any
20+
from pathlib import Path
21+
from typing import TYPE_CHECKING, Any
2122

2223
import click
23-
from rapyuta_io import Client
2424
import yaml
2525
from benedict import benedict
2626
from munch import munchify
2727

28-
from yaspin.api import Yaspin
29-
3028
from riocli.apply.util import (
3129
get_resource_class,
3230
init_jinja_environment,
@@ -44,10 +42,6 @@
4442
from riocli.utils import dump_all_yaml, print_centered_text, run_bash
4543
from riocli.utils.graph import GraphVisualizer, Graphviz
4644
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"
5145

5246
if TYPE_CHECKING:
5347
from collections.abc import Callable, Iterable, Mapping
@@ -288,8 +282,8 @@ def _delete_manifest(
288282

289283
def _get_dependency_graph(
290284
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()
293287
diagram = Graphviz(direction="LR", format="svg")
294288

295289
for key, obj in objects.items():
@@ -533,18 +527,18 @@ def worker_func(w: str) -> Exception | None:
533527
def _can_delete(obj: Model) -> bool:
534528
metadata = obj.get("metadata")
535529
if metadata is None:
536-
return False
530+
return True
537531

538532
labels: dict[str, str] = metadata.get("labels")
539533
if labels is None:
540-
return False
534+
return True
541535

542536
policy = labels.get(DELETE_POLICY_LABEL)
543537
if policy is None:
544-
return False
538+
return True
545539

546540
if not isinstance(policy, str):
547-
return False
541+
return True
548542

549543
# If a resource has a label with DELETE_POLICY_LABEL set
550544
# to 'retain', it should not be deleted.

riocli/apply/util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from collections.abc import Iterable, Mapping
1818
from datetime import datetime
1919
from shutil import get_terminal_size
20-
from collections.abc import Iterable, Mapping
2120
from typing import Any, AnyStr
2221

2322
import click

riocli/auth/util.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@
2121
from rapyuta_io.utils import UnauthorizedError
2222
from rapyuta_io.utils.rest_client import HttpMethod, RestClient
2323
from rapyuta_io_sdk_v2 import Client as v2Client
24-
from rapyuta_io_sdk_v2.utils import handle_server_errors
24+
from rapyuta_io_sdk_v2.utils import handle_server_errors, walk_pages
2525

2626
from riocli.config import Configuration
2727
from riocli.constants import Colors, Symbols
2828
from riocli.exceptions import OrganizationNotFound, ProjectNotFound
2929
from riocli.utils.selector import show_selection
3030
from riocli.utils.spinner import with_spinner
31-
from rapyuta_io_sdk_v2 import Client as v2Client
32-
from rapyuta_io_sdk_v2.utils import handle_server_errors, walk_pages
33-
from riocli.exceptions import ProjectNotFound, OrganizationNotFound
3431

3532
TOKEN_LEVELS = {0: AuthTokenLevel.LOW, 1: AuthTokenLevel.MED, 2: AuthTokenLevel.HIGH}
3633

riocli/bootstrap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
import os
1818

1919
import click
20-
from click import Context
2120
import rapyuta_io
21+
from click import Context
2222

2323
from riocli.apply import apply, delete, graph
24-
from riocli.apply.explain import list_examples, explain
24+
from riocli.apply.explain import explain, list_examples
2525
from riocli.apply.template import template
2626
from riocli.auth import auth
2727
from riocli.chart import chart

riocli/deployment/util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ def poll_deployment(
112112
deployment = client.get_deployment(name=name)
113113
status = deployment.status
114114

115-
error_codes = []
116115
if status is not None and hasattr(status, "error_codes"):
117-
error_codes = status.error_codes or []
116+
pass
118117
msg = (
119118
f"Retries exhausted: Tried {retry_count} times with {sleep_interval}s interval. "
120119
f"Deployment: phase={status.phase} status={status.status} \n"

riocli/network/model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from typing_extensions import override
1818

1919
from riocli.model import Model
20-
from rapyuta_io_sdk_v2.exceptions import HttpAlreadyExistsError, HttpNotFoundError
2120
from riocli.network.util import poll_network
2221

2322

riocli/project/list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
import munch
1717
from click_help_colors import HelpColorsCommand
1818
from munch import unmunchify
19+
from rapyuta_io_sdk_v2.utils import walk_pages
1920

2021
from riocli.config import new_v2_client
2122
from riocli.constants import Colors
2223
from riocli.organization.util import name_to_guid as name_to_organization_guid
2324
from riocli.utils import tabulate_data
24-
from rapyuta_io_sdk_v2.utils import walk_pages
2525

2626

2727
@click.command(

riocli/project/model.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
from typing_extensions import Any, override
1919
from waiting import wait
2020

21-
from riocli.config import Configuration
22-
from riocli.constants import ApplyResult
23-
from riocli.model import Model
2421
from riocli.auth.util import find_project_guid
2522
from riocli.config import Configuration
2623
from riocli.constants import ApplyResult

riocli/role/bind.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def bind(
7979
subject_kind, subject_name = get_subject(subject)
8080

8181
binding = {
82-
"bindings": [
82+
"newBindings": [
8383
{
8484
"metadata": {
8585
"organizationGUID": config.organization_guid,
@@ -98,10 +98,11 @@ def bind(
9898
},
9999
},
100100
}
101-
]
101+
],
102+
"oldBindings": [],
102103
}
103104

104-
_ = client.create_role_binding(binding)
105+
_ = client.update_role_binding(binding=binding)
105106
spinner.text = click.style("Binding created successfully.", fg=Colors.GREEN)
106107
spinner.green.ok(Symbols.SUCCESS)
107108
except Exception as e:

0 commit comments

Comments
 (0)