#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you 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.

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: applications.yunikorn.apache.org
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: yunikorn.apache.org
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: applications
    # singular name to be used as an alias on the CLI and for display
    singular: application
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: Application
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - app
   # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1alpha1
      # Each version can be enabled/disabled by Served flag.
      served: true
      # One and only one version must be marked as the storage version.
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                schedulingPolicy:
                  type: object
                  properties:
                    type:
                      type: string
                    parameters:
                      type: object
                      additionalProperties:
                        type: string
                queue:
                  type: string
                  pattern: '^[a-zA-Z0-9_-]{1,64}([.]{1}[a-zA-Z0-9_-]{1,64})*$'
                taskGroups:
                  type: array
                  items:
                    type: object
                    properties:
                      name: 
                        type: string
                      minMember:
                        type: integer
                      minResource:
                        type: object
                        additionalProperties:
                          anyOf:
                          - type: integer
                          - type: string
                          pattern: '^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$'
                          x-kubernetes-int-or-string: true 
                      nodeSelector:
                        type: object
                        additionalProperties:
                          type: string
                      tolerations:
                        type: array
                        items:
                          type: object
                          properties:
                            effect:
                              type: string
                            key:
                              type: string
                            operator:
                              type: string
                            value:
                              type: string
                            tolerationSeconds:
                              format: int64
                              type: integer             
            status:
              type: object
              properties:
                appID:
                  type: string
                appstatus:
                  type: string
                message:
                  type: string
                lastupdate:
                  type: string
  # subresources describes the subresources for custom resources.
      subresources:
    # status enables the status subresource.
        status: {}

