helm-charts/charts/library/common/templates/lib/routes/_enabled_routes.tpl
2025-06-11 14:09:46 +00:00

29 lines
1.1 KiB
Smarty

{{/*
Return the enabled routes.
*/}}
{{- define "bjw-s.common.lib.route.enabledRoutes" -}}
{{- $rootContext := .rootContext -}}
{{- $enabledRoutes := dict -}}
{{- range $name, $route := $rootContext.Values.route -}}
{{- if kindIs "map" $route -}}
{{- /* Enable Route by default, but allow override */ -}}
{{- $routeEnabled := true -}}
{{- if hasKey $route "enabled" -}}
{{- $routeEnabled = $route.enabled -}}
{{- end -}}
{{- if $routeEnabled -}}
{{- $_ := set $enabledRoutes $name . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- range $identifier, $objectValues := $enabledRoutes -}}
{{- $object := include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledRoutes)) | fromYaml -}}
{{- $object = include "bjw-s.common.lib.route.autoDetectService" (dict "rootContext" $rootContext "object" $object) | fromYaml -}}
{{- $_ := set $enabledRoutes $identifier $object -}}
{{- end -}}
{{- $enabledRoutes | toYaml -}}
{{- end -}}