helm-charts/charts/library/common/templates/lib/controller/_getByIdentifier.tpl
Bernd Schorgers a01a89cb13
feat(common): Release common 4.0.0 (#398)
Co-authored-by: lab-assistant[bot] <180935599+lab-assistant[bot]@users.noreply.github.com>
2025-05-16 08:55:14 +02:00

19 lines
822 B
Smarty

{{/*
Return a controller object by its Identifier.
*/}}
{{- define "bjw-s.common.lib.controller.getByIdentifier" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if (hasKey $enabledControllers $identifier) -}}
{{- $objectValues := get $enabledControllers $identifier -}}
{{- /* Default the controller type to Deployment */ -}}
{{- if empty (dig "type" nil $objectValues) -}}
{{- $_ := set $objectValues "type" "deployment" -}}
{{- end -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledControllers)) -}}
{{- end -}}
{{- end -}}