# Custom Resource Definition (CRD) for OSM's policy specification.
#
# Copyright Open Service Mesh authors.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: ingressbackends.policy.openservicemesh.io
  labels:
    app.kubernetes.io/name : "openservicemesh.io"
spec:
  group: policy.openservicemesh.io
  scope: Namespaced
  names:
    kind: IngressBackend
    listKind: IngressBackendList
    shortNames:
      - ingressbackend
    singular: ingressbackend
    plural: ingressbackends
  versions:
    - name: v1alpha1
      served: true
      storage: true
      additionalPrinterColumns:
      - description: Current status of the IngressBackend policy.
        jsonPath: .status.currentStatus
        name: Status
        type: string
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              required:
                - backends
                - sources
              properties:
                backends:
                  description: Backends the IngressBackend policy is applicable to.
                  type: array
                  items:
                    type: object
                    required:
                      - name
                      - port
                    properties:
                      name:
                        description: Name of the backend.
                        type: string
                      port:
                        description: Port of the backend.
                        type: object
                        required:
                          - number
                          - protocol
                        properties:
                          number:
                            description: Port number of this port.
                            type: integer
                            minimum: 1
                            maximum: 65535
                          protocol:
                            description: Protocol served by this port.
                            type: string
                      tls:
                        description: TLS configuration for the backend.
                        type: object
                        required:
                          - skipClientCertValidation
                        properties:
                          skipClientCertValidation:
                            description: Skip client certificate validation.
                            type: boolean
                          sniHosts:
                            description: SNI hosts allowed by the backend.
                            type: array
                            items:
                              type: string
                sources:
                  description: Sources the IngressBackend policy is applicable to.
                  type: array
                  items:
                    type: object
                    required:
                      - kind
                      - name
                    properties:
                      kind:
                        description: Kind of this source.
                        type: string
                      name:
                        description: Name of this source.
                        type: string
                      namespace:
                        description: Namespace of this source.
                        type: string
                matches:
                  description: The resource references an IngressBackend policy should match on.
                  type: array
                  items:
                    type: object
                    required: ['apiGroup', 'kind', 'name']
                    properties:
                      apiGroup:
                        description: API group for the resource being referenced.
                        type: string
                      kind:
                        description: Type of resource being referenced.
                        type: string
                      name:
                        description: Name of resource being referenced.
                        type: string
            status:
              type: object
              x-kubernetes-preserve-unknown-fields: true
      subresources:
        # status enables the status subresource
        status: {}
