Skip to content

Commit 92aa169

Browse files
authored
Merge pull request kiwigrid#4 from eloo/feature/use-namespace
Use NAMESPACE env variable to search on a specific namespace
2 parents 9505bcb + bc4c402 commit 92aa169

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ Example for a simple deployment can be found in `example.yaml`. Depending on the
3737
- required: true
3838
- type: string
3939

40+
- `NAMESPACE`
41+
- description: If specified, the sidecar will search for config-maps inside this namespace
42+
- required: false
43+
- type: string
44+
4045
- `REQ_URL`
4146
- description: URL to which send a request after a configmap got reloaded
4247
- required: false
@@ -51,5 +56,3 @@ Example for a simple deployment can be found in `example.yaml`. Depending on the
5156
- description: If you use POST you can also provide json payload
5257
- required: false
5358
- type: json
54-
55-

sidecar/sidecar.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ def removeFile(folder, filename):
4242
def watchForChanges(label, targetFolder, url, method, payload):
4343
v1 = client.CoreV1Api()
4444
w = watch.Watch()
45-
for event in w.stream(v1.list_config_map_for_all_namespaces):
45+
stream = None
46+
namespace = os.getenv("NAMESPACE")
47+
if namespace is None:
48+
stream = w.stream(v1.list_config_map_for_all_namespaces)
49+
else:
50+
stream = w.stream(v1.list_namespaced_config_map, namespace=namespace)
51+
for event in stream:
4652
metadata = event['object'].metadata
4753
if metadata.labels is None:
4854
continue

0 commit comments

Comments
 (0)