{{- if .Values.qaFixtures.enabled }}
{{- /*
  Environment CR for the qa-omantel test fixtures (qa-loop iter-7
  Cluster-C, Fix #36 / #1227). Required by the application-controller
  before the qa-wp Application reconciles. Single-region (fsn1) per
  the matrix's primary-region default; the topology-preview /
  upgrade-preview tests exercise mode transitions but the live
  install starts single-region.

  Name MUST match Application.spec.environmentRef on the qa-wp
  fixture below. Convention: `<organization>-<envType>` is the
  catalyst-wide naming pattern, but the matrix asserts the literal
  namespace `qa-omantel`, so we use the namespace name directly to
  keep wire-shape symmetry between the fixture and the matrix
  assertions.
*/ -}}
apiVersion: catalyst.openova.io/v1
kind: Environment
metadata:
  name: {{ .Values.qaFixtures.namespace | default "qa-omantel" | quote }}
  labels:
    openova.io/sovereign: {{ .Values.qaFixtures.sovereignRef | default "omantel.biz" | quote }}
    openova.io/organization: {{ .Values.qaFixtures.organization | default "omantel-platform" | quote }}
    catalyst.openova.io/managed-by: qa-fixtures
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/instance: {{ .Release.Name }}
spec:
  organizationRef: {{ .Values.qaFixtures.organization | default "omantel-platform" | quote }}
  envType: dev
  placement: single-region
  regions:
    # Environment CRD requires the region OBJECT shape:
    #   provider:      arbitrary slug ("hetzner", "aws", "azure")
    #   region:        ^[a-z]{3}[a-z0-9]?$  (3-4 char region code, e.g. "fsn", "hel")
    #   buildingBlock: arbitrary slug ("rtz")
    #
    # The qaFixtures.primaryRegion value carries the FULL canonical
    # 4-segment region label (e.g. "hz-fsn-rtz-prod"); we split it
    # into the CRD-required subfields here. Defaults below mirror
    # the canonical hz-fsn-rtz-prod default so a vanilla install
    # renders valid spec.regions[0] without per-Sovereign overrides.
    - provider: {{ .Values.qaFixtures.envRegionProvider | default "hetzner" | quote }}
      region: {{ .Values.qaFixtures.envRegionCode | default "fsn" | quote }}
      buildingBlock: {{ .Values.qaFixtures.envRegionBuildingBlock | default "rtz" | quote }}
{{- end }}
