apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: corspolicies.citrix.com
spec:
  group: citrix.com
  names:
    kind: corspolicy
    plural: corspolicies
    singular: corspolicy
    shortNames:
    - cp
  scope: Namespaced
  versions: 
  - name: v1beta1
    served: true
    storage: true
    subresources:
      status: {}
    additionalPrinterColumns:
    - name: Status
      type: string
      description: 'Current Status of the CRD'
      jsonPath: .status.state
    - name: Message
      type: string
      description: 'Status Message'
      jsonPath: .status.status_message
    schema:
      openAPIV3Schema:
        type: object
        properties:
          status:
            type: object
            properties:
              state:
                 type: string
              status_message:
                 type: string
          spec:
            type: object
            properties:
              ingressclass:
                type: string
                description: "Ingress class, if not specified then all citrix ingress controllers in the cluster will process the resource otherwise only the controller with that ingress class will process this resource"
              servicenames:
                description: 'The list of Kubernetes services to which you want to apply the cors policies.'
                type: array
                items:
                  type: string
                  maxLength: 63
              allow_origin:
                description: 'Represents list of allowed origins, it is used to screen the “origin” in the cors pre flight request'
                type: array
                items:
                  type: string
                  maxLength: 2083
              allow_methods:
                description: 'Indicates which methods are supported by the response’s URL for the purposes of the CORS protocol. This variable will be used to set Access-Control-Allow-Methods in the pre-flight cors response.'
                type: array
                items:
                  type: string
                  maxLength: 127
              allow_headers:
                description: 'Indicates which headers are supported by the response’s URL for the purposes of the CORS protocol. This variable will be used to set Access-Control-Allow-Headers in the pre-flight cors response.'
                type: array
                items:
                  type: string
                  maxLength: 127
              max_age:
                description: 'Indicates the number of seconds (5 by default) the information provided by the `Access-Control-Allow-Methods` and `Access-Control-Allow-Headers` headers can be cached. This variable will be used to set Access-Control-Max-Age in the pre-flight cors response.'
                type: integer
              allow_credentials:
                description: 'Indicates whether the response can be shared when the request’s credentials mode is "include". This variable will be set to Access-Control-Allow-Credentials in the rewrite action.'
                type: boolean
            required: [servicenames, allow_origin, allow_methods, allow_headers]
