From 55e15e5f8868f8fd581f3e655a344dc5e93d48d1 Mon Sep 17 00:00:00 2001 From: Daniela Plascencia Date: Thu, 25 Jul 2024 11:05:59 +0200 Subject: [PATCH] skip: update based on latest changes to dex-auth --- lib/charms/dex_auth/v0/dex_oidc_config.py | 29 ++++++++++++----------- metadata.yaml | 2 +- requirements.in | 1 + src/charm.py | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/charms/dex_auth/v0/dex_oidc_config.py b/lib/charms/dex_auth/v0/dex_oidc_config.py index ecb794e..8f77a65 100644 --- a/lib/charms/dex_auth/v0/dex_oidc_config.py +++ b/lib/charms/dex_auth/v0/dex_oidc_config.py @@ -69,6 +69,7 @@ def __init__(self, *args, **kwargs): ... self._dex_oidc_config_provider = DexOidcConfigProvider(self) self.observe(self.on.some_event, self._some_event_handler) + def _some_event_handler(self, ...): # This will update the relation data bag with the issuer URL try: @@ -171,7 +172,7 @@ class DexOidcConfigRequirer(Object): Args: charm (CharmBase): the provider application - refresh_event: (list, optional): list of BoundEvents that this manager should handle. + refresh_events: (list, optional): list of BoundEvents that this manager should handle. Use this to update the data sent on this relation on demand. relation_name (str, optional): the name of the relation @@ -185,7 +186,7 @@ class DexOidcConfigRequirer(Object): def __init__( self, charm: CharmBase, - refresh_event: Optional[Union[BoundEvent, List[BoundEvent]]] = None, + refresh_events: Optional[List[BoundEvent]] = None, relation_name: Optional[str] = DEFAULT_RELATION_NAME, ): super().__init__(charm, relation_name) @@ -201,10 +202,8 @@ def __init__( self._charm.on[self._relation_name].relation_broken, self._on_relation_broken ) - if refresh_event: - if not isinstance(refresh_event, (tuple, list)): - refresh_event = [refresh_event] - for evt in refresh_event: + if refresh_events: + for evt in refresh_events: self.framework.observe(evt, self._on_relation_changed) def get_data(self) -> DexOidcConfigObject: @@ -236,11 +235,13 @@ def __init__(self, charm, relation_name: Optional[str] = DEFAULT_RELATION_NAME): self.relation_name = relation_name @staticmethod - def _validate_relation(relation: Relation) -> None: + def _validate_relation(relation: Optional[Relation]) -> None: """Series of checks for the relation and relation data. Args: - relation (Relation): the relation object to run the checks on + relation (optional, Relation): the relation object to run the checks on. + This object must always come from a call of get_relation, which + can either return a Relation object or None. Raises: DexOidcConfigRelationDataMissingError if data is missing or incomplete @@ -289,7 +290,7 @@ class DexOidcConfigProvider(Object): Args: charm (CharmBase): the provider application issuer_url (str): This is the canonical URL that OIDC clients MUST use to refer to dex. - refresh_event: (list, optional): list of BoundEvents that this manager should handle. Use this to update + refresh_events: (list, optional): list of BoundEvents that this manager should handle. Use this to update the data sent on this relation on demand. relation_name (str, optional): the name of the relation @@ -302,7 +303,7 @@ def __init__( self, charm: CharmBase, issuer_url: str, - refresh_event: Optional[Union[BoundEvent, List[BoundEvent]]] = None, + refresh_events: Optional[List[BoundEvent]] = None, relation_name: Optional[str] = DEFAULT_RELATION_NAME, ): super().__init__(charm, relation_name) @@ -315,10 +316,8 @@ def __init__( self.framework.observe(self.charm.on[self.relation_name].relation_created, self._send_data) - if refresh_event: - if not isinstance(refresh_event, (tuple, list)): - refresh_event = [refresh_event] - for evt in refresh_event: + if refresh_events: + for evt in refresh_events: self.framework.observe(evt, self._send_data) def _send_data(self, _) -> None: @@ -360,6 +359,8 @@ def send_data( "DexOidcConfigProvider handled send_data event when it is not the leader." "Skipping event - no data sent." ) + return + # Update the relation data bag with Dex's OIDC configuration relations = self.charm.model.relations[self.relation_name] diff --git a/metadata.yaml b/metadata.yaml index 0dbaf98..af583d9 100755 --- a/metadata.yaml +++ b/metadata.yaml @@ -52,7 +52,7 @@ provides: versions: [v1] __schema_source: https://raw.githubusercontent.com/canonical/operator-schemas/oidc-schemas/oidc-client.yaml requires: - oidc-provider-info: + dex-oidc-config: interface: dex-oidc-config ingress: interface: ingress diff --git a/requirements.in b/requirements.in index 9c64eae..7adbcb6 100644 --- a/requirements.in +++ b/requirements.in @@ -2,6 +2,7 @@ # See LICENSE file for licensing details. ops oci-image +# required by dex-oidc-config library pydantic # oidc-gatekeeper's current implementation is not compatible # with SDI>0.3. diff --git a/src/charm.py b/src/charm.py index 66eef64..653ac0a 100755 --- a/src/charm.py +++ b/src/charm.py @@ -24,7 +24,7 @@ from serialized_data_interface import NoCompatibleVersions, NoVersionsListed, get_interfaces -OIDC_PROVIDER_INFO_RELATION = "oidc-provider-info" +OIDC_PROVIDER_INFO_RELATION = "dex-oidc-config" class OIDCGatekeeperOperator(CharmBase):