From db1e59d6dea3224ddca4768a3900d364bcc583bf Mon Sep 17 00:00:00 2001 From: Prajith Ndz Date: Sat, 13 Feb 2021 18:17:14 +0530 Subject: [PATCH] set all variables out of function --- handlers.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/handlers.py b/handlers.py index aeb7dcb..6e8003b 100644 --- a/handlers.py +++ b/handlers.py @@ -2,16 +2,15 @@ import kubernetes import os -def watch_namespace(namespace, **_): - namespaces = os.getenv('WATCH_NAMESPACE') - if namespaces is None or namespaces == "": - return True +WATCH_NAMESPACE = os.getenv('WATCH_NAMESPACE') +if WATCH_NAMESPACE is not None: + all_namespaces = WATCH_NAMESPACE.split(',') - all_namespaces = namespaces.split(',') - if namespace in all_namespaces: +def watch_namespace(namespace, **_): + if WATCH_NAMESPACE == "" or namespace in all_namespaces: return True return False - + @kopf.on.create('', 'v1', 'secrets', annotations={'synator/sync': 'yes'}, when=watch_namespace) @kopf.on.update('', 'v1', 'secrets', annotations={'synator/sync': 'yes'}, when=watch_namespace) def update_secret(body, meta, spec, status, old, new, diff, **kwargs):