Files
cloud-host/backend/helm/cloudhost-platform/templates/_helpers.tpl
T
keyhan d3bbc0c0a0
Build and Deploy Platform / build-and-deploy (push) Successful in 14m57s
fix(build): default Kaniko and init images to Harbor via Helm values
User-app builds no longer pull gcr.io/docker.io directly when build.images
is configured in values.yaml, fixing ImagePullBackOff on clusters without
upstream registry access.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-03 14:20:36 +03:30

127 lines
4.4 KiB
Smarty

{{- define "cloudhost-platform.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "cloudhost-platform.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- define "cloudhost-platform.namespace" -}}
{{- .Values.namespace | default "cloudhost" }}
{{- end }}
{{- define "cloudhost-platform.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" }}
{{- end }}
{{- define "cloudhost-platform.labels" -}}
helm.sh/chart: {{ include "cloudhost-platform.chart" . }}
{{ include "cloudhost-platform.selectorLabels" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{- define "cloudhost-platform.selectorLabels" -}}
app.kubernetes.io/name: {{ include "cloudhost-platform.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- define "cloudhost-platform.postgres.fullname" -}}
{{- printf "%s-postgres" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- define "cloudhost-platform.redis.fullname" -}}
{{- printf "%s-redis" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- define "cloudhost-platform.backend.fullname" -}}
{{- printf "%s-backend" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- define "cloudhost-platform.frontend.fullname" -}}
{{- printf "%s-frontend" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- define "cloudhost-platform.secretName" -}}
{{- if .Values.secrets.existingSecret }}
{{- .Values.secrets.existingSecret }}
{{- else }}
{{- printf "%s-secrets" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- end }}
{{- define "cloudhost-platform.tlsSecretName" -}}
{{- if .Values.ingress.tls.secretName }}
{{- .Values.ingress.tls.secretName }}
{{- else }}
{{- printf "%s-platform-tls" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- end }}
{{- define "cloudhost-platform.urlScheme" -}}
{{- if and .Values.ingress.enabled .Values.ingress.tls.enabled }}https{{- else }}http{{- end }}
{{- end }}
{{- define "cloudhost-platform.frontendPublicUrl" -}}
{{- $scheme := include "cloudhost-platform.urlScheme" . -}}
{{- if .Values.ingress.enabled }}
{{- if .Values.ingress.singleHost.enabled }}
{{- printf "%s://%s" $scheme .Values.ingress.singleHost.host }}
{{- else }}
{{- printf "%s://%s" $scheme .Values.ingress.frontend.host }}
{{- end }}
{{- else }}
{{- printf "http://%s-frontend.%s.svc.cluster.local:3000" (include "cloudhost-platform.fullname" .) (include "cloudhost-platform.namespace" .) }}
{{- end }}
{{- end }}
{{- /*
Comma-separated CORS origins for the backend's FRONTEND_URL.
The frontend (landing) URL MUST stay first: configuration.ts derives
PLATFORM_DOMAIN / preview domain from the first entry only. The panel host
(when configured) is appended as an additional allowed origin.
*/ -}}
{{- define "cloudhost-platform.corsOrigins" -}}
{{- $scheme := include "cloudhost-platform.urlScheme" . -}}
{{- $origins := list (include "cloudhost-platform.frontendPublicUrl" .) -}}
{{- if and .Values.ingress.enabled .Values.ingress.panel.host -}}
{{- $origins = append $origins (printf "%s://%s" $scheme .Values.ingress.panel.host) -}}
{{- end -}}
{{- join "," $origins -}}
{{- end }}
{{- define "cloudhost-platform.apiPublicUrl" -}}
{{- $scheme := include "cloudhost-platform.urlScheme" . -}}
{{- if .Values.ingress.enabled }}
{{- if .Values.ingress.singleHost.enabled }}
{{- printf "%s://%s%s" $scheme .Values.ingress.singleHost.host .Values.ingress.singleHost.apiPath }}
{{- else }}
{{- printf "%s://%s" $scheme .Values.ingress.api.host }}
{{- end }}
{{- else }}
{{- printf "http://%s-backend.%s.svc.cluster.local:4000" (include "cloudhost-platform.fullname" .) (include "cloudhost-platform.namespace" .) }}
{{- end }}
{{- end }}
{{- define "cloudhost-platform.backendImage" -}}
{{- printf "%s:%s" .Values.images.backend.repository .Values.images.backend.tag }}
{{- end }}
{{- define "cloudhost-platform.frontendImage" -}}
{{- printf "%s:%s" .Values.images.frontend.repository .Values.images.frontend.tag }}
{{- end }}
{{- define "cloudhost-platform.buildEnv" -}}
- name: KANIKO_IMAGE
value: {{ .Values.build.images.kaniko | quote }}
- name: BUILD_ALPINE_IMAGE
value: {{ .Values.build.images.alpine | quote }}
- name: BUILD_ALPINE_GIT_IMAGE
value: {{ .Values.build.images.alpineGit | quote }}
- name: BASE_IMAGE_REGISTRY
value: {{ .Values.build.baseImageRegistry | quote }}
{{- end }}