_helpers.tpl 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. {{- define "kubectl-image" }}
  2. {{- if semverCompare ">=1.30" .Capabilities.KubeVersion.Version -}}
  3. {{- printf "%s/ongres/kubectl:v1.30.1-build-6.33" .Values.containerRegistry -}}
  4. {{- else if semverCompare ">=1.27" .Capabilities.KubeVersion.Version -}}
  5. {{- printf "%s/ongres/kubectl:v1.28.10-build-6.33" .Values.containerRegistry -}}
  6. {{- else if semverCompare ">=1.24" .Capabilities.KubeVersion.Version -}}
  7. {{- printf "%s/ongres/kubectl:v1.25.16-build-6.33" .Values.containerRegistry -}}
  8. {{- else if semverCompare ">=1.21" .Capabilities.KubeVersion.Version -}}
  9. {{- printf "%s/ongres/kubectl:v1.22.17-build-6.33" .Values.containerRegistry -}}
  10. {{- else if semverCompare ">=1.18" .Capabilities.KubeVersion.Version -}}
  11. {{- printf "%s/ongres/kubectl:v1.19.16-build-6.33" .Values.containerRegistry -}}
  12. {{- else -}}
  13. {{- printf "%s/ongres/kubectl:v1.30.1-build-6.33" .Values.containerRegistry -}}
  14. {{- end -}}
  15. {{- end -}}
  16. {{- define "operator-image" }}
  17. {{- if not (regexMatch "^[^/]+\\.[^/]+/.*$" .Values.operator.image.name) }}{{ .Values.containerRegistry }}/{{ end }}{{ .Values.operator.image.name }}:{{ .Values.operator.image.tag }}
  18. {{- end }}
  19. {{- define "restapi-image" }}
  20. {{- if not (regexMatch "^[^/]+\\.[^/]+/.*$" .Values.restapi.image.name ) }}{{ .Values.containerRegistry }}/{{ end }}{{ .Values.restapi.image.name }}:{{ .Values.restapi.image.tag }}
  21. {{- end }}
  22. {{- define "adminui-image" }}
  23. {{- if not (regexMatch "^[^/]+\\.[^/]+/.*$" .Values.adminui.image.name ) }}{{ .Values.containerRegistry }}/{{ end }}{{ .Values.adminui.image.name }}:{{ .Values.adminui.image.tag }}
  24. {{- end }}
  25. {{- define "jobs-image" }}
  26. {{- if not (regexMatch "^[^/]+\\.[^/]+/.*$" .Values.jobs.image.name ) }}{{ .Values.containerRegistry }}/{{ end }}{{ .Values.jobs.image.name }}:{{ .Values.jobs.image.tag }}
  27. {{- end }}
  28. {{- define "cert-name" }}
  29. {{- .Values.cert.secretName | default (printf "%s-%s" .Release.Name "certs") }}
  30. {{- end }}
  31. {{- define "web-cert-name" }}
  32. {{- .Values.cert.webSecretName | default (printf "%s-%s" .Release.Name "web-certs") }}
  33. {{- end }}
  34. {{- define "unmodificableWebapiAdminClusterRoleBinding" }}
  35. {{- if .Release.IsUpgrade }}
  36. {{- $unmodificableWebapiAdminClusterRoleBinding := false }}
  37. {{- $webapiAdminClusterRoleBinding := lookup "rbac.authorization.k8s.io/v1" "ClusterRoleBinding" "" "stackgres-restapi-admin" }}
  38. {{- if $webapiAdminClusterRoleBinding }}
  39. {{- if not (eq $webapiAdminClusterRoleBinding.roleRef.name "stackgres-restapi-admin") }}
  40. {{- $unmodificableWebapiAdminClusterRoleBinding = true }}
  41. {{- end }}
  42. {{- end }}
  43. {{- if $unmodificableWebapiAdminClusterRoleBinding }}true{{- else }}false{{- end }}
  44. {{- else }}
  45. false
  46. {{- end }}
  47. {{- end }}
  48. {{- define "allowedNamespaces" }}
  49. {{- $allowedNamespaces := list }}
  50. {{- if .Values.allowedNamespaces }}
  51. {{- range $namespace := .Values.allowedNamespaces }}
  52. {{- $allowedNamespaces = append $allowedNamespaces $namespace }}
  53. {{- end }}
  54. {{- if not ($allowedNamespaces | has .Release.Namespace) }}
  55. {{- $allowedNamespaces = append $allowedNamespaces .Release.Namespace }}
  56. {{- end }}
  57. {{- else if .Values.allowedNamespaceLabelSelector }}
  58. {{- $namespaces := lookup "v1" "Namespace" "" "" }}
  59. {{- range $namespace := $namespaces }}
  60. {{- $containsAllowedNamespaceLabelSelector := true }}
  61. {{- range $k,$v := $.Values.allowedNamespaceLabelSelector }}
  62. {{- $containsLabel := false }}
  63. {{- range $nk,$nv := $namespace.metadata.labels }}
  64. {{- if and (eq $nk $k) (eq $nv $v) }}
  65. {{- $containsLabel = true }}
  66. {{- end }}
  67. {{- end }}
  68. {{- if not $containsLabel }}
  69. {{- $containsAllowedNamespaceLabelSelector = false }}
  70. {{- end }}
  71. {{- end }}
  72. {{- if $containsAllowedNamespaceLabelSelector }}
  73. {{- $allowedNamespaces = append $allowedNamespaces $namespace.metadata.name }}
  74. {{- end }}
  75. {{- end }}
  76. {{- else if .Values.disableClusterRole }}
  77. {{- $allowedNamespaces = append $allowedNamespaces .Release.Namespace }}
  78. {{- else }}
  79. {{- $allowedNamespaces = append $allowedNamespaces "_all_namespaces_placeholder" }}
  80. {{- end }}
  81. {{- range $index,$namespace := $allowedNamespaces }}{{ if $index }} {{ end }}{{ $namespace }}{{ end }}
  82. {{- end }}