This is an automated email from the ASF dual-hosted git repository.

hefengen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shenyu-helm-chart.git


The following commit(s) were added to refs/heads/main by this push:
     new 16188b8  [type:fix] fix helm common template refers (#32)
16188b8 is described below

commit 16188b81967d2f33bb236792491a3c27b40845d9
Author: aias00 <rok...@163.com>
AuthorDate: Mon Jul 22 16:35:22 2024 +0800

    [type:fix] fix helm common template refers (#32)
    
    * fix helm common template refers
    
    * update helm version
---
 charts/shenyu/Chart.yaml             | 10 ++--
 charts/shenyu/templates/_helpers.tpl | 94 ++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+), 5 deletions(-)

diff --git a/charts/shenyu/Chart.yaml b/charts/shenyu/Chart.yaml
index bd26a43..65e5a68 100644
--- a/charts/shenyu/Chart.yaml
+++ b/charts/shenyu/Chart.yaml
@@ -2,7 +2,7 @@ apiVersion: v2
 name: shenyu
 description: Helm Chart for deploying Apache ShenYu in Kubernetes
 type: application
-version: 0.6.2
+version: 0.6.3
 appVersion: "2.5.1"
 icon: https://shenyu.apache.org/img/logo.png
 maintainers:
@@ -10,7 +10,7 @@ maintainers:
     email: wanneng...@gmail.com
   - name: aFlyBird0
     email: aflybi...@gmail.com
-dependencies:
-  - name: common
-    version: 1.x.x
-    repository: https://charts.bitnami.com/bitnami
+# dependencies:
+  # - name: common
+  #   version: 1.x.x
+  #   repository: https://charts.bitnami.com/bitnami
diff --git a/charts/shenyu/templates/_helpers.tpl 
b/charts/shenyu/templates/_helpers.tpl
index 4e61e8b..af10a3b 100644
--- a/charts/shenyu/templates/_helpers.tpl
+++ b/charts/shenyu/templates/_helpers.tpl
@@ -52,3 +52,97 @@ app.kubernetes.io/component: shenyu-bootstrap
 {{ include "common.labels.matchLabels" . }}
 app.kubernetes.io/component: shenyu-bootstrap
 {{- 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 "common.names.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 -}}
+
+{{/* vim: set filetype=mustache: */}}
+{{/*
+Renders a value that contains template perhaps with scope if the scope is 
present.
+Usage:
+{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value 
"context" $ ) }}
+{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value 
"context" $ "scope" $app ) }}
+*/}}
+{{- define "common.tplvalues.render" -}}
+{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
+{{- if contains "{{" (toJson .value) }}
+  {{- if .scope }}
+      {{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge 
(dict "RelativeScope" .scope) .context) }}
+  {{- else }}
+    {{- tpl $value .context }}
+  {{- end }}
+{{- else }}
+    {{- $value }}
+{{- end }}
+{{- end -}}
+
+
+{{/*
+Kubernetes standard labels
+{{ include "common.labels.standard" (dict "customLabels" .Values.commonLabels 
"context" $) -}}
+*/}}
+{{- define "common.labels.standard" -}}
+{{- if and (hasKey . "customLabels") (hasKey . "context") -}}
+{{- $default := dict "app.kubernetes.io/name" (include "common.names.name" 
.context) "helm.sh/chart" (include "common.names.chart" .context) 
"app.kubernetes.io/instance" .context.Release.Name 
"app.kubernetes.io/managed-by" .context.Release.Service -}}
+{{- with .context.Chart.AppVersion -}}
+{{- $_ := set $default "app.kubernetes.io/version" . -}}
+{{- end -}}
+{{ template "common.tplvalues.merge" (dict "values" (list .customLabels 
$default) "context" .context) }}
+{{- else -}}
+app.kubernetes.io/name: {{ include "common.names.name" . }}
+helm.sh/chart: {{ include "common.names.chart" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- with .Chart.AppVersion }}
+app.kubernetes.io/version: {{ . | quote }}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+
+{{/* vim: set filetype=mustache: */}}
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "common.names.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "common.names.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | 
trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Labels used on immutable fields such as deploy.spec.selector.matchLabels or 
svc.spec.selector
+{{ include "common.labels.matchLabels" (dict "customLabels" .Values.podLabels 
"context" $) -}}
+
+We don't want to loop over custom labels appending them to the selector
+since it's very likely that it will break deployments, services, etc.
+However, it's important to overwrite the standard labels if the user
+overwrote them on metadata.labels fields.
+*/}}
+{{- define "common.labels.matchLabels" -}}
+{{- if and (hasKey . "customLabels") (hasKey . "context") -}}
+{{ merge (pick (include "common.tplvalues.render" (dict "value" .customLabels 
"context" .context) | fromYaml) "app.kubernetes.io/name" 
"app.kubernetes.io/instance") (dict "app.kubernetes.io/name" (include 
"common.names.name" .context) "app.kubernetes.io/instance" 
.context.Release.Name ) | toYaml }}
+{{- else -}}
+app.kubernetes.io/name: {{ include "common.names.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end -}}
+{{- end -}}
\ No newline at end of file

Reply via email to