Skip to content

Commit 1bf2f2c

Browse files
committed
fix(module): base64 encoding for custom certificate Secret template (#1297)
* fix(module): base64 encoding for custom certificate Secret template --------- Signed-off-by: Ivan Mikheykin <[email protected]>
1 parent ef390d4 commit 1bf2f2c

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

templates/custom-certificate.yaml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1-
{{- include "helm_lib_module_https_copy_custom_certificate" (list . "d8-virtualization" "ingress-tls") -}}
1+
{{- /* Copy from helm-lib to work with custom certificate retrieved by the common hook in module-sdk. }} */ -}}
2+
{{- /* Values contain non-encoded certificates, we need to base64 them for the Secret data. }} */ -}}
3+
4+
{{- /* Usage: {{ include "helm_lib_module_https_copy_custom_certificate" (list . "namespace" "secret_name_prefix") }} */ -}}
5+
{{- /* Renders secret with [custom certificate](https://deckhouse.io/products/kubernetes-platform/documentation/v1/deckhouse-configure-global.html#parameters-modules-https-customcertificate) */ -}}
6+
{{- /* in passed namespace with passed prefix */ -}}
7+
{{- define "override_until_fixed::helm_lib_module_https_copy_custom_certificate" -}}
8+
{{- $context := index . 0 -}} {{- /* Template context with .Values, .Chart, etc */ -}}
9+
{{- $namespace := index . 1 -}} {{- /* Namespace */ -}}
10+
{{- $secret_name_prefix := index . 2 -}} {{- /* Secret name prefix */ -}}
11+
{{- $mode := include "helm_lib_module_https_mode" $context -}}
12+
{{- if eq $mode "CustomCertificate" -}}
13+
{{- $module_values := (index $context.Values (include "helm_lib_module_camelcase_name" $context)) -}}
14+
{{- $secret_name := include "helm_lib_module_https_secret_name" (list $context $secret_name_prefix) -}}
15+
---
16+
apiVersion: v1
17+
kind: Secret
18+
metadata:
19+
name: {{ $secret_name }}
20+
namespace: {{ $namespace }}
21+
{{- include "helm_lib_module_labels" (list $context) | nindent 2 }}
22+
type: kubernetes.io/tls
23+
data:
24+
{{- if (hasKey $module_values.internal.customCertificateData "ca.crt") }}
25+
ca.crt: {{ index $module_values.internal.customCertificateData "ca.crt" | b64enc }}
26+
{{- end }}
27+
tls.crt: {{ index $module_values.internal.customCertificateData "tls.crt" | b64enc }}
28+
tls.key: {{ index $module_values.internal.customCertificateData "tls.key" | b64enc }}
29+
{{- end -}}
30+
{{- end -}}
31+
32+
33+
34+
{{- include "override_until_fixed::helm_lib_module_https_copy_custom_certificate" (list . "d8-virtualization" "ingress-tls") -}}

0 commit comments

Comments
 (0)