feat(common): Release common v4.1.0 (#416)

This commit is contained in:
Bernd Schorgers 2025-06-11 16:09:46 +02:00 committed by GitHub
parent f3660654f4
commit db552e2dee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 705 additions and 129 deletions

View file

@ -0,0 +1,15 @@
{{/*
Autodetects the controller for a Service object
*/}}
{{- define "bjw-s.common.lib.service.autoDetectController" -}}
{{- $rootContext := .rootContext -}}
{{- $serviceObject := .object -}}
{{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{- if eq 1 (len $enabledControllers) -}}
{{- if (empty (dig "controller" nil $serviceObject)) -}}
{{- $_ := set $serviceObject "controller" ($enabledControllers | keys | first) -}}
{{- end -}}
{{- end -}}
{{- $serviceObject | toYaml -}}
{{- end -}}

View file

@ -5,21 +5,25 @@ Return the enabled services.
{{- $rootContext := .rootContext -}}
{{- $enabledServices := dict -}}
{{- range $name, $service := $rootContext.Values.service -}}
{{- if kindIs "map" $service -}}
{{- range $identifier, $objectValues := $rootContext.Values.service -}}
{{- if kindIs "map" $objectValues -}}
{{- /* Enable Service by default, but allow override */ -}}
{{- $serviceEnabled := true -}}
{{- if hasKey $service "enabled" -}}
{{- $serviceEnabled = $service.enabled -}}
{{- if hasKey $objectValues "enabled" -}}
{{- $serviceEnabled = $objectValues.enabled -}}
{{- end -}}
{{- if $serviceEnabled -}}
{{- $_ := set $enabledServices $name . -}}
{{- $_ := set $enabledServices $identifier $objectValues -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- range $identifier, $objectValues := $enabledServices -}}
{{- $object := include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledServices)) | fromYaml -}}
{{- $object = include "bjw-s.common.lib.service.autoDetectController" (dict "rootContext" $rootContext "object" $object) | fromYaml -}}
{{- $_ := set $enabledServices $identifier $object -}}
{{- end -}}
{{- $enabledServices | toYaml -}}
{{- end -}}

View file

@ -5,18 +5,8 @@ Return a service Object by its Identifier.
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) -}}
{{- if (hasKey $enabledServices $identifier) -}}
{{- $objectValues := get $enabledServices $identifier -}}
{{- $object := include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledServices)) | fromYaml -}}
{{- if eq 1 (len $enabledControllers) -}}
{{- if (empty (dig "controller" nil $object)) -}}
{{- $_ := set $object "controller" ($enabledControllers | keys | first) -}}
{{- end -}}
{{- end -}}
{{- $object | toYaml -}}
{{- get $enabledServices $identifier | toYaml -}}
{{- end -}}
{{- end -}}