move file to helpers

This commit is contained in:
Stavros kois
2023-02-13 21:34:39 +02:00
parent 498461643b
commit 133423a17f
2 changed files with 6 additions and 5 deletions

View File

@@ -23,7 +23,7 @@ objectData: The service data, that will be used to render the Service object.
{{/* External Name / External IP does not rely on any pod values */}}
{{- if not (mustHas $svcType $specialTypes) -}}
{{/* Get Pod Values based on the selector (or the absence of it) */}}
{{- $podValues = fromJson (include "ix.v1.common.lib.service.getSelectedPodValues" (dict "rootCtx" $rootCtx "objectData" $objectData)) -}}
{{- $podValues = fromJson (include "ix.v1.common.lib.helpers.getSelectedPodValues" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "Service")) -}}
{{- if $podValues -}}
{{/* Get Pod hostNetwork configuration */}}

View File

@@ -1,24 +1,25 @@
{{/* Service - Get Selected Pod */}}
{{/* Call this template:
{{ include "ix.v1.common.lib.service.getSelectedPodValues" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
{{ include "ix.v1.common.lib.helpers.getSelectedPodValues" (dict "rootCtx" $rootCtx "objectData" $objectData) -}}
objectData: The object data of the service
rootCtx: The root context of the chart.
*/}}
{{- define "ix.v1.common.lib.service.getSelectedPodValues" -}}
{{- define "ix.v1.common.lib.helpers.getSelectedPodValues" -}}
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData -}}
{{- $caller := .caller -}}
{{- $podValues := dict -}}
{{- with $objectData.targetSelector -}}
{{- $podValues = mustDeepCopy (get $rootCtx.Values.workload .) -}}
{{- if not $podValues -}}
{{- fail (printf "Service - Selected pod [%s] is not defined" .) -}}
{{- fail (printf "%s - Selected pod [%s] is not defined" $caller .) -}}
{{- end -}}
{{- if not $podValues.enabled -}}
{{- fail (printf "Service - Selected pod [%s] is not enabled" .) -}}
{{- fail (printf "%s - Selected pod [%s] is not enabled" $caller .) -}}
{{- end -}}
{{/* While we know the shortName from targetSelector, let's set it explicitly