Files
nplus/charts/instance/templates/instance.tpl
2025-01-24 16:18:47 +01:00

55 lines
1.5 KiB
Smarty

{{- include "nplus.init" $ -}}
{{/*
Assemble List of Components
*/}}
{{- define "nplus.instance.getComponents" -}}
{{- $mylist := list -}}
{{- range $key, $value := .Values.components }}
{{- if $value }}
{{- $replicas := (( index $.Values $key ).replicaCount | default 1) | int }}
{{- if (gt $replicas 1) }}
{{- $mylist = append $mylist (printf "%s(%d)" ($key) $replicas) }}
{{- else }}
{{- $mylist = append $mylist (printf "%s" ($key)) }}
{{- end }}
{{- end }}
{{- end }}
{{- join "," $mylist -}}
{{- end -}}
{{/*
Assemble List of Expectations
*/}}
{{- define "nplus.instance.getExpected" -}}
{{- range $key, $value := .Values.components }}
{{- if $value }}
{{- $replicas := (( index $.Values $key ).replicaCount | default 1) | int }}
- component: {{ $key }}
replicaCount: {{ $replicas }}
{{- end }}
{{- end }}
{{- end -}}
apiVersion: nplus.cloud/v1beta1
kind: Instance
metadata:
{{- if .this.utils.includeNamespace }}
namespace: {{ .Release.Namespace }}
{{- end }}
name: {{ .Release.Name }}
labels:
{{- include "nplus.instanceLabels" . | nindent 4 }}
annotations:
{{- include "nplus.annotations" . | nindent 4 }}
argocd.argoproj.io/sync-wave: "1"
spec:
nscaleVersion: {{ .instance.version | quote }}
components: {{ include "nplus.instance.getComponents" . }}
handler: {{ .component.handler }}
expected:
{{- include "nplus.instance.getExpected" . | indent 2 }}
tenant: {{ (.this.meta).tenant }}
provider: {{ (.this.meta).provider }}
url: {{ include "nplus.url" . | quote }}