From 41e287b2e4247d317468ebdf9a0f40a041f1530c Mon Sep 17 00:00:00 2001 From: RomilShah Date: Sat, 11 May 2024 20:01:19 +0530 Subject: [PATCH] fix(secret): corrects corresponding find functions (#301) Due to a recent refactor in the v2 client library, the list secrets function now returns the entire secret objects instead of just reading the metadata in the previous implementation. This changed object altogther and the way other sections of code fetched the secret name. This commit addresses the issue by correcting the find functions and other methods where secret name is referred to. --- riocli/apply/resolver.py | 6 +++--- riocli/secret/model.py | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/riocli/apply/resolver.py b/riocli/apply/resolver.py index b8642f27..4cc3808b 100644 --- a/riocli/apply/resolver.py +++ b/riocli/apply/resolver.py @@ -1,4 +1,4 @@ -# Copyright 2022 Rapyuta Robotics +# Copyright 2024 Rapyuta Robotics # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -116,7 +116,7 @@ def find_depends(self, depends, *args): def _guid_functor(self, kind): mapping = { - 'secret': lambda x: munchify(x).guid, + 'secret': lambda x: munchify(x).metadata.name, "project": lambda x: munchify(x).metadata.guid, "package": lambda x: munchify(x)['id'], "staticroute": lambda x: munchify(x)['metadata']['guid'], @@ -150,7 +150,7 @@ def _list_functors(self, kind): def _find_functors(self, kind): mapping = { - 'secret': self._generate_find_guid_functor(), + 'secret': lambda name, secrets: filter(lambda i: i.metadata.name == name, secrets), "project": lambda name, projects: filter(lambda i: i.metadata.name == name, projects), "package": lambda name, obj_list, version: filter( lambda x: name == x.name and version == x['packageVersion'], obj_list), diff --git a/riocli/secret/model.py b/riocli/secret/model.py index 343dae72..2b416f54 100644 --- a/riocli/secret/model.py +++ b/riocli/secret/model.py @@ -1,4 +1,4 @@ -# Copyright 2023 Rapyuta Robotics +# Copyright 2024 Rapyuta Robotics # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. import typing -from munch import unmunchify +from munch import unmunchify from rapyuta_io import Client from riocli.config import new_v2_client from riocli.jsonschema.validate import load_schema from riocli.model import Model + class Secret(Model): def __init__(self, *args, **kwargs): self.update(*args, **kwargs) @@ -51,12 +52,12 @@ def update_object(self, client: Client, obj: typing.Any) -> typing.Any: secret = unmunchify(self) secret.pop("rc", None) - r = client.update_secret(obj.name, secret) + r = client.update_secret(obj.metadata.name, secret) return unmunchify(r) def delete_object(self, client: Client, obj: typing.Any) -> typing.Any: client = new_v2_client() - client.delete_secret(obj.name) + client.delete_secret(obj.metadata.name) @classmethod def pre_process(cls, client: Client, d: typing.Dict) -> None: