Skip to content

Commit

Permalink
chore(requirer): Don't exclude secret id
Browse files Browse the repository at this point in the history
  • Loading branch information
merkata committed Aug 29, 2024
1 parent f4496ef commit e7e1beb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/charms/matrix_plugins_lib/v0/matrix_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def to_relation_data(self, model: ops.Model, relation: ops.Relation) -> Dict[str
dumped_model = self.model_dump(exclude_unset=True)
dumped_data = {
"shared_secret_id": dumped_model["shared_secret_id"],
"homeserver": dumped_model["homeserver"],
}
return dumped_data

Expand Down Expand Up @@ -197,7 +198,7 @@ class MatrixAuthRequirerData(BaseModel):
"""

registration: Optional[SecretStr] = Field(default=None, exclude=True)
registration_secret_id: Optional[SecretStr] = Field(default=None, exclude=True)
registration_secret_id: Optional[SecretStr] = Field(default=None)

def set_registration_id(self, model: ops.Model, relation: ops.Relation) -> None:
"""Store the app registration as a Juju secret.
Expand Down Expand Up @@ -367,25 +368,25 @@ def __init__(self, charm: ops.CharmBase, relation_name: str = DEFAULT_RELATION_N
self.relation_name = relation_name
self.framework.observe(charm.on[relation_name].relation_changed, self._on_relation_changed)

def get_remote_relation_data(self) -> Optional[MatrixAuthProviderData]:
def get_remote_relation_data(self) -> Optional[MatrixAuthRequirerData]:
"""Retrieve the remote relation data.
Returns:
MatrixAuthProviderData: the relation data.
MatrixAuthRequirerData: the relation data.
"""
relation = self.model.get_relation(self.relation_name)
return self._get_remote_relation_data(relation) if relation else None

def _get_remote_relation_data(self, relation: ops.Relation) -> MatrixAuthProviderData:
def _get_remote_relation_data(self, relation: ops.Relation) -> MatrixAuthRequirerData:
"""Retrieve the remote relation data.
Args:
relation: the relation to retrieve the data from.
Returns:
MatrixAuthProviderData: the relation data.
MatrixAuthRequirerData: the relation data.
"""
return MatrixAuthProviderData.from_relation(relation)
return MatrixAuthRequirerData.from_relation(relation=relation)

def _is_remote_relation_data_valid(self, relation: ops.Relation) -> bool:
"""Validate the relation data.
Expand Down Expand Up @@ -478,7 +479,7 @@ def _get_remote_relation_data(
Returns:
the relation data and the processed entries for it.
"""
return MatrixAuthProviderData.from_relation(model, relation)
return MatrixAuthProviderData.from_relation(relation=relation)

def _is_remote_relation_data_valid(self, relation: ops.Relation) -> bool:
"""Validate the relation data.
Expand Down

0 comments on commit e7e1beb

Please sign in to comment.