From 2228f4a49e54481119ac3bdaa1917a5308027149 Mon Sep 17 00:00:00 2001 From: Chi-En Wu Date: Mon, 20 Apr 2020 11:12:29 +0800 Subject: [PATCH] feat: add template `common.serviceMonitor.secret` --- templates/_servicemonitor-secret.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 templates/_servicemonitor-secret.yaml diff --git a/templates/_servicemonitor-secret.yaml b/templates/_servicemonitor-secret.yaml new file mode 100644 index 0000000..ec6283e --- /dev/null +++ b/templates/_servicemonitor-secret.yaml @@ -0,0 +1,27 @@ +{{/* vim: set filetype=mustache: */}} + +{{- define "common.serviceMonitor.secret.tpl" -}} +{{- $basicAuth := .Values.serviceMonitor.basicAuth | default (dict) -}} +metadata: + name: {{ $basicAuth.secretName | default (include "common.fullname" .) }} + {{- with .Values.serviceMonitor.namespace }} + namespace: {{ . }} + {{- end }} +{{- if $basicAuth.enabled }} +data: + {{ $basicAuth.usernameKey | default "username" }}: {{ $basicAuth.username | toString | b64enc | quote }} + {{ $basicAuth.passwordKey | default "password" }}: {{ $basicAuth.password | toString | b64enc | quote }} +{{- end }} +{{- end -}} + +{{- define "common.serviceMonitor.secret.if" -}} +{{- $top := first . -}} +{{- $serviceMonitor := $top.Values.serviceMonitor | default (dict) -}} +{{- if $serviceMonitor.enabled -}} + {{- include "common.secret" (append . "common.serviceMonitor.secret.tpl") -}} +{{- end -}} +{{- end -}} + +{{- define "common.serviceMonitor.secret" -}} +{{- include "common.utils.flattenCall" (list "common.serviceMonitor.secret.if" .) -}} +{{- end -}}