apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: resourcehierarchies.cft.dev
spec:
  group: cft.dev
  scope: Namespaced
  names:
    plural: resourcehierarchies
    singular: resourcehierarchy
    kind: ResourceHierarchy
  preserveUnknownFields: false
  versions:
  - name: v1alpha1
    served: true
    storage: false
    deprecated: true
    schema:
      openAPIV3Schema:
        type: object
        required:
        - spec
        properties:
          spec:
            # ResourceHierarchySpec
            type: object
            properties:
              layers:
                type: array
                items:
                  type: string
              config:
                type: object
                additionalProperties:
                  type: array
                  items:
                    type: string
              organization:
                type: string
            required:
              - layers
              - config
              - organization
            # /ResourceHierarchySpec
  - name: v1alpha2
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        required:
        - spec
        properties:
          spec:
            # ResourceHierarchySpec
            type: object
            properties:
              subtrees:
                type: object
                additionalProperties:
                  x-kubernetes-preserve-unknown-fields: true
              config:
                type: array
                items:
                  type: object
                  additionalProperties:
                    x-kubernetes-preserve-unknown-fields: true
              parentRef:
                type: object
                properties:
                  kind:
                    type: string
                    enum:
                      - Organization
                  external:
                    type: string
                required:
                  - external
            required:
              - config
              - parentRef
            # /ResourceHierarchySpec
