_helpers.tpl 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. {{/* vim: set filetype=mustache: */}}
  2. {{/*
  3. Expand the name of the chart.
  4. */}}
  5. {{- define "nextcloud.name" -}}
  6. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
  7. {{- end -}}
  8. {{/*
  9. Create a default fully qualified app name.
  10. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  11. If release name contains chart name it will be used as a full name.
  12. */}}
  13. {{- define "nextcloud.fullname" -}}
  14. {{- if .Values.fullnameOverride -}}
  15. {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
  16. {{- else -}}
  17. {{- $name := default .Chart.Name .Values.nameOverride -}}
  18. {{- if contains $name .Release.Name -}}
  19. {{- .Release.Name | trunc 63 | trimSuffix "-" -}}
  20. {{- else -}}
  21. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
  22. {{- end -}}
  23. {{- end -}}
  24. {{- end -}}
  25. {{/*
  26. Create a default fully qualified app name.
  27. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  28. */}}
  29. {{- define "nextcloud.mariadb.fullname" -}}
  30. {{- printf "%s-%s" .Release.Name "mariadb" | trunc 63 | trimSuffix "-" -}}
  31. {{- end -}}
  32. {{/*
  33. Create a default fully qualified redis app name.
  34. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  35. */}}
  36. {{- define "nextcloud.redis.fullname" -}}
  37. {{- printf "%s-%s" .Release.Name "redis" | trunc 63 | trimSuffix "-" -}}
  38. {{- end -}}
  39. {{/*
  40. Create chart name and version as used by the chart label.
  41. */}}
  42. {{- define "nextcloud.chart" -}}
  43. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
  44. {{- end -}}
  45. {{/*
  46. Retrieve host path from ix volumes based on dataset name
  47. */}}
  48. {{- define "retrieveHostPathFromiXVolume" -}}
  49. {{- range $index, $hostPathConfiguration := $.ixVolumes }}
  50. {{- $dsName := base $hostPathConfiguration.hostPath -}}
  51. {{- if eq $.datasetName $dsName -}}
  52. {{- $hostPathConfiguration.hostPath -}}
  53. {{- end -}}
  54. {{- end -}}
  55. {{- end -}}
  56. {{/*
  57. Retrieve host path defined in volume
  58. */}}
  59. {{- define "configuredHostPath" -}}
  60. {{- if .Values.emptyDirVolumes -}}
  61. {{- printf "" -}}
  62. {{- else if .Values.nextcloudDataHostPathEnabled -}}
  63. {{- required "Please specify a host path for nextcloud" .Values.nextcloudHostPath -}}
  64. {{- else -}}
  65. {{- $volDict := dict "datasetName" $.Values.nextcloudDataVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
  66. {{- include "retrieveHostPathFromiXVolume" $volDict -}}
  67. {{- end -}}
  68. {{- end -}}
  69. {{/*
  70. Retrieve backup postgresql host path defined in volume
  71. */}}
  72. {{- define "configuredBackupPostgresHostPath" -}}
  73. {{- if .Values.emptyDirVolumes -}}
  74. {{- printf "" -}}
  75. {{- else -}}
  76. {{- $volDict := dict "datasetName" $.Values.postgresBackupVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
  77. {{- include "retrieveHostPathFromiXVolume" $volDict -}}
  78. {{- end -}}
  79. {{- end -}}
  80. {{/*
  81. Retrieve postgresql data host path defined in volume
  82. */}}
  83. {{- define "configuredPostgresHostPath" -}}
  84. {{- if .Values.emptyDirVolumes -}}
  85. {{- printf "" -}}
  86. {{- else -}}
  87. {{- $volDict := dict "datasetName" $.Values.postgresDataVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
  88. {{- include "retrieveHostPathFromiXVolume" $volDict -}}
  89. {{- end -}}
  90. {{- end -}}
  91. {{/*
  92. Selector labels
  93. */}}
  94. {{- define "nextcloud.selectorLabels" -}}
  95. app.kubernetes.io/name: {{ include "nextcloud.name" . }}
  96. app.kubernetes.io/instance: {{ .Release.Name }}
  97. {{- end }}
  98. {{/*
  99. Nextcloud service account
  100. */}}
  101. {{- define "nextcloud.serviceAccountName" -}}
  102. {{- printf "%s-service-account" .Release.Name -}}
  103. {{- end -}}