From 8bd89e6f2fcc1da4c4097f6b716ed9c995e6532a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Schr=C3=B6ter?= Date: Thu, 19 Dec 2024 14:59:52 +0100 Subject: [PATCH] fix: change order of resource-names being prefixed --- README.md | 2 +- src/resources.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 54297a1..f906638 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ If the filename ends with `.url` suffix, the content will be processed as a URL | `FOLDER_ANNOTATION` | The annotation the sidecar will look for in configmaps to override the destination folder for files. The annotation _value_ can be either an absolute or a relative path. Relative paths will be relative to `FOLDER`. | false | `k8s-sidecar-target-directory` | string | | `NAMESPACE` | Comma separated list of namespaces. If specified, the sidecar will search for config-maps inside these namespaces. It's also possible to specify `ALL` to search in all namespaces. | false | namespace in which the sidecar is running | string | | `RESOURCE` | Resource type, which is monitored by the sidecar. Options: `configmap`, `secret`, `both` | false | `configmap` | string | -| `RESOURCE_NAME` | Comma separated list of resource names, which are monitored by the sidecar. Items can be prefixed by the namespace and the resource type. E.g. `namespace/resource-name` or `secret/namespace/resource-name`. Setting this will result `method` set to `WATCH` being treated as `SLEEP` | false | - | string | +| `RESOURCE_NAME` | Comma separated list of resource names, which are monitored by the sidecar. Items can be prefixed by the namespace and the resource type. E.g. `secret/resource-name` or `namespace/secret/resource-name`. Setting this will result `method` set to `WATCH` being treated as `SLEEP` | false | - | string | | `METHOD` | If `METHOD` is set to `LIST`, the sidecar will just list config-maps/secrets and exit. With `SLEEP` it will list all config-maps/secrets, then sleep for `SLEEP_TIME` seconds. Anything else will continuously watch for changes (see https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes). | false | - | string | | `SLEEP_TIME` | How many seconds to wait before updating config-maps/secrets when using `SLEEP` method. | false | `60` | integer | | `REQ_URL` | URL to which send a request after a configmap/secret got reloaded | false | - | URI | diff --git a/src/resources.py b/src/resources.py index 9b1f9e4..cf78149 100755 --- a/src/resources.py +++ b/src/resources.py @@ -118,9 +118,9 @@ def list_resources(label, label_value, target_folder, request_url, request_metho if namespace != "ALL" and resource_name: for rn in resource_name.split(","): splitted_rn = list(reversed(rn.split("/"))) - if len(splitted_rn) == 3 and splitted_rn[2] != resource: + if len(splitted_rn) == 3 and splitted_rn[2] != namespace: continue - if len(splitted_rn) == 2 and splitted_rn[1] != namespace: + if len(splitted_rn) == 2 and splitted_rn[1] != resource: continue resource_names.append(splitted_rn[0])