Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: removes old sdk object references #364

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ graphlib-backport = ">=1.0.3"
jinja2 = ">=3.0.1"
munch = ">=2.4.0"
pyyaml = ">=5.4.1"
rapyuta-io = ">=1.17.1"
rapyuta-io = ">=2.0.0"
tabulate = ">=0.8.0"
pyrfc3339 = ">=1.1"
directory-tree = ">=0.0.3.1"
Expand Down
694 changes: 363 additions & 331 deletions Pipfile.lock

Large diffs are not rendered by default.

57 changes: 3 additions & 54 deletions riocli/deployment/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import functools
import re
import typing

import click
from rapyuta_io.clients.deployment import Deployment
import munch

from riocli.config import new_v2_client
from riocli.constants import Colors
from riocli.deployment.list import DEFAULT_PHASES
from riocli.utils import tabulate_data
from riocli.v2client import Client
Expand All @@ -33,58 +29,11 @@
]


def name_to_guid(f: typing.Callable) -> typing.Callable:
@functools.wraps(f)
def decorated(**kwargs: typing.Any) -> None:
try:
client = new_v2_client()
except Exception as e:
click.secho(str(e), fg=Colors.RED)
raise SystemExit(1) from e

name = kwargs.pop('deployment_name')
guid = None

if name.startswith('dep-'):
guid = name
name = None

try:
if name is None:
name = get_deployment_name(client, guid)

if guid is None:
guid = get_deployment_guid(client, name)

except Exception as e:
click.secho(str(e), fg=Colors.RED)
raise SystemExit(1) from e

kwargs['deployment_name'] = name
kwargs['deployment_guid'] = guid
f(**kwargs)

return decorated


def get_deployment_guid(client: Client, name: str) -> str:
deployment = client.get_deployment(name)
return deployment.metadata.guid


def get_deployment_name(client: Client, guid: str) -> str:
deployments = client.list_deployments(query={'guids': [guid]})
if len(deployments) == 0:
raise Exception('deployment not found')

return deployments[0].metadata.name


def fetch_deployments(
client: Client,
deployment_name_or_regex: str,
include_all: bool,
) -> typing.List[Deployment]:
) -> typing.List[munch.Munch]:
deployments = client.list_deployments(query={'phases': DEFAULT_PHASES})
result = []
for deployment in deployments:
Expand All @@ -97,7 +46,7 @@ def fetch_deployments(
return result


def print_deployments_for_confirmation(deployments: typing.List[Deployment]):
def print_deployments_for_confirmation(deployments: typing.List[munch.Munch]):
headers = ['Name', 'GUID', 'Phase', 'Status']

data = []
Expand Down
4 changes: 2 additions & 2 deletions riocli/project/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import typing

import click
import munch
from click_help_colors import HelpColorsCommand
from munch import unmunchify
from rapyuta_io import Project

from riocli.config import new_v2_client
from riocli.constants import Colors, Symbols
Expand Down Expand Up @@ -84,7 +84,7 @@ def list_projects(
raise SystemExit(1)


def _display_project_list(projects: typing.List[Project], current: str = None,
def _display_project_list(projects: typing.List[munch.Munch], current: str = None,
show_header: bool = True,
wide: bool = False) -> None:
headers = []
Expand Down
4 changes: 2 additions & 2 deletions riocli/secret/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import typing

import click
import munch
from click_help_colors import HelpColorsCommand
from rapyuta_io import Secret

from riocli.config import new_v2_client
from riocli.constants import Colors
Expand Down Expand Up @@ -45,7 +45,7 @@ def list_secrets(labels: typing.List[str]) -> None:


def _display_secret_list(
secrets: typing.List[Secret],
secrets: typing.List[munch.Munch],
show_header: bool = True,
) -> None:
headers = []
Expand Down
4 changes: 2 additions & 2 deletions riocli/static_route/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from typing import List

import click
import munch
from click_help_colors import HelpColorsCommand
from rapyuta_io.clients.static_route import StaticRoute

from riocli.config import new_v2_client
from riocli.constants import Colors
Expand Down Expand Up @@ -52,7 +52,7 @@ def list_static_routes(labels: typing.List[str]) -> None:
raise SystemExit(1) from e


def _display_routes_list(routes: List[StaticRoute]) -> None:
def _display_routes_list(routes: List[munch.Munch]) -> None:
headers = ['Route ID', 'Name', 'URL', 'Creator', 'CreatedAt']

data = []
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"python-dateutil>=2.8.2",
"pytz",
"pyyaml>=5.4.1",
"rapyuta-io>=1.17.1",
"rapyuta-io>=2.0.0",
"requests>=2.20.0",
"setuptools",
"six>=1.13.0",
Expand Down
Loading