Skip to content

Commit

Permalink
skip: update based on latest changes to dex-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
DnPlas committed Jul 25, 2024
1 parent 9a0e615 commit 55e15e5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
29 changes: 15 additions & 14 deletions lib/charms/dex_auth/v0/dex_oidc_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 55e15e5

Please sign in to comment.