_helpers.tpl 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. ################################################################################
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. ################################################################################
  18. {{/*
  19. Expand the name of the chart.
  20. */}}
  21. {{- define "flink-operator.name" -}}
  22. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
  23. {{- end }}
  24. {{/*
  25. Create a default fully qualified app name.
  26. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  27. If release name contains chart name it will be used as a full name.
  28. */}}
  29. {{- define "flink-operator.fullname" -}}
  30. {{- if .Values.fullnameOverride }}
  31. {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
  32. {{- else }}
  33. {{- $name := default .Chart.Name .Values.nameOverride }}
  34. {{- if contains $name .Release.Name }}
  35. {{- .Release.Name | trunc 63 | trimSuffix "-" }}
  36. {{- else }}
  37. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
  38. {{- end }}
  39. {{- end }}
  40. {{- end }}
  41. {{/*
  42. Create chart name and version as used by the chart label.
  43. */}}
  44. {{- define "flink-operator.chart" -}}
  45. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
  46. {{- end }}
  47. {{/*
  48. Common labels
  49. */}}
  50. {{- define "flink-operator.labels" -}}
  51. {{ include "flink-operator.selectorLabels" . }}
  52. {{- if .Chart.AppVersion }}
  53. app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
  54. {{- end }}
  55. app.kubernetes.io/managed-by: {{ .Release.Service }}
  56. helm.sh/chart: {{ include "flink-operator.chart" . }}
  57. {{- end }}
  58. {{/*
  59. Selector labels
  60. */}}
  61. {{- define "flink-operator.selectorLabels" -}}
  62. app.kubernetes.io/name: {{ include "flink-operator.name" . }}
  63. {{- end }}
  64. {{/*
  65. Create the path of the operator image to use
  66. */}}
  67. {{- define "flink-operator.imagePath" -}}
  68. {{- if .Values.image.digest }}
  69. {{- .Values.image.repository }}@{{ .Values.image.digest }}
  70. {{- else }}
  71. {{- .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}
  72. {{- end }}
  73. {{- end }}
  74. {{/*
  75. Create the name of the operator role to use
  76. */}}
  77. {{- define "flink-operator.roleName" -}}
  78. {{- if .Values.rbac.operatorRole.create }}
  79. {{- default (include "flink-operator.fullname" .) .Values.rbac.operatorRole.name }}
  80. {{- else }}
  81. {{- default "default" .Values.rbac.operatorRole.name }}
  82. {{- end }}
  83. {{- end }}
  84. {{/*
  85. Create the name of the operator role binding to use
  86. */}}
  87. {{- define "flink-operator.roleBindingName" -}}
  88. {{- if .Values.rbac.operatorRoleBinding.create }}
  89. {{- default (include "flink-operator.fullname" .) .Values.rbac.operatorRoleBinding.name }}
  90. {{- else }}
  91. {{- default "default" .Values.rbac.operatorRoleBinding.name }}
  92. {{- end }}
  93. {{- end }}
  94. {{/*
  95. Create the name of the job role to use
  96. */}}
  97. {{- define "flink-operator.jobRoleName" -}}
  98. {{- if .Values.rbac.jobRoleBinding.create }}
  99. {{- default (include "flink-operator.fullname" .) .Values.rbac.jobRole.name }}
  100. {{- else }}
  101. {{- default "default" .Values.rbac.jobRole.name }}
  102. {{- end }}
  103. {{- end }}
  104. {{/*
  105. Create the name of the job role to use
  106. */}}
  107. {{- define "flink-operator.jobRoleBindingName" -}}
  108. {{- if .Values.rbac.jobRole.create }}
  109. {{- default (include "flink-operator.fullname" .) .Values.rbac.jobRoleBinding.name }}
  110. {{- else }}
  111. {{- default "default" .Values.rbac.jobRoleBinding.name }}
  112. {{- end }}
  113. {{- end }}
  114. {{/*
  115. Create the name of the operator service account to use
  116. */}}
  117. {{- define "flink-operator.serviceAccountName" -}}
  118. {{- if .Values.operatorServiceAccount.create }}
  119. {{- default (include "flink-operator.fullname" .) .Values.operatorServiceAccount.name }}
  120. {{- else }}
  121. {{- default "default" .Values.operatorServiceAccount.name }}
  122. {{- end }}
  123. {{- end }}
  124. {{/*
  125. Create the name of the job service account to use
  126. */}}
  127. {{- define "flink-operator.jobServiceAccountName" -}}
  128. {{- if .Values.jobServiceAccount.create }}
  129. {{- default (include "flink-operator.fullname" .) .Values.jobServiceAccount.name }}
  130. {{- else }}
  131. {{- default "default" .Values.jobServiceAccount.name }}
  132. {{- end }}
  133. {{- end }}
  134. {{/*
  135. Determine role scope based on name
  136. */}}
  137. {{- define "flink-operator.roleScope" -}}
  138. {{- if contains ":" .role }}
  139. {{- printf "ClusterRole" }}
  140. {{- else }}
  141. {{- printf "Role" }}
  142. {{- end }}
  143. {{- end }}
  144. {{- define "flink-operator.validating-webhook-enabled" -}}
  145. {{- if hasKey .Values.webhook "validator" }}
  146. {{- if .Values.webhook.validator.create }}
  147. {{- printf "true" }}
  148. {{- else }}
  149. {{- printf "false" }}
  150. {{- end }}
  151. {{- else }}
  152. {{- if or (.Values.webhook.create) }}
  153. {{- printf "true" }}
  154. {{- else }}
  155. {{- printf "false" }}
  156. {{- end }}
  157. {{- end }}
  158. {{- end }}
  159. {{- define "flink-operator.mutating-webhook-enabled" -}}
  160. {{- if hasKey .Values.webhook "mutator" }}
  161. {{- if .Values.webhook.mutator.create }}
  162. {{- printf "true" }}
  163. {{- else }}
  164. {{- printf "false" }}
  165. {{- end }}
  166. {{- else }}
  167. {{- if or (.Values.webhook.create) }}
  168. {{- printf "true" }}
  169. {{- else }}
  170. {{- printf "false" }}
  171. {{- end }}
  172. {{- end }}
  173. {{- end }}
  174. {{- define "flink-operator.webhook-enabled" -}}
  175. {{- if or (eq (include "flink-operator.validating-webhook-enabled" .) "true") (eq (include "flink-operator.mutating-webhook-enabled" .) "true") }}
  176. {{- printf "true" }}
  177. {{- else }}
  178. {{- printf "false" }}
  179. {{- end }}
  180. {{- end }}