This commit is contained in:
Andrei Kvapil
2024-02-02 18:29:27 +01:00
parent d0a2643785
commit 241cf2aa4c

View File

@@ -7,18 +7,18 @@ metadata:
{{- if hasPrefix "tenant-" .Release.Namespace }}
{{- $existingNS := lookup "v1" "Namespace" "" .Release.Namespace }}
{{- if $existingNS }}
labels:
annotations:
{{- if .Values.host }}
namespace.cozystack.io/host: "{{ .Values.host }}"
{{- else }}
{{ $parentHost := index $existingNS.metadata.labels "namespace.cozystack.io/host" | required (printf "namespace %s has no namespace.cozystack.io/host label" $.Release.Namespace) }}
namespace.cozystack.io/host: "{{ trimPrefix "tenant-" (include "tenant.name" .) }}.{{ $parentHost }}"
{{ $parentHost := index $existingNS.metadata.annotations "namespace.cozystack.io/host" | required (printf "namespace %s has no namespace.cozystack.io/host annotation" $.Release.Namespace) }}
namespace.cozystack.io/host: "{{ splitList "-" (include "tenant.name" .) | last }}.{{ $parentHost }}"
{{- end }}
{{- range $x := list "etcd" "monitoring" "ingress" }}
{{- if (index $.Values $x) }}
namespace.cozystack.io/{{ $x }}: "{{ include "tenant.name" $ }}"
{{- else }}
namespace.cozystack.io/{{ $x }}: "{{ index $existingNS.metadata.labels (printf "namespace.cozystack.io/%s" $x) | required (printf "namespace %s has no namespace.cozystack.io/%s label" $.Release.Namespace $x) }}"
namespace.cozystack.io/{{ $x }}: "{{ index $existingNS.metadata.annotations (printf "namespace.cozystack.io/%s" $x) | required (printf "namespace %s has no namespace.cozystack.io/%s annotation" $.Release.Namespace $x) }}"
{{- end }}
{{- end }}
ownerReferences: