Skip to content

Commit

Permalink
feat: BI-5901 add secrepr function for dict (#740)
Browse files Browse the repository at this point in the history
add secrepr function for dict
  • Loading branch information
juliarbkv authored Dec 16, 2024
1 parent cc643b5 commit f1027ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/dl_core/dl_core/us_manager/us_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ def _get_entry_save_params(self, entry: USEntry) -> dict:
data_pack = USDataPack(data=data_dict)

for key, secret in data_pack.secrets.items():
if isinstance(secret, dict):
secret = json.dumps(secret)
assert secret is None or isinstance(secret, str)
data_pack.secrets[key] = self._crypto_controller.encrypt_with_actual_key(secret)

Expand Down
8 changes: 6 additions & 2 deletions lib/dl_core/dl_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ def sa_plain_text(query: str) -> sa.sql.elements.TextClause:

def secrepr(value: Optional[str]) -> str:
"""Convenience function for attrs-repr of secrets"""
if value is None:
return repr(value)
if not value:
return repr(value)
if not isinstance(value, str):
Expand All @@ -284,6 +282,12 @@ def secrepr(value: Optional[str]) -> str:
return repr(f"{value[:side_size]}...{value[-side_size:]}")


def secrepr_dict(d: dict[str, Optional[str]]) -> str:
if not d:
return repr(d)
return repr({key: secrepr(value) for key, value in d.items()})


def _multidict_to_list(md: CIMultiDictProxy[str]) -> Iterable[tuple[str, str]]:
return [(str(k), str(v)) for k, v in md.items()]

Expand Down

0 comments on commit f1027ab

Please sign in to comment.