In a recent integration with the dex-oidc-config library, it was discovered that the requirers could use the _validate_relation method for validating that the relation exists. Right now the way a requirer would validate the relation is by calling get_data(), which requires to wrap the logic in a method like this:
def _check_dex_oidc_config_relation(self) -> None:
"""Check for exceptions from the library and raises ErrorWithStatus to set the unit status.
Raises:
ErrorWithStatus: if the relation hasn't been established, set unit to BlockedStatus
ErrorWithStatus: if the relation has empty or missing data, set unit to WaitingStatus
"""
try:
self._dex_oidc_config_requirer.get_data()
except DexOidcConfigRelationMissingError as rel_error:
raise ErrorWithStatus(
f"{rel_error.message} Please add the missing relation.", BlockedStatus
)
except DexOidcConfigRelationDataMissingError as data_error:
self.logger.error(f"Empty or missing data. Got: {data_error.message}")
raise ErrorWithStatus(
f"Empty or missing data in {OIDC_PROVIDER_INFO_RELATION} relation."
" This may be transient, but if it persists it is likely an error.",
WaitingStatus,
)
Ideally the requirer object could provide a way to directly check the relation w/o this awkward wrap.
What needs to get done
Make _validate_relation a public method or create a new method
Alternatively, the library could emit a custom event
Definition of Done
The library provides a way for checking the relation from the requirer side.
Context
In a recent integration with the
dex-oidc-config
library, it was discovered that the requirers could use the_validate_relation
method for validating that the relation exists. Right now the way a requirer would validate the relation is by callingget_data()
, which requires to wrap the logic in a method like this:Ideally the requirer object could provide a way to directly check the relation w/o this awkward wrap.
What needs to get done
_validate_relation
a public method or create a new methodDefinition of Done
The library provides a way for checking the relation from the requirer side.