{{/* vim: set filetype=mustache: */}} {{/* Expand the name of the chart. */}} {{- define "portalmodelo.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). If release name contains chart name it will be used as a full name. */}} {{- define "portalmodelo.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} {{- $name := default .Chart.Name .Values.nameOverride }} {{- if contains $name .Release.Name }} {{- .Release.Name | trunc 63 | trimSuffix "-" }} {{- else }} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} {{- end }} {{- end }} {{- end }} {{/* Create chart name and version as used by the chart label. */}} {{- define "portalmodelo.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} {{- define "portalmodelo.labels" -}} helm.sh/chart: {{ include "portalmodelo.chart" . }} app.kubernetes.io/name: {{ include "portalmodelo.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} {{/* Common selector labels */}} {{- define "portalmodelo.selectorLabels" -}} app.kubernetes.io/name: {{ include "portalmodelo.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Selector labels for Plone component */}} {{- define "portalmodelo.ploneSelectorLabels" -}} {{ include "portalmodelo.selectorLabels" . }} app.kubernetes.io/component: plone {{- end }} {{/* Selector labels for ZEO Server component */}} {{- define "portalmodelo.zeoserverSelectorLabels" -}} {{ include "portalmodelo.selectorLabels" . }} app.kubernetes.io/component: zeoserver {{- end }} {{/* Calculates zeoInitialDelaySeconds from a Kubernetes resource quantity (Ki, Mi, Gi, K, M, G, or raw bytes). Usage: include "portalmodelo.zeoInitialDelaySeconds" .Values.persistence.size */}} {{- define "portalmodelo.zeoInitialDelaySeconds" -}} {{- $rawSize := . | toString -}} {{- $num := regexFind "[0-9]+" $rawSize | default "0" | float64 -}} {{- $unit := regexFind "[a-zA-Z]+" $rawSize | default "" | upper -}} {{- $sizeGiFloat := $num -}} {{- if eq $unit "KI" -}} {{- $sizeGiFloat = divf $num 1048576 -}} {{- else if eq $unit "MI" -}} {{- $sizeGiFloat = divf $num 1024 -}} {{- else if eq $unit "GI" -}} {{- $sizeGiFloat = $num -}} {{- else if eq $unit "K" -}} {{- $sizeGiFloat = divf $num 1000000 -}} {{- else if eq $unit "M" -}} {{- $sizeGiFloat = divf $num 1000 -}} {{- else if eq $unit "G" -}} {{- $sizeGiFloat = $num -}} {{- else if eq $unit "TI" -}} {{- $sizeGiFloat = mulf $num 1024 -}} {{- end -}} {{- $calculatedSeconds := int64 (round (mulf $sizeGiFloat 0.9) 0) -}} {{- /* Clamp between min (30s) and max (720s / 12m) */ -}} {{- if lt $calculatedSeconds 30 -}} 30 {{- else if gt $calculatedSeconds 720 -}} 720 {{- else -}} {{- $calculatedSeconds -}} {{- end -}} {{- end -}}