_portal.tpl 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. {{- define "photoprism.portal" -}}
  2. {{- $proto := "http" -}}
  3. {{- if .Values.photoprismNetwork.certificateID -}}
  4. {{- $proto = "https" -}}
  5. {{- end -}}
  6. {{- $host := "$node_ip" -}}
  7. {{- with .Values.photoprismConfig.siteURL -}} {{/* Trim protocol and trailing slash */}}
  8. {{- $host = (. | trimPrefix "https://" | trimPrefix "http://" | trimSuffix "/") -}}
  9. {{- $host = mustRegexReplaceAll "(.*):[0-9]+" $host "${1}" -}}
  10. {{- end -}}
  11. {{- $port := .Values.photoprismNetwork.webPort }}
  12. {{- with .Values.photoprismConfig.siteURL -}} {{/* If URL is defined */}}
  13. {{- $p := (. | trimPrefix "https://" | trimPrefix "http://" | trimSuffix "/") -}}
  14. {{- $p = split ":" $p -}}
  15. {{- if $p._1 -}} {{/* If port is defined */}}
  16. {{- $port = $p._1 -}}
  17. {{- else -}}
  18. {{- $port = "80" -}}
  19. {{- if eq $proto "https" -}}
  20. {{- $port = "443" -}}
  21. {{- end -}}
  22. {{- end -}}
  23. {{- end }}
  24. ---
  25. apiVersion: v1
  26. kind: ConfigMap
  27. metadata:
  28. name: portal
  29. data:
  30. protocol: {{ $proto }}
  31. path: "/"
  32. host: {{ $host }}
  33. port: {{ $port | quote }}
  34. {{- end -}}