apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: testkinds.testapp.ext.grafana.app
spec:
  conversion:
    strategy: webhook
    webhook:
      clientConfig:
        url: http://foo.bar/convert
      conversionReviewVersions:
      - v1
  group: testapp.ext.grafana.app
  names:
    kind: TestKind
    plural: testkinds
  scope: Namespaced
  versions:
  - name: v1
    schema:
      openAPIV3Schema:
        properties:
          spec:
            properties:
              stringField:
                pattern: ^[a-zA-Z_][a-zA-Z0-9_-]*$
                type: string
            required:
            - stringField
            type: object
          status:
            properties:
              additionalFields:
                description: additionalFields is reserved for future use
                type: object
                x-kubernetes-preserve-unknown-fields: true
              operatorStates:
                additionalProperties:
                  properties:
                    descriptiveState:
                      description: descriptiveState is an optional more descriptive
                        state field which has no requirements on format
                      type: string
                    details:
                      description: details contains any extra information that is
                        operator-specific
                      type: object
                      x-kubernetes-preserve-unknown-fields: true
                    lastEvaluation:
                      description: lastEvaluation is the ResourceVersion last evaluated
                      type: string
                    state:
                      description: |-
                        state describes the state of the lastEvaluation.
                        It is limited to three possible states for machine evaluation.
                      enum:
                      - success
                      - in_progress
                      - failed
                      type: string
                  required:
                  - lastEvaluation
                  - state
                  type: object
                description: |-
                  operatorStates is a map of operator ID to operator state evaluations.
                  Any operator which consumes this kind SHOULD add its state evaluation information to this field.
                type: object
            type: object
        required:
        - spec
        type: object
    selectableFields:
    - jsonPath: .spec.stringField
    served: true
    storage: true
    subresources:
      status: {}
  - additionalPrinterColumns:
    - jsonPath: .spec.stringField
      name: STRING FIELD
      type: string
    name: v2
    schema:
      openAPIV3Schema:
        properties:
          spec:
            properties:
              intField:
                type: integer
              stringField:
                type: string
              timeField:
                format: date-time
                type: string
              unionNull:
                allOf:
                - required:
                  - str
                  - i
                description: This generates a normal go pointer field, but needs to
                  be handled correctly as a selectable field, as the schema logic
                  registers it as a disjunction
                nullable: true
                properties:
                  i:
                    type: integer
                  str:
                    type: string
                type: object
              unionNull2:
                description: null variant should be ignore in disjunction when generating
                  the selectable field
                oneOf:
                - not:
                    anyOf:
                    - required:
                      - b
                  required:
                  - str
                  - i
                - not:
                    anyOf:
                    - required:
                      - i
                  required:
                  - str
                  - b
                - not:
                    anyOf:
                    - required:
                      - str
                    - required:
                      - i
                    - required:
                      - str
                    - required:
                      - b
                properties:
                  b:
                    type: boolean
                  i:
                    type: integer
                  str:
                    type: string
                type:
                - object
                - "null"
            required:
            - stringField
            - intField
            - timeField
            type: object
          status:
            properties:
              additionalFields:
                description: additionalFields is reserved for future use
                type: object
                x-kubernetes-preserve-unknown-fields: true
              operatorStates:
                additionalProperties:
                  properties:
                    descriptiveState:
                      description: descriptiveState is an optional more descriptive
                        state field which has no requirements on format
                      type: string
                    details:
                      description: details contains any extra information that is
                        operator-specific
                      type: object
                      x-kubernetes-preserve-unknown-fields: true
                    lastEvaluation:
                      description: lastEvaluation is the ResourceVersion last evaluated
                      type: string
                    state:
                      description: |-
                        state describes the state of the lastEvaluation.
                        It is limited to three possible states for machine evaluation.
                      enum:
                      - success
                      - in_progress
                      - failed
                      type: string
                  required:
                  - lastEvaluation
                  - state
                  type: object
                description: |-
                  operatorStates is a map of operator ID to operator state evaluations.
                  Any operator which consumes this kind SHOULD add its state evaluation information to this field.
                type: object
            type: object
        required:
        - spec
        type: object
    selectableFields:
    - jsonPath: .spec.stringField
    - jsonPath: .spec.intField
    - jsonPath: .spec.unionNull.str
    - jsonPath: .spec.unionNull2.str
    served: true
    storage: false
    subresources:
      status: {}
  - name: v3
    schema:
      openAPIV3Schema:
        properties:
          spec:
            properties:
              boolField:
                type: boolean
              intField:
                type: integer
              stringField:
                type: string
              timeField:
                format: date-time
                type: string
            required:
            - stringField
            - intField
            - timeField
            - boolField
            type: object
          status:
            properties:
              additionalFields:
                description: additionalFields is reserved for future use
                type: object
                x-kubernetes-preserve-unknown-fields: true
              operatorStates:
                additionalProperties:
                  properties:
                    descriptiveState:
                      description: descriptiveState is an optional more descriptive
                        state field which has no requirements on format
                      type: string
                    details:
                      description: details contains any extra information that is
                        operator-specific
                      type: object
                      x-kubernetes-preserve-unknown-fields: true
                    lastEvaluation:
                      description: lastEvaluation is the ResourceVersion last evaluated
                      type: string
                    state:
                      description: |-
                        state describes the state of the lastEvaluation.
                        It is limited to three possible states for machine evaluation.
                      enum:
                      - success
                      - in_progress
                      - failed
                      type: string
                  required:
                  - lastEvaluation
                  - state
                  type: object
                description: |-
                  operatorStates is a map of operator ID to operator state evaluations.
                  Any operator which consumes this kind SHOULD add its state evaluation information to this field.
                type: object
            type: object
        required:
        - spec
        type: object
    selectableFields:
    - jsonPath: .spec.stringField
    - jsonPath: .spec.intField
    - jsonPath: .spec.boolField
    served: true
    storage: false
    subresources:
      status: {}
  - name: v4
    schema:
      openAPIV3Schema:
        properties:
          spec:
            properties:
              union:
                oneOf:
                - required:
                  - kind
                  - spec
                - required:
                  - kind
                  - spec
                properties:
                  kind:
                    type: string
                  spec:
                    properties:
                      name:
                        type: string
                    required:
                    - name
                    type: object
                type: object
            required:
            - union
            type: object
          status:
            properties:
              additionalFields:
                description: additionalFields is reserved for future use
                type: object
                x-kubernetes-preserve-unknown-fields: true
              operatorStates:
                additionalProperties:
                  properties:
                    descriptiveState:
                      description: descriptiveState is an optional more descriptive
                        state field which has no requirements on format
                      type: string
                    details:
                      description: details contains any extra information that is
                        operator-specific
                      type: object
                      x-kubernetes-preserve-unknown-fields: true
                    lastEvaluation:
                      description: lastEvaluation is the ResourceVersion last evaluated
                      type: string
                    state:
                      description: |-
                        state describes the state of the lastEvaluation.
                        It is limited to three possible states for machine evaluation.
                      enum:
                      - success
                      - in_progress
                      - failed
                      type: string
                  required:
                  - lastEvaluation
                  - state
                  type: object
                description: |-
                  operatorStates is a map of operator ID to operator state evaluations.
                  Any operator which consumes this kind SHOULD add its state evaluation information to this field.
                type: object
            type: object
        required:
        - spec
        type: object
    selectableFields:
    - jsonPath: .spec.union.spec.name
    served: true
    storage: false
    subresources:
      status: {}
