更新模板中函数备注信息

This commit is contained in:
2025-03-13 15:23:42 +08:00
parent 136d42a31e
commit 6754237844
13 changed files with 103 additions and 37 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ apiVersion: v2
# 针对库类型的 Helm Chart,保持 `version` 和 `appVersion` 定义一致 # 针对库类型的 Helm Chart,保持 `version` 和 `appVersion` 定义一致
version: 1.0.0 version: 1.0.0
appVersion: 1.0.0 appVersion: 1.0.0
description: Helm Chart 通用函数及工具库,用于其他 Helm Chart 仓库引用 description: Helm Chart 通用函数及工具库,用于其他 Helm Chart 仓库引用(基于 Bitnami 进行汉化、修改)
home: https://colovu.com home: https://colovu.com
maintainers: maintainers:
- name: Endial Fang(endial@126.com) - name: Endial Fang(endial@126.com)
+2 -3
View File
@@ -234,10 +234,9 @@
{{- end -}} {{- end -}}
{{/* {{/*
Helm 3.3+ Helm 3.3+true/flase
Helm 3.3.0 `.Capabilities.HelmVersion` 使 Helm `{{}}` Helm 3.3.0 `.Capabilities.HelmVersion` 使 Helm `{{}}`
使 `regexMatch` `{{ if .Capabilities.HelmVersion }}` Helm 3.3 使 `regexMatch` `{{ if .Capabilities.HelmVersion }}` Helm 3.3 HelmVersion
HelmVersion
** Helm 3.3 ** ** Helm 3.3 **
*/}} */}}
{{- define "common.capabilities.supportsHelmVersion" -}} {{- define "common.capabilities.supportsHelmVersion" -}}
+1 -1
View File
@@ -1,5 +1,5 @@
{{/* {{/*
Openshift true/false Openshift true/false
{{- include "common.compatibility.isOpenshift" . -}} {{- include "common.compatibility.isOpenshift" . -}}
*/}} */}}
+2 -2
View File
@@ -5,8 +5,8 @@
{{- $validationError01 := include "common.validations.values.single.empty" (dict "valueKey" "path.to.password01" "secret" "secretName" "field" "password-01") -}} {{- $validationError01 := include "common.validations.values.single.empty" (dict "valueKey" "path.to.password01" "secret" "secretName" "field" "password-01") -}}
{{ include "common.errors.upgrade.passwords.empty" (dict "validationErrors" (list $validationError00 $validationError01) "context" $) }} {{ include "common.errors.upgrade.passwords.empty" (dict "validationErrors" (list $validationError00 $validationError01) "context" $) }}
- validationErrors - - validationErrors:
- context - - context:
*/}} */}}
{{- define "common.errors.upgrade.passwords.empty" -}} {{- define "common.errors.upgrade.passwords.empty" -}}
{{- $validationErrors := join "" .validationErrors -}} {{- $validationErrors := join "" .validationErrors -}}
+4 -3
View File
@@ -1,6 +1,7 @@
{{/* {{/*
Tag digest 使 appVersion
Tag Digest 使 appVersion
{{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global "chart" .Chart ) }} {{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global "chart" .Chart ) }}
*/}} */}}
@@ -27,7 +28,7 @@
{{- end -}} {{- end -}}
{{/* {{/*
{{ include "common.images.renderPullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "context" $) }} {{ include "common.images.renderPullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "context" $) }}
*/}} */}}
@@ -62,7 +63,7 @@ imagePullSecrets:
{{- end -}} {{- end -}}
{{/* {{/*
revision/prerelease revision/prerelease 使 appVersion
{{ include "common.images.version" ( dict "imageRoot" .Values.path.to.the.image "chart" .Chart ) }} {{ include "common.images.version" ( dict "imageRoot" .Values.path.to.the.image "chart" .Chart ) }}
*/}} */}}
+6 -6
View File
@@ -3,9 +3,9 @@
{{ include "common.ingress.backend" (dict "serviceName" "backendName" "servicePort" "backendPort" "context" $) }} {{ include "common.ingress.backend" (dict "serviceName" "backendName" "servicePort" "backendPort" "context" $) }}
- serviceName - - serviceName:
- servicePort - /. YAML - servicePort: /. YAML
- context - `$`: `.`: - context: `$`: `.`:
*/}} */}}
{{- define "common.ingress.backend" -}} {{- define "common.ingress.backend" -}}
{{- $apiVersion := (include "common.capabilities.ingress.apiVersion" .context) -}} {{- $apiVersion := (include "common.capabilities.ingress.apiVersion" .context) -}}
@@ -25,7 +25,7 @@ service:
{{- end -}} {{- end -}}
{{/* {{/*
pathType true / false pathType true / false
{{ include "common.ingress.supportsPathType" . }} {{ include "common.ingress.supportsPathType" . }}
*/}} */}}
@@ -38,7 +38,7 @@ service:
{{- end -}} {{- end -}}
{{/* {{/*
ingressClassname true / false ingressClassname true / false
{{ include "common.ingress.supportsIngressClassname" . }} {{ include "common.ingress.supportsIngressClassname" . }}
*/}} */}}
@@ -51,7 +51,7 @@ service:
{{- end -}} {{- end -}}
{{/* {{/*
cert-manager true / false cert-manager TLS true / false
https://cert-manager.io/docs/usage/ingress/#supported-annotations https://cert-manager.io/docs/usage/ingress/#supported-annotations
+1 -1
View File
@@ -1,5 +1,5 @@
{{/* {{/*
K8s K8s
{{ include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) -}} {{ include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) -}}
*/}} */}}
+4 -3
View File
@@ -1,5 +1,5 @@
{{/* {{/*
K8s DNS 63 K8s DNS 63
*/}} */}}
{{- define "common.names.name" -}} {{- define "common.names.name" -}}
@@ -7,7 +7,8 @@
{{- end -}} {{- end -}}
{{/* {{/*
K8s DNS 63
*/}} */}}
{{- define "common.names.chart" -}} {{- define "common.names.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
@@ -50,7 +51,7 @@
{{- end -}} {{- end -}}
{{/* {{/*
namespace Namespace
*/}} */}}
{{- define "common.names.namespace" -}} {{- define "common.names.namespace" -}}
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}} {{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
+1
View File
@@ -1,5 +1,6 @@
{{/* {{/*
request/limit request/limit
使
{{ include "common.resources.preset" (dict "type" "nano") -}} {{ include "common.resources.preset" (dict "type" "nano") -}}
*/}} */}}
+12 -12
View File
@@ -3,9 +3,9 @@
{{ include "common.secrets.name" (dict "existingSecret" .Values.path.to.the.existingSecret "defaultNameSuffix" "mySuffix" "context" $) }} {{ include "common.secrets.name" (dict "existingSecret" .Values.path.to.the.existingSecret "defaultNameSuffix" "mySuffix" "context" $) }}
- existingSecret - Secret - existingSecret: Secret Secret
- defaultNameSuffix - Secret - defaultNameSuffix: Secret
- context - - context:
*/}} */}}
{{- define "common.secrets.name" -}} {{- define "common.secrets.name" -}}
{{- $name := (include "common.names.fullname" .context) -}} {{- $name := (include "common.names.fullname" .context) -}}
@@ -32,8 +32,8 @@
{{ include "common.secrets.key" (dict "existingSecret" .Values.path.to.the.existingSecret "key" "keyName") }} {{ include "common.secrets.key" (dict "existingSecret" .Values.path.to.the.existingSecret "key" "keyName") }}
- existingSecret - Secret - existingSecret: Secret Secret
- key - - key:
*/}} */}}
{{- define "common.secrets.key" -}} {{- define "common.secrets.key" -}}
{{- $key := .key -}} {{- $key := .key -}}
@@ -136,10 +136,10 @@ The order in which this function returns a secret password:
{{ include "common.secrets.lookup" (dict "secret" "secret-name" "key" "keyName" "defaultValue" .Values.myValue "context" $) }} {{ include "common.secrets.lookup" (dict "secret" "secret-name" "key" "keyName" "defaultValue" .Values.myValue "context" $) }}
- secret - Secret - secret: Secret
- key - Secret - key: Secret
- defaultValue - `values.yaml`"mysql.password" - defaultValue: `values.yaml`"mysql.password"
- context - - context:
*/}} */}}
{{- define "common.secrets.lookup" -}} {{- define "common.secrets.lookup" -}}
{{- $value := "" -}} {{- $value := "" -}}
@@ -155,12 +155,12 @@ The order in which this function returns a secret password:
{{- end -}} {{- end -}}
{{/* {{/*
secret定义true/false Secret定义true/false
{{ include "common.secrets.exists" (dict "secret" "secret-name" "context" $) }} {{ include "common.secrets.exists" (dict "secret" "secret-name" "context" $) }}
- secret - Secret - secret: Secret
- context - - context:
*/}} */}}
{{- define "common.secrets.exists" -}} {{- define "common.secrets.exists" -}}
{{- $secret := (lookup "v1" "Secret" (include "common.names.namespace" .context) .secret) }} {{- $secret := (lookup "v1" "Secret" (include "common.names.namespace" .context) .secret) }}
+1 -1
View File
@@ -1,5 +1,5 @@
{{/* {{/*
Storage Class Storage Class
{{ include "common.storage.class" ( dict "persistence" .Values.path.to.the.persistence "global" $) }} {{ include "common.storage.class" ( dict "persistence" .Values.path.to.the.persistence "global" $) }}
*/}} */}}
+2 -2
View File
@@ -1,5 +1,5 @@
{{/* {{/*
secret Secret
{{ include "common.utils.secret.getvalue" (dict "secret" "secret-name" "field" "secret-value-field" "context" $) }} {{ include "common.utils.secret.getvalue" (dict "secret" "secret-name" "field" "secret-value-field" "context" $) }}
*/}} */}}
@@ -61,7 +61,7 @@ export {{ $varname }}=$(kubectl get secret --namespace {{ include "common.names.
{{- end -}} {{- end -}}
{{/* {{/*
`path` **ConfigMapSecret便*Pod* `path` **ConfigMapSecret**便*Pod*
{{ include "common.utils.checksumTemplate" (dict "path" "/configmap.yaml" "context" $) }} {{ include "common.utils.checksumTemplate" (dict "path" "/configmap.yaml" "context" $) }}
*/}} */}}
+65 -1
View File
@@ -1,5 +1,5 @@
{{/* {{/*
使 TAG 使 TAG latest
{{ include "common.warnings.rollingTag" .Values.path.to.the.imageRoot }} {{ include "common.warnings.rollingTag" .Values.path.to.the.imageRoot }}
*/}} */}}
@@ -9,3 +9,67 @@
WARNING: Rolling tag detected ({{ .repository }}:{{ .tag }}), please note that it is strongly recommended to avoid using rolling tags in a production environment. WARNING: Rolling tag detected ({{ .repository }}:{{ .tag }}), please note that it is strongly recommended to avoid using rolling tags in a production environment.
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{/*
Resource
{{ include "common.warnings.resources" (dict "sections" (list "path1" "path2") context $) }}
:
{{- include "common.warnings.resources" (dict "sections" (list "csiProvider.provider" "server" "volumePermissions" "") "context" $) }}
The list in the example assumes that the following values exist:
- csiProvider.provider.resources
- server.resources
- volumePermissions.resources
- resources
*/}}
{{- define "common.warnings.resources" -}}
{{- $values := .context.Values -}}
{{- $printMessage := false -}}
{{ $affectedSections := list -}}
{{- range .sections -}}
{{- if eq . "" -}}
{{/* Case where the resources section is at the root (one main deployment in the chart) */}}
{{- if not (index $values "resources") -}}
{{- $affectedSections = append $affectedSections "resources" -}}
{{- $printMessage = true -}}
{{- end -}}
{{- else -}}
{{/* Case where the are multiple resources sections (more than one main deployment in the chart) */}}
{{- $keys := split "." . -}}
{{/* We iterate through the different levels until arriving to the resource section. Example: a.b.c.resources */}}
{{- $section := $values -}}
{{- range $keys -}}
{{- $section = index $section . -}}
{{- end -}}
{{- if not (index $section "resources") -}}
{{/* If the section has enabled=false or replicaCount=0, do not include it */}}
{{- if and (hasKey $section "enabled") -}}
{{- if index $section "enabled" -}}
{{/* enabled=true */}}
{{- $affectedSections = append $affectedSections (printf "%s.resources" .) -}}
{{- $printMessage = true -}}
{{- end -}}
{{- else if and (hasKey $section "replicaCount") -}}
{{/* We need a casting to int because number 0 is not treated as an int by default */}}
{{- if (gt (index $section "replicaCount" | int) 0) -}}
{{/* replicaCount > 0 */}}
{{- $affectedSections = append $affectedSections (printf "%s.resources" .) -}}
{{- $printMessage = true -}}
{{- end -}}
{{- else -}}
{{/* Default case, add it to the affected sections */}}
{{- $affectedSections = append $affectedSections (printf "%s.resources" .) -}}
{{- $printMessage = true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if $printMessage }}
WARNING: There are "resources" sections in the chart not set. Using "resourcesPreset" is not recommended for production. For production installations, please set the following values according to your workload needs:
{{- range $affectedSections }}
- {{ . }}
{{- end }}
+info https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
{{- end -}}
{{- end -}}