{{- if and .Release.IsInstall .Values.createNamespace }}
{{- $apiVersions := (include "k8s.apiVersions" .) | fromJson }}
{{- $svcName := (include "k8s.serviceName" .) }}
{{- if and (.Values.hostnameIncludeStack) (.Values.app.stack) }}
{{- $svcName = (include "service.stackServiceName" .) }}
{{- end }}
---
apiVersion: {{ get $apiVersions "Namespace" }}
kind: Namespace
metadata:
  name: {{ .Values.namespaceOverride | default (cat .Values.cluster.environment "-" $svcName | nospace) }}
  labels:
    pluto.tv/team: {{ .Values.app.team | required "Service Labels app.team required!" }}
  {{- if (eq (include "istio.enabled" .) "true") }}
    istio-injection: enabled
  {{- end }}
  annotations:
    helm.sh/hook: "pre-install, pre-upgrade"
    helm.sh/hook-weight: "-10"
{{- end }}
