new way of doin
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
root
2023-11-16 19:42:02 +10:00
parent 77ec717184
commit 1eaf295724
341 changed files with 19416 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
{{/* Merge chart values and the common chart defaults */}}
{{/* The ".common" is the name of the library */}}
{{/* Call this template:
{{ include "tc.v1.common.values.init" $ }}
*/}}
{{- define "tc.v1.common.values.init" -}}
{{- if .Values.common -}}
{{- $commonValues := mustDeepCopy .Values.common -}}
{{- $chartValues := mustDeepCopy (omit .Values "common") -}}
{{- $mergedValues := mustMergeOverwrite $commonValues $chartValues -}}
{{- $_ := set . "Values" (mustDeepCopy $mergedValues) -}}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,18 @@
{{/* Validates any object that it does not contain helm errors */}}
{{/* This usually can happen after merging values from an include that did not render correcly */}}
{{/* Any object will be passed to "toYaml" */}}
{{/* Call this template:
{{ include "tc.v1.common.values.validate" . }}
*/}}
{{- define "tc.v1.common.values.validate" -}}
{{- $allValues := (toYaml .) -}}
{{- if contains "error converting YAML to JSON" $allValues -}}
{{/* Print values to show values with the error included. */}}
{{/* Ideally we would want to extract the error only, but because it usually contains ":",
It gets parsed as dict and it cant regex matched it afterwards */}}
{{- fail (printf "Chart - Values contain an error that may be a result of merging. Values containing the error: \n\n %v \n\n See error above values." $allValues) -}}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,21 @@
{{- define "tc.v1.common.values.deviceList" -}}
{{- $rootCtx := . -}}
{{- range $idx, $deviceValues := $rootCtx.Values.deviceList -}}
{{- if eq $deviceValues.type "device" -}}
{{- $name := (printf "device-%s" (toString $idx)) -}}
{{- with $deviceValues.name -}}
{{- $name = . -}}
{{- end -}}
{{- if not (hasKey $rootCtx.Values "persistence") -}}
{{- $_ := set $rootCtx.Values "persistence" dict -}}
{{- end -}}
{{- $_ := set $rootCtx.Values.persistence $name $deviceValues -}}
{{- else -}}
{{- fail (printf "Device List - Only [device] type can be defined in deviceList, but got [%s]" $deviceValues.type) -}}
{{- end -}}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,17 @@
{{- define "tc.v1.common.values.ingressList" -}}
{{- $rootCtx := . -}}
{{- range $idx, $ingressValues := $rootCtx.Values.ingressList -}}
{{- $name := (printf "ingress-list-%s" (toString $idx)) -}}
{{- with $ingressValues.name -}}
{{- $name = . -}}
{{- end -}}
{{- if not (hasKey $rootCtx.Values "ingress") -}}
{{- $_ := set $rootCtx.Values "ingress" dict -}}
{{- end -}}
{{- $_ := set $rootCtx.Values.ingress $name $ingressValues -}}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,21 @@
{{- define "tc.v1.common.values.persistenceList" -}}
{{- $rootCtx := . -}}
{{- range $idx, $persistenceValues := $rootCtx.Values.persistenceList -}}
{{- if ne $persistenceValues.type "device" -}}
{{- $name := (printf "persist-list-%s" (toString $idx)) -}}
{{- with $persistenceValues.name -}}
{{- $name = . -}}
{{- end -}}
{{- if not (hasKey $rootCtx.Values "persistence") -}}
{{- $_ := set $rootCtx.Values "persistence" dict -}}
{{- end -}}
{{- $_ := set $rootCtx.Values.persistence $name $persistenceValues -}}
{{- else -}}
{{- fail "Persistence List - type [device] should be defined in deviceList only" -}}
{{- end -}}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,34 @@
{{- define "tc.v1.common.values.portList" -}}
{{- $rootCtx := . -}}
{{- $svcValues := .svcValues -}}
{{- $hasPrimaryPort := false -}}
{{- range $portName, $portValues := $svcValues.ports -}}
{{- if $portValues.enabled -}}
{{- if $portValues.primary -}}
{{- $hasPrimaryPort = true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- range $portIdx, $portValues := $svcValues.portsList -}}
{{- $portName := (printf "port-list-%s" (toString $portIdx)) -}}
{{- if eq $portIdx 0 -}}
{{- if not $hasPrimaryPort -}}
{{- $_ := set $portValues "primary" true -}}
{{- end -}}
{{- end -}}
{{- with $portValues.name -}}
{{- $portName = . -}}
{{- end -}}
{{- if not (hasKey $svcValues "ports") -}}
{{- $_ := set $svcValues "ports" dict -}}
{{- end -}}
{{- $_ := set $svcValues.ports $portName $portValues -}}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,36 @@
{{- define "tc.v1.common.values.serviceList" -}}
{{- $rootCtx := . -}}
{{- $hasPrimary := false -}}
{{- range $svcName, $svcValues := $rootCtx.Values.service -}}
{{- if $svcValues.enabled -}}
{{- if $svcValues.primary -}}
{{- $hasPrimary = true -}}
{{- end -}} {{/* Check if "service" has a portList. */}}
{{- include "tc.v1.common.values.portList" (dict "rootCtx" $rootCtx "svcValues" $svcValues) -}}
{{- end -}}
{{- end -}}
{{- range $svcIdx, $svcValues := $rootCtx.Values.serviceList -}}
{{- $svcName := (printf "svc-list-%s" (toString $svcIdx)) -}}
{{- if eq $svcIdx 0 -}}
{{- if not $hasPrimary -}}
{{- $_ := set $svcValues "primary" true -}}
{{- end -}}
{{- end -}}
{{- with $svcValues.name -}}
{{- $svcName = . -}}
{{- end -}}
{{- if not (hasKey $rootCtx.Values "service") -}}
{{- $_ := set $rootCtx.Values "service" dict -}}
{{- end -}}
{{- include "tc.v1.common.values.portList" (dict "rootCtx" $rootCtx "svcValues" $svcValues) -}}
{{- $_ := set $rootCtx.Values.service $svcName $svcValues -}}
{{- end -}}
{{- end -}}