# Copyright 2020 Google LLC
#
# 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: brokercells.internal.events.cloud.google.com
  labels:
    events.cloud.google.com/release: devel
    events.cloud.google.com/crd-install: "true"
spec:
  group: internal.events.cloud.google.com
  names:
    kind: BrokerCell
    plural: brokercells
    singular: brokercell
    categories:
    - knative-internal
  scope: Namespaced
  preserveUnknownFields: false
  conversion:
    strategy: Webhook
    webhook:
      # conversionReviewVersions indicates what ConversionReview versions are understood/preferred by the webhook.
      # The first version in the list understood by the API server is sent to the webhook.
      # The webhook must respond with a ConversionReview object in the same version it received.
      conversionReviewVersions: ["v1", "v1beta1"]
      clientConfig:
        service:
          name: webhook
          namespace: events-system
  versions:
  - &version
    name: v1alpha1
    served: true
    storage: true
    subresources:
      status: {}
    additionalPrinterColumns:
    - name: Ready
      type: string
      jsonPath: ".status.conditions[?(@.type==\"Ready\")].status"
    - name: Reason
      type: string
      jsonPath: ".status.conditions[?(@.type==\"Ready\")].reason"
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            properties:
              components:
                type: object
                properties:
                  fanout:
                    type: object
                    properties:
                      avgCPUUtilization:
                        type: integer
                        format: int64
                      avgMemoryUsage:
                        type: string
                      cpuRequest:
                        type: string
                      cpuLimit:
                        type: string
                      memoryRequest:
                        type: string
                      memoryLimit:
                        type: string
                      minReplicas:
                        type: integer
                        format: int64
                      maxReplicas:
                        type: integer
                        format: int64
                  ingress:
                    type: object
                    properties:
                      avgCPUUtilization:
                        type: integer
                        format: int64
                      avgMemoryUsage:
                        type: string
                      cpuRequest:
                        type: string
                      cpuLimit:
                        type: string
                      memoryRequest:
                        type: string
                      memoryLimit:
                        type: string
                      minReplicas:
                        type: integer
                        format: int64
                      maxReplicas:
                        type: integer
                        format: int64
                  retry:
                    type: object
                    properties:
                      avgCPUUtilization:
                        type: integer
                        format: int64
                      avgMemoryUsage:
                        type: string
                      cpuRequest:
                        type: string
                      cpuLimit:
                        type: string
                      memoryRequest:
                        type: string
                      memoryLimit:
                        type: string
                      minReplicas:
                        type: integer
                        format: int64
                      maxReplicas:
                        type: integer
                        format: int64
          status:
            type: object
            properties:
              observedGeneration:
                type: integer
                format: int64
              conditions:
                type: array
                items:
                  type: object
                  properties:
                    lastTransitionTime:
                      # we use a string in the stored object but a wrapper object
                      # at runtime.
                      type: string
                    message:
                      type: string
                    reason:
                      type: string
                    severity:
                      type: string
                    status:
                      type: string
                    type:
                      type: string
                  required:
                    - type
                    - status
              ingressTemplate:
                type: string
                description: >
                  IngressTemplate contains a URI template as specified by RFC6570 to generate Broker
                  ingress URIs. It may contain variables `name` and `namespace`.
