Skip to content

Commit 20344ec

Browse files
fix: resource overrides in nginx-php templates (#267)
1 parent c8b6c28 commit 20344ec

File tree

6 files changed

+36
-7
lines changed

6 files changed

+36
-7
lines changed

legacy/helmcharts/nginx-php-persistent/templates/_helpers.tpl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,16 @@ Generate path for twig storage emptyDir
135135
{{- define "nginx-php-persistent.twig-storage.path" -}}
136136
{{- printf "%s/php" .Values.persistentStorage.path }}
137137
{{- end -}}
138+
139+
{{/*
140+
Merge resources from global over resources defined in the values
141+
*/}}
142+
{{- define "resources" -}}
143+
{{- $value := dict -}}
144+
{{- range (rest .) -}}
145+
{{- $value = merge $value . -}}
146+
{{- end -}}
147+
{{- if $value -}}
148+
{{- toYaml $value }}
149+
{{- end }}
150+
{{- end -}}

legacy/helmcharts/nginx-php-persistent/templates/deployment.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ spec:
109109
{{- toYaml .Values.dynamicSecretMounts | nindent 12 }}
110110
{{- end }}
111111
resources:
112-
{{- toYaml .Values.resources.nginx | nindent 12 }}
113-
112+
{{- include "resources" (list "resources" .Values.resources .Values.containerResources.nginx) | nindent 12 }}
114113
- image: {{ .Values.images.php | quote }}
115114
name: "php"
116115
imagePullPolicy: {{ .Values.imagePullPolicy }}
@@ -146,7 +145,7 @@ spec:
146145
{{- toYaml .Values.dynamicSecretMounts | nindent 12 }}
147146
{{- end }}
148147
resources:
149-
{{- toYaml .Values.resources.php | nindent 12 }}
148+
{{- include "resources" (list "resources" .Values.resources .Values.containerResources.php ) | nindent 12 }}
150149
{{- with .Values.nodeSelector }}
151150
nodeSelector:
152151
{{- toYaml . | nindent 8 }}

legacy/helmcharts/nginx-php-persistent/values.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fastly:
4040
# serviceId: ''
4141
# apiSecretName: ''
4242

43-
resources:
43+
containerResources:
4444
nginx:
4545
# limits:
4646
# cpu: 100m
@@ -56,6 +56,8 @@ resources:
5656
cpu: 10m
5757
memory: 100Mi
5858

59+
resources: {}
60+
5961
nodeSelector: {}
6062

6163
cronjobNodeSelector: {}

legacy/helmcharts/nginx-php/templates/_helpers.tpl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,16 @@ lagoon.sh/prHeadBranch: {{ .Values.prHeadBranch | quote }}
113113
lagoon.sh/prBaseBranch: {{ .Values.prBaseBranch | quote }}
114114
{{- end }}
115115
{{- end -}}
116+
117+
{{/*
118+
Merge resources from global over resources defined in the values
119+
*/}}
120+
{{- define "resources" -}}
121+
{{- $value := dict -}}
122+
{{- range (rest .) -}}
123+
{{- $value = merge $value . -}}
124+
{{- end -}}
125+
{{- if $value -}}
126+
{{- toYaml $value }}
127+
{{- end }}
128+
{{- end -}}

legacy/helmcharts/nginx-php/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ spec:
7272
- configMapRef:
7373
name: lagoon-env
7474
resources:
75-
{{- toYaml .Values.resources.nginx | nindent 12 }}
75+
{{- include "resources" (list "resources" .Values.resources .Values.containerResources.nginx ) | nindent 12 }}
7676
{{- if .Values.dynamicSecretMounts }}
7777
volumeMounts:
7878
{{- toYaml .Values.dynamicSecretMounts | nindent 12 }}
@@ -105,7 +105,7 @@ spec:
105105
- name: NGINX_FASTCGI_PASS
106106
value: '127.0.0.1'
107107
resources:
108-
{{- toYaml .Values.resources.php | nindent 12 }}
108+
{{- include "resources" (list "resources" .Values.resources .Values.containerResources.php ) | nindent 12 }}
109109
{{- if .Values.dynamicSecretMounts }}
110110
volumeMounts:
111111
{{- toYaml .Values.dynamicSecretMounts | nindent 12 }}

legacy/helmcharts/nginx-php/values.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fastly:
3737
# serviceId: ''
3838
# apiSecretName: ''
3939

40-
resources:
40+
containerResources:
4141
nginx:
4242
# limits:
4343
# cpu: 100m
@@ -53,6 +53,8 @@ resources:
5353
cpu: 10m
5454
memory: 100Mi
5555

56+
resources: {}
57+
5658
nodeSelector: {}
5759

5860
cronjobNodeSelector: {}

0 commit comments

Comments
 (0)