Skip to content

Commit

Permalink
Added event handler for changes in 'avoidNamespaces' field
Browse files Browse the repository at this point in the history
  • Loading branch information
tymuraheiev committed Jan 19, 2025
1 parent da9b4ee commit 01c0bb0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ def on_delete(
logger.debug(f'csec {uid} deleted from memory ok')


@kopf.on.field('clustersecret.io', 'v1', 'clustersecrets', field='avoidNamespaces')
@kopf.on.field('clustersecret.io', 'v1', 'clustersecrets', field='matchNamespace')
def on_field_match_namespace(
def on_fields_avoid_or_match_namespace(
old: Optional[List[str]],
new: List[str],
name: str,
Expand All @@ -61,12 +62,11 @@ def on_field_match_namespace(
logger: logging.Logger,
**_,
):
logger.debug(f'Namespaces changed: {old} -> {new}')

if old is None:
logger.debug('This is a new object: Ignoring.')
return

logger.debug(f'Avoid or match namespaces changed: {old} -> {new}')
logger.debug(f'Updating Object body == {body}')

syncedns = body.get('status', {}).get('create_fn', {}).get('syncedns', [])
Expand All @@ -81,7 +81,7 @@ def on_field_match_namespace(
sync_secret(logger, secret_namespace, body, v1)

for secret_namespace in to_remove:
delete_secret(logger, secret_namespace, name, v1=v1)
delete_secret(logger, secret_namespace, name, v1)

cached_cluster_secret = csecs_cache.get_cluster_secret(uid)
if cached_cluster_secret is None:
Expand Down

0 comments on commit 01c0bb0

Please sign in to comment.