mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 17:07:04 +02:00
35 lines
1.3 KiB
Smarty
35 lines
1.3 KiB
Smarty
{{/*
|
|
Convert controller values to an object
|
|
*/}}
|
|
{{- define "bjw-s.common.lib.controller.valuesToObject" -}}
|
|
{{- $rootContext := .rootContext -}}
|
|
{{- $identifier := .id -}}
|
|
{{- $objectValues := .values -}}
|
|
|
|
{{- /* Default the controller type to Deployment */ -}}
|
|
{{- if empty (dig "type" nil $objectValues) -}}
|
|
{{- $_ := set $objectValues "type" "deployment" -}}
|
|
{{- end -}}
|
|
|
|
{{- /* Determine and inject the controller name */ -}}
|
|
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
|
|
|
|
{{- if $objectValues.nameOverride -}}
|
|
{{- $override := tpl $objectValues.nameOverride $rootContext -}}
|
|
{{- if not (eq $objectName $override) -}}
|
|
{{- $objectName = printf "%s-%s" $objectName $override -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) }}
|
|
{{- if gt (len $enabledControllers) 1 -}}
|
|
{{- if not (eq $objectName $identifier) -}}
|
|
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- $_ := set $objectValues "name" $objectName -}}
|
|
{{- $_ := set $objectValues "identifier" $identifier -}}
|
|
|
|
{{- /* Return the controller object */ -}}
|
|
{{- $objectValues | toYaml -}}
|
|
{{- end -}}
|