<commit_before>{{/*
Expand the name of a component.
*/}}
{{- define "esgf.component.name" -}}
  {{- $context := index . 0 -}}
  {{- printf "%s-%s" $context.Chart.Name (index . 1 | kebabcase) | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a fully qualified component name for a named component.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If the release name contains the chart or component name, it is not duplicated.
*/}}
{{- define "esgf.component.fullname" -}}
  {{- $context := index . 0 -}}
  {{- $name := include "esgf.component.name" . -}}
  {{- if contains $context.Release.Name $name -}}
    {{- $name | trunc 63 | trimSuffix "-" -}}
  {{- else -}}
    {{- printf "%s-%s" $context.Release.Name $name | trunc 63 | trimSuffix "-" -}}
  {{- end -}}
{{- end -}}

{{/*
Common labels for a component.
*/}}
{{- define "esgf.component.labels" -}}
{{- $context := index . 0 -}}
helm.sh/chart: {{ printf "%s-%s" $context.Chart.Name $context.Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- if $context.Chart.AppVersion }}
app.kubernetes.io/version: {{ $context.Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ $context.Release.Service }}
{{ include "esgf.component.selectorLabels" . }}
{{- end -}}

{{/*
Selector labels for a component.
*/}}
{{- define "esgf.component.selectorLabels" -}}
{{- $context := index . 0 -}}
app.kubernetes.io/name: {{ $context.Chart.Name }}
app.kubernetes.io/instance: {{ $context.Release.Name }}
app.kubernetes.io/component: {{ index . 1 }}
{{- end -}}

{{/*
Produces an image specification.
*/}}
{{- define "esgf.component.image" -}}
{{- $context := index . 0 -}}
{{- $overrides := index . 1 -}}
{{- $image := mergeOverwrite $context.Values.image $overrides -}}
image: {{ printf "%s/%s:%s" $image.prefix $image.repository $image.tag }}
imagePullPolicy: {{ $image.pullPolicy }}
{{- end -}}

{{/*
Produces an image specification with the correct nesting for use in deployments.
*/}}
{{- define "esgf.deployment.image" -}}
{{- include "esgf.component.image" . | indent 10 | trim -}}
{{- end -}}

{{/*
Produces a volume name for the given volume configuration.
*/}}
{{- define "esgf.data.volumeName" -}}
{{- if .name -}}
{{- .name -}}
{{- else -}}<commit_msg>Fix problem with image defaults getting overwritten<commit_after>{{/*
Expand the name of a component.
*/}}
{{- define "esgf.component.name" -}}
  {{- $context := index . 0 -}}
  {{- printf "%s-%s" $context.Chart.Name (index . 1 | kebabcase) | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a fully qualified component name for a named component.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If the release name contains the chart or component name, it is not duplicated.
*/}}
{{- define "esgf.component.fullname" -}}
  {{- $context := index . 0 -}}
  {{- $name := include "esgf.component.name" . -}}
  {{- if contains $context.Release.Name $name -}}
    {{- $name | trunc 63 | trimSuffix "-" -}}
  {{- else -}}
    {{- printf "%s-%s" $context.Release.Name $name | trunc 63 | trimSuffix "-" -}}
  {{- end -}}
{{- end -}}

{{/*
Common labels for a component.
*/}}
{{- define "esgf.component.labels" -}}
{{- $context := index . 0 -}}
helm.sh/chart: {{ printf "%s-%s" $context.Chart.Name $context.Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- if $context.Chart.AppVersion }}
app.kubernetes.io/version: {{ $context.Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ $context.Release.Service }}
{{ include "esgf.component.selectorLabels" . }}
{{- end -}}

{{/*
Selector labels for a component.
*/}}
{{- define "esgf.component.selectorLabels" -}}
{{- $context := index . 0 -}}
app.kubernetes.io/name: {{ $context.Chart.Name }}
app.kubernetes.io/instance: {{ $context.Release.Name }}
app.kubernetes.io/component: {{ index . 1 }}
{{- end -}}

{{/*
Produces an image specification.
*/}}
{{- define "esgf.component.image" -}}
{{- $context := index . 0 -}}
{{- $overrides := index . 1 -}}
{{- $image := deepCopy $context.Values.image | merge $overrides -}}
image: {{ printf "%s/%s:%s" $image.prefix $image.repository $image.tag }}
imagePullPolicy: {{ $image.pullPolicy }}
{{- end -}}

{{/*
Produces an image specification with the correct nesting for use in deployments.
*/}}
{{- define "esgf.deployment.image" -}}
{{- include "esgf.component.image" . | indent 10 | trim -}}
{{- end -}}

{{/*
Produces a volume name for the given volume configuration.
*/}}
{{- define "esgf.data.volumeName" -}}
{{- if .name -}}
{{- .name -}}
{{- else -}}
{'fraction_non_alphanumeric': 0.21817004747518343, 'fraction_numerical': 0.008631851532153647, 'mean_word_length': 3.311627906976744, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6430881', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1536, 'n_words': 405}