_nginx.tpl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {{/*
  2. Retrieve true/false if certificate is configured
  3. */}}
  4. {{- define "nginx.certAvailable" -}}
  5. {{- if .Values.certificate -}}
  6. {{- $values := (. | mustDeepCopy) -}}
  7. {{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate) -}}
  8. {{- template "common.resources.cert_present" $values -}}
  9. {{- else -}}
  10. {{- false -}}
  11. {{- end -}}
  12. {{- end -}}
  13. {{/*
  14. Retrieve public key of certificate
  15. */}}
  16. {{- define "nginx.cert.publicKey" -}}
  17. {{- $values := (. | mustDeepCopy) -}}
  18. {{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate "publicKey" true) -}}
  19. {{ include "common.resources.cert" $values }}
  20. {{- end -}}
  21. {{/*
  22. Retrieve private key of certificate
  23. */}}
  24. {{- define "nginx.cert.privateKey" -}}
  25. {{- $values := (. | mustDeepCopy) -}}
  26. {{- $_ := set $values "commonCertOptions" (dict "certKeyName" $values.Values.certificate) -}}
  27. {{ include "common.resources.cert" $values }}
  28. {{- end -}}
  29. {{/*
  30. Retrieve configured protocol scheme for nextcloud
  31. */}}
  32. {{- define "nginx.scheme" -}}
  33. {{- if eq (include "nginx.certAvailable" .) "true" -}}
  34. {{- print "https" -}}
  35. {{- else -}}
  36. {{- print "http" -}}
  37. {{- end -}}
  38. {{- end -}}
  39. {{/*
  40. Retrieve nginx certificate secret name
  41. */}}
  42. {{- define "nginx.secretName" -}}
  43. {{- print "nginx-secret" -}}
  44. {{- end -}}
  45. {{/*
  46. Formats volumeMount for tls keys and trusted certs
  47. */}}
  48. {{- define "nginx.tlsKeysVolumeMount" -}}
  49. {{- if eq (include "nginx.certAvailable" .) "true" -}}
  50. - name: cert-secret-volume
  51. mountPath: "/etc/nginx-certs"
  52. {{- end -}}
  53. {{- end -}}
  54. {{/*
  55. Formats volume for tls keys and trusted certs
  56. */}}
  57. {{- define "nginx.tlsKeysVolume" -}}
  58. {{- if eq (include "nginx.certAvailable" .) "true" -}}
  59. - name: cert-secret-volume
  60. secret:
  61. secretName: {{ include "nginx.secretName" . }}
  62. items:
  63. - key: certPublicKey
  64. path: public.crt
  65. - key: certPrivateKey
  66. path: private.key
  67. {{- end -}}
  68. {{- end -}}