Skip to content

Commit

Permalink
fix(jans-pycloudlib): avoid overwritten data by using merge strategy …
Browse files Browse the repository at this point in the history
…for AWS wrappers (#3832)
  • Loading branch information
iromli authored Feb 10, 2023
1 parent 1593997 commit cf0d4e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions jans-pycloudlib/jans/pycloudlib/config/aws_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,17 @@ def set_all(self, data: dict[str, _t.Any]) -> bool:
"""
self._prepare_secret()

# fetch existing data (if any) as we will merge them;
# note that existing value will be overwritten
payload = self.get_all()

for k, v in data.items():
# ensure value that has bytes is converted to text
payload[k] = safe_value(v)

resp = self.client.update_secret(
SecretId=self.basepath,
SecretString=_dump_value(
# ensure key-value that has bytes is converted to text
{k: safe_value(v) for k, v in data.items()}
),
SecretString=_dump_value(payload),
)
return bool(resp)

Expand Down
13 changes: 9 additions & 4 deletions jans-pycloudlib/jans/pycloudlib/secret/aws_secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,17 @@ def set_all(self, data: dict[str, _t.Any]) -> bool:
"""
self._prepare_secret()

# fetch existing data (if any) as we will merge them;
# note that existing value will be overwritten
payload = self.get_all()

for k, v in data.items():
# ensure value that has bytes is converted to text
payload[k] = safe_value(v)

resp = self.client.update_secret(
SecretId=self.basepath,
SecretBinary=_dump_value(
# ensure key-value that has bytes is converted to text
{k: safe_value(v) for k, v in data.items()}
),
SecretBinary=_dump_value(payload),
)
return bool(resp)

Expand Down

0 comments on commit cf0d4e3

Please sign in to comment.