Skip to content

Commit

Permalink
Merge pull request #142 from pokt-foundation/patch/universal_helm_trunc
Browse files Browse the repository at this point in the history
Truncate chart, release and full name at 56 characters
  • Loading branch information
HebertCL authored Nov 11, 2024
2 parents e030e15 + f2e8d71 commit 660b95b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion charts/universal-helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Universal Helm chart

type: application

version: 0.0.23
version: 0.0.24
# Not compatible with 0.0.1 due to change container.command

appVersion: "1.16.0"
Expand Down
17 changes: 11 additions & 6 deletions charts/universal-helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
{{/*
Expand the name of the chart.
Name is truncated at 56 characters since certain Kubernetes fields are capped at 63 characters.
Instead of truncating at max characters, trunc gives room in case any prefix/suffix is used.
*/}}
{{- define "universal-helm.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- default .Chart.Name .Values.nameOverride | trunc 56 | 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).
We truncate at 56 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
Instead of truncating at max characters, trunc gives room in case any prefix/suffix is used.
If release name contains chart name it will be used as a full name.
*/}}
{{- define "universal-helm.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- .Values.fullnameOverride | trunc 56 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.global.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- .Release.Name | trunc 56 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- printf "%s-%s" .Release.Name $name | trunc 56 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
Chart is truncated at 56 characters since certain Kubernetes fields are capped at 63 characters.
Instead of truncating at max characters, trunc gives room in case any prefix/suffix is used.
*/}}
{{- define "universal-helm.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 56 | trimSuffix "-" }}
{{- end }}

{{/*
Expand Down

0 comments on commit 660b95b

Please sign in to comment.