Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make _validate_relation a public method #215

Open
DnPlas opened this issue Jul 26, 2024 · 1 comment
Open

Make _validate_relation a public method #215

DnPlas opened this issue Jul 26, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@DnPlas
Copy link
Contributor

DnPlas commented Jul 26, 2024

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.

@DnPlas DnPlas added the enhancement New feature or request label Jul 26, 2024
Copy link

Thank you for reporting us your feedback!

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

This message was autogenerated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant