# Copyright 2021 TriggerMesh Inc.
#
# 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: confluenttargets.targets.triggermesh.io
  labels:
    knative.dev/crd-install: 'true'
    triggermesh.io/crd-install: 'true'
    duck.knative.dev/addressable: 'true'
spec:
  group: targets.triggermesh.io
  names:
    kind: ConfluentTarget
    plural: confluenttargets
    categories:
    - all
    - knative
    - eventing
    - targets
  scope: Namespaced
  versions:
  - name: v1alpha1
    served: true
    storage: true
    subresources:
      status: {}
    schema:
      openAPIV3Schema:
        type: object
        description: TriggerMesh event target for Confluent Kafka.
        properties:
          spec:
            description: Desired state of event target.
            type: object
            properties:
              username:
                description: Confluent account username when using SASL.
                type: string
                minLength: 1
              password:
                description: Confluent account password when using SASL.
                type: object
                properties:
                  secretKeyRef:
                    type: object
                    properties:
                      key:
                        type: string
                      name:
                        type: string
              topic:
                description: Topic name to stream the target events to.
                type: string
                minLength: 1
              topicReplicationFactor:
                description: The number of replicas required to stream to the topic.
                type: integer
              topicPartitions:
                description: The number of partitions used by the topic to stream an event to.
                type: integer
              bootstrapServers:
                description: Array of Confluent Kafka servers used to bootstrap the connection.
                type: array
                items:
                  type: string
                  minLength: 1
              securityProtocol:
                description: Encryption protocol to use for connecting to Confluent Kafka.
                  This can be "Plaintext", "SslPlaintext", "SaslSsl", or "Ssl". Additional information can be found at https://docs.confluent.io/platform/current/connect/security.html
                type: string
              saslMechanism:
                description: When using the "saslSsl" securityProtocol attribute, indicate which
                  mechanism to use. This can be "Gssapi", "OAuthBearer", "Plain", "ScramSha256", and "ScramSha512".
                type: string
              discardCloudEventContext:
                description: Produce a new cloud event based on the response from calling Kafka.
                type: boolean
            required:
            - username
            - password
            - topic
            - bootstrapServers
          status:
            type: object
            description: Reported status of the event target.
            properties:
              observedGeneration:
                type: integer
                format: int64
              conditions:
                type: array
                items:
                  type: object
                  properties:
                    type:
                      type: string
                    status:
                      type: string
                      enum: ['True', 'False', Unknown]
                    severity:
                      type: string
                      enum: [Error, Warning, Info]
                    reason:
                      type: string
                    message:
                      type: string
                    lastTransitionTime:
                      type: string
                      format: date-time
                  required:
                  - type
                  - status
              address:
                type: object
                properties:
                  url:
                    type: string
    additionalPrinterColumns:
    - name: URL
      type: string
      jsonPath: .status.address.url
    - 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
