_helpers.tpl 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. {{/*
  2. Create a default fully qualified app name.
  3. We truncate at 63 chars because some Kubernetes name fields are limited to
  4. this (by the DNS naming spec). If release name contains chart name it will
  5. be used as a full name.
  6. */}}
  7. {{- define "seaweedfs.fullname" -}}
  8. {{- if .Values.fullnameOverride -}}
  9. {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
  10. {{- else -}}
  11. {{- $name := default .Chart.Name .Values.nameOverride -}}
  12. {{- if contains $name .Release.Name -}}
  13. {{- .Release.Name | trunc 63 | trimSuffix "-" -}}
  14. {{- else -}}
  15. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
  16. {{- end -}}
  17. {{- end -}}
  18. {{- end -}}
  19. {{/*
  20. Create chart name and version as used by the chart label.
  21. */}}
  22. {{- define "seaweedfs.chart" -}}
  23. {{- printf "%s-helm" .Chart.Name | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
  24. {{- end -}}
  25. {{/*
  26. Expand the name of the chart.
  27. */}}
  28. {{- define "seaweedfs.name" -}}
  29. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
  30. {{- end -}}
  31. {{/*
  32. Inject extra environment vars in the format key:value, if populated
  33. */}}
  34. {{- define "seaweedfs.extraEnvironmentVars" -}}
  35. {{- if .extraEnvironmentVars -}}
  36. {{- range $key, $value := .extraEnvironmentVars }}
  37. - name: {{ $key }}
  38. value: {{ $value | quote }}
  39. {{- end -}}
  40. {{- end -}}
  41. {{- end -}}
  42. {{/* Return the proper filer image */}}
  43. {{- define "filer.image" -}}
  44. {{- if .Values.filer.imageOverride -}}
  45. {{- $imageOverride := .Values.filer.imageOverride -}}
  46. {{- printf "%s" $imageOverride -}}
  47. {{- else -}}
  48. {{- $registryName := default .Values.image.registry .Values.global.localRegistry | toString -}}
  49. {{- $repositoryName := .Values.image.repository | toString -}}
  50. {{- $name := .Values.global.imageName | toString -}}
  51. {{- $tag := .Chart.AppVersion | toString -}}
  52. {{- printf "%s%s%s:%s" $registryName $repositoryName $name $tag -}}
  53. {{- end -}}
  54. {{- end -}}
  55. {{/* Return the proper dbSchema image */}}
  56. {{- define "filer.dbSchema.image" -}}
  57. {{- if .Values.filer.dbSchema.imageOverride -}}
  58. {{- $imageOverride := .Values.filer.dbSchema.imageOverride -}}
  59. {{- printf "%s" $imageOverride -}}
  60. {{- else -}}
  61. {{- $registryName := default .Values.global.registry .Values.global.localRegistry | toString -}}
  62. {{- $repositoryName := .Values.global.repository | toString -}}
  63. {{- $name := .Values.filer.dbSchema.imageName | toString -}}
  64. {{- $tag := .Values.filer.dbSchema.imageTag | toString -}}
  65. {{- printf "%s%s%s:%s" $registryName $repositoryName $name $tag -}}
  66. {{- end -}}
  67. {{- end -}}
  68. {{/* Return the proper master image */}}
  69. {{- define "master.image" -}}
  70. {{- if .Values.master.imageOverride -}}
  71. {{- $imageOverride := .Values.master.imageOverride -}}
  72. {{- printf "%s" $imageOverride -}}
  73. {{- else -}}
  74. {{- $registryName := default .Values.image.registry .Values.global.localRegistry | toString -}}
  75. {{- $repositoryName := .Values.image.repository | toString -}}
  76. {{- $name := .Values.global.imageName | toString -}}
  77. {{- $tag := .Chart.AppVersion | toString -}}
  78. {{- printf "%s%s%s:%s" $registryName $repositoryName $name $tag -}}
  79. {{- end -}}
  80. {{- end -}}
  81. {{/* Return the proper s3 image */}}
  82. {{- define "s3.image" -}}
  83. {{- if .Values.s3.imageOverride -}}
  84. {{- $imageOverride := .Values.s3.imageOverride -}}
  85. {{- printf "%s" $imageOverride -}}
  86. {{- else -}}
  87. {{- $registryName := default .Values.image.registry .Values.global.localRegistry | toString -}}
  88. {{- $repositoryName := .Values.image.repository | toString -}}
  89. {{- $name := .Values.global.imageName | toString -}}
  90. {{- $tag := .Chart.AppVersion | toString -}}
  91. {{- printf "%s%s%s:%s" $registryName $repositoryName $name $tag -}}
  92. {{- end -}}
  93. {{- end -}}
  94. {{/* Return the proper volume image */}}
  95. {{- define "volume.image" -}}
  96. {{- if .Values.volume.imageOverride -}}
  97. {{- $imageOverride := .Values.volume.imageOverride -}}
  98. {{- printf "%s" $imageOverride -}}
  99. {{- else -}}
  100. {{- $registryName := default .Values.image.registry .Values.global.localRegistry | toString -}}
  101. {{- $repositoryName := .Values.image.repository | toString -}}
  102. {{- $name := .Values.global.imageName | toString -}}
  103. {{- $tag := .Chart.AppVersion | toString -}}
  104. {{- printf "%s%s%s:%s" $registryName $repositoryName $name $tag -}}
  105. {{- end -}}
  106. {{- end -}}
  107. {{/* check if any Volume PVC exists */}}
  108. {{- define "volume.pvc_exists" -}}
  109. {{- if or (or (eq .Values.volume.data.type "persistentVolumeClaim") (and (eq .Values.volume.idx.type "persistentVolumeClaim") .Values.volume.dir_idx )) (eq .Values.volume.logs.type "persistentVolumeClaim") -}}
  110. {{- printf "true" -}}
  111. {{- else -}}
  112. {{- printf "false" -}}
  113. {{- end -}}
  114. {{- end -}}
  115. {{/* check if any Volume HostPath exists */}}
  116. {{- define "volume.hostpath_exists" -}}
  117. {{- if or (or (eq .Values.volume.data.type "hostPath") (and (eq .Values.volume.idx.type "hostPath") .Values.volume.dir_idx )) (eq .Values.volume.logs.type "hostPath") -}}
  118. {{- printf "true" -}}
  119. {{- else -}}
  120. {{- if or .Values.global.enableSecurity .Values.volume.extraVolumes -}}
  121. {{- printf "true" -}}
  122. {{- else -}}
  123. {{- printf "false" -}}
  124. {{- end -}}
  125. {{- end -}}
  126. {{- end -}}
  127. {{/* check if any Filer PVC exists */}}
  128. {{- define "filer.pvc_exists" -}}
  129. {{- if or (eq .Values.filer.data.type "persistentVolumeClaim") (eq .Values.filer.logs.type "persistentVolumeClaim") -}}
  130. {{- printf "true" -}}
  131. {{- else -}}
  132. {{- printf "false" -}}
  133. {{- end -}}
  134. {{- end -}}
  135. {{/* check if any Filer HostPath exists */}}
  136. {{- define "filer.hostpath_exists" -}}
  137. {{- if or (eq .Values.filer.data.type "hostPath") (eq .Values.filer.logs.type "hostPath") -}}
  138. {{- printf "true" -}}
  139. {{- else -}}
  140. {{- printf "false" -}}
  141. {{- end -}}
  142. {{- end -}}
  143. {{/* check if any Master PVC exists */}}
  144. {{- define "master.pvc_exists" -}}
  145. {{- if or (eq .Values.master.data.type "persistentVolumeClaim") (eq .Values.master.logs.type "persistentVolumeClaim") -}}
  146. {{- printf "true" -}}
  147. {{- else -}}
  148. {{- printf "false" -}}
  149. {{- end -}}
  150. {{- end -}}
  151. {{/* check if any Master HostPath exists */}}
  152. {{- define "master.hostpath_exists" -}}
  153. {{- if or (eq .Values.master.data.type "hostPath") (eq .Values.master.logs.type "hostPath") -}}
  154. {{- printf "true" -}}
  155. {{- else -}}
  156. {{- if or .Values.global.enableSecurity .Values.volume.extraVolumes -}}
  157. {{- printf "true" -}}
  158. {{- else -}}
  159. {{- printf "false" -}}
  160. {{- end -}}
  161. {{- end -}}
  162. {{- end -}}
  163. {{/* check if any InitContainers exist for Volumes */}}
  164. {{- define "volume.initContainers_exists" -}}
  165. {{- if or (not (empty .Values.volume.dir_idx )) (not (empty .Values.volume.initContainers )) -}}
  166. {{- printf "true" -}}
  167. {{- else -}}
  168. {{- printf "false" -}}
  169. {{- end -}}
  170. {{- end -}}