apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: opengausses.controller.k8s.do
spec:
  group: controller.k8s.do
  names:
    kind: OpenGauss
    listKind: OpenGaussList
    plural: opengausses
    singular: opengauss
    shortNames:
    - og
    categories:
    - all
  scope: Namespaced
  versions:
  - name: v1
    served: true
    storage: true
    subresources:
      status: {}
    additionalPrinterColumns:
    # - jsonPath:  .status.conditions[?(@.type=="Ready")].status
    #   name: Ready
    #   type: string
    - jsonPath: .spec.image
      description: The image for opengauss cluster.
      name: Image
      type: string
    - jsonPath: .status.readyMaster
      description: The ready master number of opengauss cluster
      name: Master-Ready
      type: string
    - jsonPath: .spec.opengauss.master.replicas
      description: The desired master number of opengauss cluster
      name: Master-Desire
      type: integer
    - jsonPath: .status.readyReplicas
      description: The ready replicas number of opengauss cluster
      name: Replicas-Ready
      type: string
    - jsonPath: .spec.opengauss.worker.replicas
      description: The desired replicas number of opengauss cluster
      name: Replicas-Desire
      type: integer
    - jsonPath: .status.opengaussStatus
      name: Status
      type: string
      description: Current sync status of opengauss resource
    schema:
      openAPIV3Schema:
        type: object
        required:
          - kind
          - apiVersion
          - spec
        properties:
          kind:
            type: string
            enum:
              - OpenGauss
          apiVersion:
            type: string
            enum:
              - controller.k8s.do/v1
          spec:
            type: object
            required:
              - image
              - opengauss
              - resources
            properties:
              image:
                type: string
              imagePullPolicy:
                type: string
              storageClassName:
                type: string
              resources:
                type: object
                required:
                  - requests
                properties:
                  requests:
                    type: object
                    required:
                      - storage
                    properties:
                      storage:
                          type: string
              opengauss:
                type: object
                required:
                  - master
                  - worker
                properties:
                  master:
                    type: object
                    required:
                      - replicas
                    properties:
                      replicas:
                        type: integer
                        format: int32
                        minimum: 1
                  worker:
                    type: object
                    required:
                      - replicas
                    properties:
                      replicas:
                        type: integer
                        format: int32
                        minimum: 0
                  resources:
                    type: object
                    required:
                      - requests
                      - limits
                    properties:
                      limits:
                        type: object
                        required:
                          - cpu
                          - memory
                        properties:
                          cpu:
                            type: string
                            pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
                          memory:
                            type: string
                            pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
                      requests:
                        type: object
                        required:
                          - cpu
                          - memory
                        properties:
                          cpu:
                            type: string
                            pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
                          memory:
                            type: string
                            pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
                  mycat:
                    type: object
                    required:
                      - replicas
                    properties:
                      replicas:
                        type: integer
                        format: int32
                        minimum: 1                      
                      image:
                        type: string
          status:
            type: object
            properties:
              masterIPs:
                type: array
                items:
                  type: string
              replicasIPs:
                type: array
                items:
                  type: string
              opengaussStatus:
                type: string
              readyMaster:
                type: string
              readyReplicas:
                type: string
              readyMycat:
                type: string
              masterStatefulset:
                type: string
              replicasStatefulset:
                type: string
              persistentVolumeClaimName:
                type: string