Skip to content

Commit

Permalink
fix(secret): corrects corresponding find functions (#301)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RomilShah authored May 11, 2024
1 parent 5b7c1bb commit 41e287b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions riocli/apply/resolver.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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),
Expand Down
9 changes: 5 additions & 4 deletions riocli/secret/model.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 41e287b

Please sign in to comment.