_helpers.tpl 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 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 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 -}}