apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: {{ .Values.customResource.plural }}.{{ .Values.customResource.group }}
  labels:
  {{- include "camaraaas-qod-provisioning-api-op-chart.labels" . | nindent 4 }}
spec:
  group: {{ quote .Values.customResource.group }}
  names:
    plural: {{ quote .Values.customResource.plural }}
    singular: {{ quote .Values.customResource.singular }}
    kind: {{ quote .Values.customResource.kind }}
    shortNames: {{ toYaml .Values.customResource.shortNames | nindent 6 }}
  scope: Namespaced
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                status:
                  type: string
                  default: NOT_RUNNING
                  enum:
                    - "RUNNING"
                    - "NOT_RUNNING"
                messageBroker:
                  type: object
                  properties:
                    address:
                      type: string
                    port:
                      type: integer
                    # Todo: The username and password should come from a K8s Secret
                    username:
                      type: string
                    password:
                      type: string
                  required:
                    - address
                    - port
                    - username
                    - password

                serviceUnderControl:
                  type: object
                  properties:
                    uuid:
                      type: string
                      format: uuid
                  required:
                    - uuid

                camaraAPI:
                  type: object
                  properties:
                    status:
                      type: string
                      default: "NOT_RUNNING"
                      enum:
                        - "RUNNING"
                        - "NOT_RUNNING"
                    url:
                      type: string
                      default: Yet To Be Configured
                    username:
                      type: string
                      default: Yet To Be Configured
                    password:
                      type: string
                      default: Yet To Be Configured
                    results:
                      type: string
                      default: ""
              required:
                - serviceUnderControl
                - messageBroker