diff --git a/app/app.py b/app/app.py index 7c4144c..9a63105 100755 --- a/app/app.py +++ b/app/app.py @@ -11,6 +11,9 @@ devenv = bool(os.getenv("DEV_ENV", False)) api_key = os.environ["API_KEY"] users_lookup = {} +def resource_is_deleted(event, **_): + return event["type"] == "DELETED" + def authorized(): def decorator(f): @wraps(f) @@ -66,7 +69,7 @@ async def save_handler(body, **_): print(f"Saving {username}") users_lookup[username] = user -@kopf.on.delete('oidcgatewayusers') +@kopf.on.event('', 'v1', 'oidcgatewayusers', when=resource_is_deleted) async def delete_handler(body, **_): username = body['metadata']['name'] print(f"Deleting {username}")