mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 08:57:04 +02:00
feat(common): Release common v4.1.0 (#416)
This commit is contained in:
parent
f3660654f4
commit
db552e2dee
52 changed files with 705 additions and 129 deletions
|
@ -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 -}}
|
|
@ -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 -}}
|
||||
|
|
|
@ -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 -}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue