_helpers.tpl 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. {{- /*
  2. Copyright Materialize, Inc. and contributors. All rights reserved.
  3. Use of this software is governed by the Business Source License
  4. included in the LICENSE file at the root of this repository.
  5. As of the Change Date specified in that file, in accordance with
  6. the Business Source License, use of this software will be governed
  7. by the Apache License, Version 2.0.
  8. */ -}}
  9. {{/*
  10. Expand the name of the chart.
  11. */}}
  12. {{- define "materialize-operator.name" -}}
  13. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
  14. {{- end }}
  15. {{/*
  16. Create a default fully qualified app name.
  17. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  18. If release name contains chart name it will be used as a full name.
  19. */}}
  20. {{- define "materialize-operator.fullname" -}}
  21. {{- if .Values.fullnameOverride }}
  22. {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
  23. {{- else }}
  24. {{- $name := default .Chart.Name .Values.nameOverride }}
  25. {{- if contains $name .Release.Name }}
  26. {{- .Release.Name | trunc 63 | trimSuffix "-" }}
  27. {{- else }}
  28. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
  29. {{- end }}
  30. {{- end }}
  31. {{- end }}
  32. {{/*
  33. Create chart name and version as used by the chart label.
  34. */}}
  35. {{- define "materialize-operator.chart" -}}
  36. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
  37. {{- end }}
  38. {{/*
  39. Common labels
  40. */}}
  41. {{- define "materialize-operator.labels" -}}
  42. helm.sh/chart: {{ include "materialize-operator.chart" . }}
  43. {{ include "materialize-operator.selectorLabels" . }}
  44. {{- if .Chart.AppVersion }}
  45. app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
  46. {{- end }}
  47. app.kubernetes.io/managed-by: {{ .Release.Service }}
  48. {{- end }}
  49. {{/*
  50. Selector labels
  51. */}}
  52. {{- define "materialize-operator.selectorLabels" -}}
  53. app.kubernetes.io/name: {{ include "materialize-operator.name" . }}
  54. app.kubernetes.io/instance: {{ .Release.Name }}
  55. {{- end }}
  56. {{/*
  57. Create the name of the service account to use
  58. */}}
  59. {{- define "materialize-operator.serviceAccountName" -}}
  60. {{- if .Values.serviceAccount.create }}
  61. {{- default (include "materialize-operator.fullname" .) .Values.serviceAccount.name }}
  62. {{- else }}
  63. {{- default "default" .Values.serviceAccount.name }}
  64. {{- end }}
  65. {{- end }}
  66. {{/*
  67. Create the name of the cluster role to use
  68. */}}
  69. {{- define "materialize-operator.clusterRoleName" -}}
  70. {{- if .Values.rbac.clusterRole.create }}
  71. {{- default (include "materialize-operator.fullname" .) .Values.rbac.clusterRole.name }}
  72. {{- else }}
  73. {{- default "default" .Values.rbac.clusterRole.name }}
  74. {{- end }}
  75. {{- end }}
  76. {{/*
  77. Create the name of the cluster role binding to use
  78. */}}
  79. {{- define "materialize-operator.clusterRoleBindingName" -}}
  80. {{- if .Values.rbac.clusterRoleBinding.create }}
  81. {{- default (include "materialize-operator.fullname" .) .Values.rbac.clusterRoleBinding.name }}
  82. {{- else }}
  83. {{- default "default" .Values.rbac.clusterRoleBinding.name }}
  84. {{- end }}
  85. {{- end }}
  86. {{/*
  87. Create the Metadata database connection string
  88. */}}
  89. {{- define "materialize-operator.metadatadbConnectionString" -}}
  90. postgresql://{{ .Values.metadatadb.username }}:{{ .Values.metadatadb.password }}@{{ .Values.metadatadb.endpoint }}:{{ .Values.metadatadb.port }}/defaultdb?sslmode=verify-full&sslrootcert=/metadata/metadata-certs/ca.crt
  91. {{- end }}
  92. {{/*
  93. Helper template to process cluster sizes based on storage class configuration
  94. */}}
  95. {{- define "materialize.processClusterSizes" -}}
  96. {{- $result := dict }}
  97. {{- range $size, $config := .Values.operator.clusters.sizes }}
  98. {{- $newConfig := deepCopy $config }}
  99. {{- if not $.Values.storage.storageClass.name }}
  100. {{- $_ := set $newConfig "disk_limit" "0" }}
  101. {{- end }}
  102. {{- $_ := set $newConfig "is_cc" true }}
  103. {{- $_ := set $result $size $newConfig }}
  104. {{- end }}
  105. {{- $result | toYaml }}
  106. {{- end }}