Quellcode durchsuchen

Add library function to retrieve certificates

Waqar Ahmed vor 4 Jahren
Ursprung
Commit
eaad608b76
1 geänderte Dateien mit 25 neuen und 0 gelöschten Zeilen
  1. 25 0
      library/common/2101.0.0/templates/lib/resources/_certs.tpl

+ 25 - 0
library/common/2101.0.0/templates/lib/resources/_certs.tpl

@@ -0,0 +1,25 @@
+{{/*
+Retrieve true/false if certificate is available in ixCertificates
+*/}}
+{{- define "common.resources.cert_present" -}}
+{{- $values := . -}}
+{{- include "common.schema.validateKeys" (dict "values" . "checkKeys" (list "commonCertOptions")) -}}
+{{- hasKey $values.ixCertificates $values.commonCertOptions.certKeyName -}}
+{{- end -}}
+
+
+{{/*
+Retrieve certificate from variable name
+*/}}
+{{- define "common.resources.cert" -}}
+{{- $values := . -}}
+{{- include "common.schema.validateKeys" (dict "values" . "checkKeys" (list "commonCertOptions")) -}}
+{{- if hasKey $values.ixCertificates $values.commonCertOptions.certKeyName -}}
+{{- $cert := get $values.ixCertificates $values.commonCertOptions.certKeyName -}}
+{{- if $values.commonCertOptions.publicKey -}}
+{{ $cert.certificate }}
+{{- else -}}
+{{ $cert.privatekey }}
+{{- end -}}
+{{- end -}}
+{{- end -}}