# 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
#
#     https://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: functions.function.knative.dev
  labels:
    samples.knative.dev/release: devel
    knative.dev/crd-install: "true"
spec:
  group: function.knative.dev
  versions:
    - name: v1alpha1
      served: true
      storage: true
      subresources:
        status: { }
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              description: Spec holds the desired state of the SimpleDeployment (from the client).
              type: object
              properties:
                HttpTrigger:
                  description: HttpTrigger specifies multi http ingress for your function.
                  type: array
                  items:
                    type: object
                instances:
                  description: Instances specifies multi revisions you can release at one time.
                  type: array
                  items:
                    type: object
                traffic:
                  description: Traffic specifies how to distribute traffic over a collection of revisions and configurations.
                  type: array
                  items:
                    type: object
            status:
              description: Status communicates the observed state of the SimpleDeployment (from the controller).
              type: object
              properties:
                address:
                  description: Address holds the information needed for a Route to be the target of an event.
                  type: object
                  required:
                    - url
                  properties:
                    url:
                      type: string
                annotations:
                  description: Annotations is additional Status fields for the Resource to save some additional State as well as convey more information to the user. This is roughly akin to Annotations on any k8s resource, just the reconciler conveying richer information outwards.
                  type: object
                  x-kubernetes-preserve-unknown-fields: true
                conditions:
                  description: Conditions the latest available observations of a resource's current state.
                  type: array
                  items:
                    type: object
                latestCreatedRevisionName:
                  description: LatestCreatedRevisionName is the last revision that was created from this Configuration. It might not be ready yet, for that use LatestReadyRevisionName.
                  type: string
                latestReadyRevisionName:
                  description: LatestReadyRevisionName holds the name of the latest Revision stamped out from this Configuration that has had its "Ready" condition become "True".
                  type: string
                message:
                  description: If Failed, Message tell you why.
                  type: string
                name:
                  description: Host of HttpTrigger
                  type: string
                observedGeneration:
                  description: ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.
                  type: integer
                  format: int64
                ready:
                  type: boolean
                traffic:
                  description: Traffic holds the configured traffic distribution. These entries will always contain RevisionName references. When ConfigurationName appears in the spec, this will hold the LatestReadyRevisionName that we last observed.
                  type: array
                  items:
                    type: object
                url:
                  description: URL holds the url that will distribute traffic over the provided traffic targets. It generally has the form http[s]://{route-name}.{route-namespace}.{cluster-level-suffix}
                  type: string
      additionalPrinterColumns:
        - name: Ready
          type: string
          jsonPath: ".status.conditions[?(@.type=='Ready')].status"
        - name: Reason
          type: string
          jsonPath: ".status.conditions[?(@.type=='Ready')].reason"
  names:
    kind: Function
    plural: functions
    singular: function
    categories:
    - all
    - knative
    shortNames:
    - func
  scope: Namespaced

