_portal.tpl 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. {{- define "castopod.portal" -}}
  2. {{- $adminPath := "/cp-admin" -}}
  3. {{- if $.Release.IsInstall -}}
  4. {{- $adminPath = "/cp-install" -}}
  5. {{- end -}}
  6. {{- $host := "$node_ip" -}}
  7. {{- $port := "" -}}
  8. {{- $protocol := "http" -}}
  9. {{- if hasPrefix "https://" .Values.castopodConfig.baseUrl -}}
  10. {{- $protocol = "https" -}}
  11. {{- end -}}
  12. {{- with .Values.castopodConfig.baseUrl -}} {{/* Trim protocol and trailing slash */}}
  13. {{- $host = . | trimPrefix "https://" | trimPrefix "http://" | trimSuffix "/" -}}
  14. {{- if contains ":" $host -}}
  15. {{- $port = (split ":" $host)._1 -}}
  16. {{- $host = (split ":" $host)._0 -}}
  17. {{- end -}}
  18. {{- if not $port -}}
  19. {{- if eq $protocol "https" -}}
  20. {{- $port = "443" -}}
  21. {{- else -}}
  22. {{- $port = "80" -}}
  23. {{- end -}}
  24. {{- end -}}
  25. {{- end }}
  26. ---
  27. apiVersion: v1
  28. kind: ConfigMap
  29. metadata:
  30. name: portal
  31. data:
  32. path: /
  33. admin: {{ $adminPath }}
  34. port: {{ $port | quote }}
  35. protocol: {{ $protocol }}
  36. host: {{ $host }}
  37. {{- end -}}