canonical / dex-auth-operator

Operator for Dex Auth
Apache License 2.0
3 stars 14 forks source link

Make `_validate_relation` a public method #215

Open DnPlas opened 3 months ago

DnPlas commented 3 months ago

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 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

  1. Make _validate_relation a public method or create a new method
  2. Alternatively, the library could emit a custom event

Definition of Done

The library provides a way for checking the relation from the requirer side.

syncronize-issues-to-jira[bot] commented 3 months ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/KF-6056.

This message was autogenerated