Skip to content

Commit

Permalink
Removing databag reference from MySQL Router Provides
Browse files Browse the repository at this point in the history
  • Loading branch information
juditnovak committed Oct 31, 2023
1 parent 0d7dedf commit b757d7d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/relations/database_provides.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,18 @@ def __init__(
self, *, relation: ops.Relation, interface: data_interfaces.DatabaseProvides
) -> None:
super().__init__(relation=relation)
self._local_databag = relation.data[interface.local_app]
self._interface = interface
self._local_databag = self._interface.fetch_my_relation_data([relation.id]).get(
relation.id
)
for key in ("database", "username", "password", "endpoints", "read-only-endpoints"):
if key not in self._local_databag:
raise _UserNotCreated

def delete_databag(self) -> None:
"""Remove connection information from databag."""
logger.debug(f"Deleting databag {self._id=}")
self._local_databag.clear()
self._interface.delete_relation_data(self._id, list(self._local_databag))
logger.debug(f"Deleted databag {self._id=}")

def delete_user(self, *, shell: mysql_shell.Shell) -> None:
Expand Down

0 comments on commit b757d7d

Please sign in to comment.