From eaad608b764d638aad40da4beb170e6a4d74c207 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Sat, 6 Feb 2021 23:09:03 +0500 Subject: [PATCH] Add library function to retrieve certificates --- .../templates/lib/resources/_certs.tpl | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 library/common/2101.0.0/templates/lib/resources/_certs.tpl diff --git a/library/common/2101.0.0/templates/lib/resources/_certs.tpl b/library/common/2101.0.0/templates/lib/resources/_certs.tpl new file mode 100644 index 0000000000..740920d6f9 --- /dev/null +++ b/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 -}}