Skip to content

Commit 221df4d

Browse files
authored
make labeling conditional (#400)
Signed-off-by: Ben Luzarraga <luzarragaben@gmail.com>
1 parent 97a7946 commit 221df4d

File tree

5 files changed

+55
-25
lines changed

5 files changed

+55
-25
lines changed

helm-cluster-scoped/templates/00-crd.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ metadata:
77
name: namespacescopes.operator.ibm.com
88
labels:
99
component-id: {{ .Chart.Name }}
10-
{{- with .Values.cpfs.labels }}
11-
{{- toYaml . | nindent 4 }}
12-
{{- end }}
13-
{{- with .Values.cpfs.clusterLabels }}
14-
{{- toYaml . | nindent 4 }}
15-
{{- end }}
10+
{{- if .Values.cpfs.labels }}
11+
{{- with .Values.cpfs.labels }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
{{- end}}
15+
{{- if .Values.cpfs.clusterLabels }}
16+
{{- with .Values.cpfs.clusterLabels }}
17+
{{- toYaml . | nindent 4 }}
18+
{{- end }}
19+
{{- end}}
1620
spec:
1721
group: operator.ibm.com
1822
names:

helm-cluster-scoped/templates/01-cluster-rbac.yaml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ metadata:
44
name: ibm-namespace-scope-operator-{{ .Values.global.operatorNamespace }}
55
labels:
66
component-id: {{ .Chart.Name }}
7-
{{- with .Values.cpfs.labels }}
8-
{{- toYaml . | nindent 4 }}
9-
{{- end }}
10-
{{- with .Values.cpfs.clusterLabels }}
11-
{{- toYaml . | nindent 4 }}
12-
{{- end }}
7+
{{- if .Values.cpfs.labels }}
8+
{{- with .Values.cpfs.labels }}
9+
{{- toYaml . | nindent 4 }}
10+
{{- end }}
11+
{{- end}}
12+
{{- if .Values.cpfs.clusterLabels }}
13+
{{- with .Values.cpfs.clusterLabels }}
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
{{- end}}
1317
rules:
1418
- verbs:
1519
- create
@@ -38,6 +42,16 @@ metadata:
3842
name: ibm-namespace-scope-operator-{{ .Values.global.operatorNamespace }}
3943
labels:
4044
component-id: {{ .Chart.Name }}
45+
{{- if .Values.cpfs.labels }}
46+
{{- with .Values.cpfs.labels }}
47+
{{- toYaml . | nindent 4 }}
48+
{{- end }}
49+
{{- end}}
50+
{{- if .Values.cpfs.clusterLabels }}
51+
{{- with .Values.cpfs.clusterLabels }}
52+
{{- toYaml . | nindent 4 }}
53+
{{- end }}
54+
{{- end}}
4155
subjects:
4256
- kind: ServiceAccount
4357
name: ibm-namespace-scope-operator

helm/templates/00-rbac.yaml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
{{- if .Values.global.instanceNamespace }}
77
{{- $namespaces = append $namespaces .Values.global.instanceNamespace }}
88
{{- end }}
9-
{{- $labels := .Values.cpfs.labels }}
9+
{{- if .Values.cpfs.labels }}
10+
{{- $labels := .Values.cpfs.labels }}
11+
{{- end }}
1012
{{- range $i := $namespaces }}
1113
kind: Role
1214
apiVersion: rbac.authorization.k8s.io/v1
@@ -15,8 +17,10 @@ metadata:
1517
namespace: {{ $i }}
1618
labels:
1719
component-id: {{ $chartName }}
18-
{{- with $labels }}
19-
{{- toYaml . | nindent 4 }}
20+
{{- if .Values.cpfs.labels }}
21+
{{- with $labels }}
22+
{{- toYaml . | nindent 4 }}
23+
{{- end }}
2024
{{- end }}
2125
rules:
2226
- verbs:
@@ -98,8 +102,10 @@ metadata:
98102
namespace: {{ $i }}
99103
labels:
100104
component-id: {{ $chartName }}
101-
{{- with $labels }}
102-
{{- toYaml . | nindent 4 }}
105+
{{- if .Values.cpfs.labels }}
106+
{{- with $labels }}
107+
{{- toYaml . | nindent 4 }}
108+
{{- end }}
103109
{{- end }}
104110
subjects:
105111
- kind: ServiceAccount
@@ -119,8 +125,10 @@ metadata:
119125
app.kubernetes.io/managed-by: ibm-namespace-scope-operator
120126
app.kubernetes.io/name: ibm-namespace-scope-operator
121127
component-id: {{ .Chart.Name }}
122-
{{- with .Values.cpfs.labels }}
123-
{{- toYaml . | nindent 4 }}
128+
{{- if .Values.cpfs.labels }}
129+
{{- with $labels }}
130+
{{- toYaml . | nindent 4 }}
131+
{{- end }}
124132
{{- end }}
125133
name: ibm-namespace-scope-operator
126134
namespace: {{ .Values.global.operatorNamespace }}

helm/templates/01-operator-deployment.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ metadata:
99
app.kubernetes.io/name: ibm-namespace-scope-operator
1010
productName: IBM_Cloud_Platform_Common_Services
1111
component-id: {{ .Chart.Name }}
12-
{{- with .Values.cpfs.labels }}
13-
{{- toYaml . | nindent 4 }}
14-
{{- end }}
12+
{{- if .Values.cpfs.labels }}
13+
{{- with .Values.cpfs.labels }}
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
{{- end}}
1517
spec:
1618
replicas: 1
1719
selector:

helm/templates/02-nss-cr.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ metadata:
55
cpfs.helm/install: 'true'
66
foundationservices.cloudpak.ibm.com: nss
77
component-id: {{ .Chart.Name }}
8-
{{- with .Values.cpfs.labels }}
9-
{{- toYaml . | nindent 4 }}
10-
{{- end }}
8+
{{- if .Values.cpfs.labels }}
9+
{{- with .Values.cpfs.labels }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- end}}
1113
name: common-service
1214
namespace: {{ .Values.global.operatorNamespace }}
1315
spec:

0 commit comments

Comments
 (0)