更新模板中函数备注信息

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` 定义一致
version: 1.0.0
appVersion: 1.0.0
description: Helm Chart 通用函数及工具库,用于其他 Helm Chart 仓库引用
description: Helm Chart 通用函数及工具库,用于其他 Helm Chart 仓库引用(基于 Bitnami 进行汉化、修改)
home: https://colovu.com
maintainers:
- name: Endial Fang(endial@126.com)
+2 -3
View File
@@ -234,10 +234,9 @@
{{- end -}}
{{/*
Helm 3.3+
Helm 3.3+true/flase
Helm 3.3.0 `.Capabilities.HelmVersion` 使 Helm `{{}}`
使 `regexMatch` `{{ if .Capabilities.HelmVersion }}` Helm 3.3
HelmVersion
使 `regexMatch` `{{ if .Capabilities.HelmVersion }}` Helm 3.3 HelmVersion
** Helm 3.3 **
*/}}
{{- define "common.capabilities.supportsHelmVersion" -}}
+1 -1
View File
@@ -1,5 +1,5 @@
{{/*
Openshift true/false
Openshift true/false
{{- 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") -}}
{{ include "common.errors.upgrade.passwords.empty" (dict "validationErrors" (list $validationError00 $validationError01) "context" $) }}
- validationErrors -
- context -
- validationErrors:
- context:
*/}}
{{- define "common.errors.upgrade.passwords.empty" -}}
{{- $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 ) }}
*/}}
@@ -27,7 +28,7 @@
{{- end -}}
{{/*
{{ include "common.images.renderPullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "context" $) }}
*/}}
@@ -62,7 +63,7 @@ imagePullSecrets:
{{- end -}}
{{/*
revision/prerelease
revision/prerelease 使 appVersion
{{ 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" $) }}
- serviceName -
- servicePort - /. YAML
- context - `$`: `.`:
- serviceName:
- servicePort: /. YAML
- context: `$`: `.`:
*/}}
{{- define "common.ingress.backend" -}}
{{- $apiVersion := (include "common.capabilities.ingress.apiVersion" .context) -}}
@@ -25,7 +25,7 @@ service:
{{- end -}}
{{/*
pathType true / false
pathType true / false
{{ include "common.ingress.supportsPathType" . }}
*/}}
@@ -38,7 +38,7 @@ service:
{{- end -}}
{{/*
ingressClassname true / false
ingressClassname true / false
{{ include "common.ingress.supportsIngressClassname" . }}
*/}}
@@ -51,7 +51,7 @@ service:
{{- end -}}
{{/*
cert-manager true / false
cert-manager TLS true / false
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" $) -}}
*/}}
+4 -3
View File
@@ -1,5 +1,5 @@
{{/*
K8s DNS 63
*/}}
{{- define "common.names.name" -}}
@@ -7,7 +7,8 @@
{{- end -}}
{{/*
K8s DNS 63
*/}}
{{- define "common.names.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
@@ -50,7 +51,7 @@
{{- end -}}
{{/*
namespace
Namespace
*/}}
{{- define "common.names.namespace" -}}
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
+1
View File
@@ -1,5 +1,6 @@
{{/*
request/limit
使
{{ 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" $) }}
- existingSecret - Secret
- defaultNameSuffix - Secret
- context -
- existingSecret: Secret Secret
- defaultNameSuffix: Secret
- context:
*/}}
{{- define "common.secrets.name" -}}
{{- $name := (include "common.names.fullname" .context) -}}
@@ -32,8 +32,8 @@
{{ include "common.secrets.key" (dict "existingSecret" .Values.path.to.the.existingSecret "key" "keyName") }}
- existingSecret - Secret
- key -
- existingSecret: Secret Secret
- key:
*/}}
{{- define "common.secrets.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" $) }}
- secret - Secret
- key - Secret
- defaultValue - `values.yaml`"mysql.password"
- context -
- secret: Secret
- key: Secret
- defaultValue: `values.yaml`"mysql.password"
- context:
*/}}
{{- define "common.secrets.lookup" -}}
{{- $value := "" -}}
@@ -155,12 +155,12 @@ The order in which this function returns a secret password:
{{- end -}}
{{/*
secret定义true/false
Secret定义true/false
{{ include "common.secrets.exists" (dict "secret" "secret-name" "context" $) }}
- secret - Secret
- context -
- secret: Secret
- context:
*/}}
{{- define "common.secrets.exists" -}}
{{- $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" $) }}
*/}}
+3 -3
View File
@@ -1,5 +1,5 @@
{{/*
secret
Secret
{{ include "common.utils.secret.getvalue" (dict "secret" "secret-name" "field" "secret-value-field" "context" $) }}
*/}}
@@ -9,7 +9,7 @@ export {{ $varname }}=$(kubectl get secret --namespace {{ include "common.names.
{{- end -}}
{{/*
线ENV变量
线 ENV
{{ include "common.utils.fieldToEnvVar" dict "field" "my-password" }}
*/}}
@@ -61,7 +61,7 @@ export {{ $varname }}=$(kubectl get secret --namespace {{ include "common.names.
{{- end -}}
{{/*
`path` **ConfigMapSecret便*Pod*
`path` **ConfigMapSecret**便*Pod*
{{ 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 }}
*/}}
@@ -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.
{{- 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 -}}