Skip to content

Commit dbeab3a

Browse files
authored
Merge pull request #88 from snyk/chore/tilt_fixes
chore: fix Tiltfile to correctly set namspace
2 parents 8ad0e72 + 3b63fd5 commit dbeab3a

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ docker_build("snyk/kubernetes-monitor", ".",
55
]
66
)
77

8-
k8s_yaml(local("helm template snyk-monitor"))
8+
k8s_yaml(local("helm template snyk-monitor | ./add-ns.py snyk-monitor"))
99
watch_file("snyk-monitor")

add-ns.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python3
2+
3+
import yaml
4+
import sys
5+
6+
# The purpose of this script is to act as if we ran the helm installation with `--namespace XXX`.
7+
# Therefore the script does the following:
8+
# 1. Set `metadata.namespace` key to each manifest (yaml)
9+
# 2. Set all the uses of `.Release.Namespace` in our helm chart to the given namespace -
10+
# currently used only in the `subjects` key in rolebinding.yaml and clusterrolebinding.yaml
11+
12+
for manifest in yaml.load_all(sys.stdin):
13+
if manifest:
14+
if 'metadata' in manifest and 'namespace' not in manifest['metadata']:
15+
manifest['metadata']['namespace'] = sys.argv[1]
16+
if 'subjects' in manifest:
17+
for subject in manifest['subjects']:
18+
subject['namespace'] = sys.argv[1]
19+
20+
print('---')
21+
print(yaml.dump(manifest))

0 commit comments

Comments
 (0)