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 -}}