apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: apintorouters.apinto.com
spec:
  group: apinto.com
  scope: Namespaced
  names:
    plural: apintorouters
    singular: apintorouter
    kind: ApintoRouter
    shortNames:
      - ar
      - router
  versions:
    - name: v1beta
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              required: ["name", "listen", "driver", "target", "rules"]
              properties:
                name:
                  type: string
                  minLength: 1
                driver:
                  type: string
                  enum: ["http"]
                listen:
                  type: integer
                  minimum: 1
                  maximum: 65535
                target:
                  type: string
                  pattern: '\w+(@service)$'
                method:
                  type: array
                  items:
                    type: string
                    enum: ["*", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"]
                host:
                  type: array
                  items:
                    type: string
                    pattern: '[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?'
                protocol:
                  type: string
                  enum: ["http","https"]
                cert:
                  type: array
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                        minLength: 1
                      crt:
                        type: string
                        minLength: 1
                rules:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    properties:
                      location:
                        type: string
                        minLength: 1
                      header:
                        type: object
                        x-kubernetes-preserve-unknown-fields: true
                      query:
                        type: object
                        x-kubernetes-preserve-unknown-fields: true
                plugins:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true