# Copyright 2019 The Knative 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/v1beta1
kind: CustomResourceDefinition
metadata:
  labels:
    eventing.knative.dev/release: devel
    eventing.knative.dev/source: "true"
    duck.knative.dev/source: "true"
    knative.dev/crd-install: "true"
  annotations:
    # TODO add schemas and descriptions
    registry.knative.dev/eventTypes: |
      [
        { "type": "dev.knative.cronjob.event" }
      ]
  name: cronjobsources.sources.eventing.knative.dev
spec:
  group: sources.eventing.knative.dev
  names:
    categories:
    - all
    - knative
    - eventing
    - sources
    kind: CronJobSource
    plural: cronjobsources
  scope: Namespaced
  subresources:
    status: {}
  additionalPrinterColumns:
    - name: Ready
      type: string
      JSONPath: ".status.conditions[?(@.type==\"Ready\")].status"
    - name: Age
      type: date
      JSONPath: .metadata.creationTimestamp
  validation:
    openAPIV3Schema:
      properties:
        spec:
          properties:
            data:
              type: string
            schedule:
              type: string
            serviceAccountName:
              type: string
            sink:
              anyOf:
                - type: object
                  description: "the destination that should receive events."
                  properties:
                    ref:
                      type: object
                      description: "a reference to a Kubernetes object from which to retrieve the target URI."
                      required:
                        - apiVersion
                        - kind
                        - name
                      properties:
                        apiVersion:
                          type: string
                          minLength: 1
                        kind:
                          type: string
                          minLength: 1
                        name:
                          type: string
                          minLength: 1
                    uri:
                      type: string
                      description: "the target URI. If ref is provided, this must be relative URI reference."
                - type: object
                  description: "DEPRECATED: a reference to a Kubernetes object from which to retrieve the target URI."
                  required:
                    - apiVersion
                    - kind
                    - name
                  properties:
                    apiVersion:
                      type: string
                      minLength: 1
                    kind:
                      type: string
                      minLength: 1
                    name:
                      type: string
                      minLength: 1
            resources:
              properties:
                limits:
                  properties:
                    cpu:
                      type: string
                    memory:
                      type: string
                  type: object
                requests:
                  properties:
                    cpu:
                      type: string
                    memory:
                      type: string
                  type: object
              type: object
          required:
          - schedule
          type: object
        status:
          properties:
            conditions:
              items:
                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
                type: object
              type: array
            sinkUri:
              type: string
          type: object
  versions:
  - name: v1alpha1
    served: true
    storage: true
