@@ -230,46 +230,44 @@ Apply scaledOverProvisionRatio to scalingModifiers. Link with autoscaling templa
230230Common autoscaling spec template
231231*/} }
232232{ {- define " seleniumGrid.autoscalingTemplate" -} }
233- { {- $spec := (dict) -} }
233+ { {- $spec := toYaml (dict) -} }
234234{ {- $nodeMaxSessions := default $.Values.global.seleniumGrid.nodeMaxSessions .node.nodeMaxSessions | int64 -} }
235235{ {- $nodeEnableManagedDownloads := default $.Values.global.seleniumGrid.nodeEnableManagedDownloads .node.nodeEnableManagedDownloads -} }
236236{ {- $nodeCustomCapabilities := default $.Values.global.seleniumGrid.nodeCustomCapabilities .node.nodeCustomCapabilities -} }
237237{ {/* Merge with precedence from right to left */} }
238238{ {- with $.Values.autoscaling.scaledOptions -} }
239- { {- $spec = mergeOverwrite ($spec ) . -} }
239+ { {- $spec = mergeOverwrite ($spec | fromYaml ) . | toYaml -} }
240240{ {- end -} }
241241{ {- with .node.scaledOptions -} }
242- { {- $spec = mergeOverwrite ($spec ) . -} }
242+ { {- $spec = mergeOverwrite ($spec | fromYaml ) . | toYaml -} }
243243{ {- end -} }
244244{ {- if eq $.Values.autoscaling.scalingType " deployment" -} }
245- { {- $advanced := (dict " scaleTargetRef" (dict " name" .name) " advanced" (dict " horizontalPodAutoscalerConfig" (dict " name" .name))) -} }
246- { {- $advanced = mergeOverwrite $advanced (include " seleniumGrid.autoscaling.scaledOverProvisionRatio" . | fromYaml) } }
247- { {- $spec = mergeOverwrite ($spec ) $advanced -} }
248245 { {- with $.Values.autoscaling.scaledObjectOptions -} }
249- { {- $spec = mergeOverwrite ($spec ) . -} }
246+ { {- $spec = mergeOverwrite ($spec | fromYaml ) . | toYaml -} }
250247 { {- end -} }
251248 { {- with .node.scaledObjectOptions -} }
252- { {- $spec = mergeOverwrite ($spec ) . -} }
249+ { {- $spec = mergeOverwrite ($spec | fromYaml ) . | toYaml -} }
253250 { {- end -} }
251+ { {- $advanced := (dict " scaleTargetRef" (dict " name" .name) " advanced" (dict " horizontalPodAutoscalerConfig" (dict " name" .name) " restoreToOriginalReplicaCount" true )) -} }
252+ { {- $advanced = mergeOverwrite $advanced (include " seleniumGrid.autoscaling.scaledOverProvisionRatio" . | fromYaml) } }
253+ { {- $spec = mergeOverwrite ($spec | fromYaml) $advanced | toYaml -} }
254254{ {- else if eq $.Values.autoscaling.scalingType " job" -} }
255- { {- $spec = mergeOverwrite ($spec ) (dict " jobTargetRef" .podTemplate) -} }
256255 { {- with $.Values.autoscaling.scaledJobOptions -} }
257- { {- $spec = mergeOverwrite ($spec ) . -} }
256+ { {- $spec = mergeOverwrite ($spec | fromYaml ) . | toYaml -} }
258257 { {- end -} }
259258 { {- with .node.scaledJobOptions -} }
260- { {- $spec = mergeOverwrite ($spec ) . -} }
259+ { {- $spec = mergeOverwrite ($spec | fromYaml ) . | toYaml -} }
261260 { {- end -} }
261+ { {- $spec = mergeOverwrite ($spec | fromYaml) (dict " jobTargetRef" .podTemplate) | toYaml -} }
262262{ {- end -} }
263- { {- if and $spec (not (empty $spec ) ) -} }
263+ { {- if and $spec (ne $spec " {} " ) -} }
264264 { {- $cleanSpec := dict -} }
265- { {- range $key , $value := $spec -} }
265+ { {- range $key , $value := ( $spec | fromYaml) -} }
266266 { {- if not (empty $value ) -} }
267267 { {- $cleanSpec = set $cleanSpec $key $value -} }
268268 { {- end -} }
269269 { {- end -} }
270- { {- if not (empty $cleanSpec ) -} }
271- { {- toYaml $cleanSpec | nindent 0 | trim -} }
272- { {- end -} }
270+ { { tpl ($cleanSpec | toYaml) $ } }
273271{ {- end -} }
274272{ {- if not $.Values.autoscaling.scaledOptions.triggers } }
275273triggers:
@@ -299,7 +297,7 @@ triggers:
299297 { {- if and (eq $.Values.autoscaling.scalingType " deployment" ) $.Values.autoscaling.metricType } }
300298 metricType: { { $.Values.autoscaling.metricType } }
301299 { {- end } }
302- { {- end - } }
300+ { {- end } }
303301{ {- end -} }
304302
305303{ {/*
0 commit comments