Skip to content

Commit 80cb98a

Browse files
mms-build-accountRodrigo Valin
authored andcommitted
Updated: helm_chart/templates/database-roles.yaml
1 parent 96803c7 commit 80cb98a

File tree

1 file changed

+26
-36
lines changed

1 file changed

+26
-36
lines changed
Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,54 @@
1+
{{- $watchNamespace := list .Values.namespace }}
2+
{{- if .Values.operator.watchNamespace }}
3+
{{- $watchNamespace = regexSplit "," .Values.operator.watchNamespace -1 }}
4+
{{- end }}
5+
6+
7+
{{- range $idx, $namespace := $watchNamespace }}
8+
9+
{{- $namespaceBlock := printf "namespace: %s" $namespace }}
10+
{{- if eq $namespace "*" }}
11+
{{- $namespaceBlock = printf "namespace: %s" $.Values.namespace }}
12+
{{- end }}
113
---
214
apiVersion: v1
315
kind: ServiceAccount
416
metadata:
517
name: mongodb-enterprise-appdb
6-
{{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }}
7-
namespace: {{ .Values.operator.watchNamespace }}
8-
{{- else }}
9-
namespace: {{ .Values.namespace }}
10-
{{- end }}
11-
{{- if .Values.registry.imagePullSecrets}}
18+
{{ $namespaceBlock }}
19+
{{- if $.Values.registry.imagePullSecrets}}
1220
imagePullSecrets:
13-
- name: {{ .Values.registry.imagePullSecrets }}
21+
- name: {{ $.Values.registry.imagePullSecrets }}
1422
{{- end }}
1523

1624
---
1725
apiVersion: v1
1826
kind: ServiceAccount
1927
metadata:
2028
name: mongodb-enterprise-database-pods
21-
{{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }}
22-
namespace: {{ .Values.operator.watchNamespace }}
23-
{{- else }}
24-
namespace: {{ .Values.namespace }}
25-
{{- end }}
26-
{{- if .Values.registry.imagePullSecrets}}
29+
{{ $namespaceBlock }}
30+
{{- if $.Values.registry.imagePullSecrets}}
2731
imagePullSecrets:
28-
- name: {{ .Values.registry.imagePullSecrets }}
32+
- name: {{ $.Values.registry.imagePullSecrets }}
2933
{{- end }}
3034

3135
---
3236
apiVersion: v1
3337
kind: ServiceAccount
3438
metadata:
3539
name: mongodb-enterprise-ops-manager
36-
{{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }}
37-
namespace: {{ .Values.operator.watchNamespace }}
38-
{{- else }}
39-
namespace: {{ .Values.namespace }}
40-
{{- end }}
41-
{{- if .Values.registry.imagePullSecrets}}
40+
{{ $namespaceBlock }}
41+
{{- if $.Values.registry.imagePullSecrets}}
4242
imagePullSecrets:
43-
- name: {{ .Values.registry.imagePullSecrets }}
43+
- name: {{ $.Values.registry.imagePullSecrets }}
4444
{{- end }}
4545

4646
---
4747
kind: Role
4848
apiVersion: rbac.authorization.k8s.io/v1
4949
metadata:
5050
name: mongodb-enterprise-appdb
51-
{{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }}
52-
namespace: {{ .Values.operator.watchNamespace }}
53-
{{- else }}
54-
namespace: {{ .Values.namespace }}
55-
{{- end }}
51+
{{ $namespaceBlock }}
5652
rules:
5753
- apiGroups:
5854
- ""
@@ -74,20 +70,14 @@ kind: RoleBinding
7470
apiVersion: rbac.authorization.k8s.io/v1
7571
metadata:
7672
name: mongodb-enterprise-appdb
77-
{{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }}
78-
namespace: {{ .Values.operator.watchNamespace }}
79-
{{- else }}
80-
namespace: {{ .Values.namespace }}
81-
{{- end }}
73+
{{ $namespaceBlock }}
8274
roleRef:
8375
apiGroup: rbac.authorization.k8s.io
8476
kind: Role
8577
name: mongodb-enterprise-appdb
8678
subjects:
8779
- kind: ServiceAccount
8880
name: mongodb-enterprise-appdb
89-
{{- if not (eq (.Values.operator.watchNamespace | default "*") "*") }}
90-
namespace: {{ .Values.operator.watchNamespace }}
91-
{{- else }}
92-
namespace: {{ .Values.namespace }}
93-
{{- end }}
81+
{{ $namespaceBlock }}
82+
83+
{{- end }}

0 commit comments

Comments
 (0)