# Copyright 2019 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.

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: brokerappconfigs.gcp.solutions
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: gcp.solutions
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1
      # 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
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: brokerappconfigs
    # singular name to be used as an alias on the CLI and for display
    singular: brokerappconfig
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: BrokerAppConfig
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
      - bac
  #preserveUnknownFields: false
  validation:
    openAPIV3Schema:
      type: object
      required:
        - spec
      properties:
        spec:
          type: object
          required:
            - version
            - name
            - displayName
            - description
            - bundle
            - serviceName
            - defaultRepo
            - defaultTag
          properties:
            type:
              type: string
              enum: [statefulset, deployment]
            version:
              type: string
            name:
              type: string
            displayName:
              type: string
            description:
              type: string
            icon:
              type: string
            launchURL:
              type: string
            disabled:
              type: boolean
            authorizedUsers:
              type: array
              items:
                type: string
            authorization:
              type: object
              required:
                - configMapRef
              properties:
                configMapRef:
                  type: object
                  required:
                    - name
                  properties:
                    name:
                      type: string
            bundle:
              type: object
              required:
                - configMapRef
              properties:
                configMapRef:
                  type: object
                  required:
                    - name
                  properties:
                    name:
                      type: string
            userBundles:
              type: array
              items:  
                type: object
                required:
                  - configMapRef
                properties:
                  configMapRef:
                    type: object
                    required:
                      - name
                    properties:
                      name:
                        type: string
            deployment:
              type: object
              properties:
                replicas:
                  type: integer
                  minimum: 0
                selector:
                  type: string
            serviceName:
              type: string
            defaultRepo:
              type: string
            defaultTag:
              type: string
            images:
              type: object
              additionalProperties:
                type: object
                properties:
                  name:
                    type: string
                  oldRepo:
                    type: string
                  newRepo:
                    type: string
                  newTag:
                    type: string
                  digest:
                    type: string
            disableOptions:
              type: boolean
            userParams:
              type: array
              items:
                type: object
                required:
                  - name
                  - displayName
                  - type
                  - default
                properties:
                  name:
                    type: string
                  displayName:
                    type: string
                  type:
                    type: string
                  default:
                    type: string
            appParams:
              type: array
              items:
                type: object
                required:
                  - name
                  - default
                properties:
                  name:
                    type: string
                  displayName:
                    type: string
                  type:
                    type: string
                  default:
                    type: string
            appEnv:
              type: array
              items:
                type: object
                required:
                  - name
                  - value
                properties:
                  name:
                    type: string
                  value:
                    type: string
            shutdownHooks:
              type: array
              items:
                type: object
                properties:
                  selector:
                    type: string
                  container:
                    type: string
                  command:
                    type: string
            editors:
              type: array
              items:
                type: string
            defaultTier:
              type: string
            nodeTiers:
              type: array
              items:
                type: object
                required:
                  - name
                  - nodeLabel
                properties:
                  name:
                    type: string
                  nodeLabel:
                    type: string
                  resources:
                    type: object
                    properties:
                      requests:
                        type: object
                        properties:
                          cpu:
                            schema:
                              oneOf:
                                - type: string
                                - type: number
                          memory:
                            type: string
                      limits:
                        type: object
                        properties:
                          cpu:
                            schema:
                              oneOf:
                                - type: string
                                - type: number
                          memory:
                            type: string
---
# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: brokerappuserconfigs.gcp.solutions
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: gcp.solutions
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1
      # 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
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: brokerappuserconfigs
    # singular name to be used as an alias on the CLI and for display
    singular: brokerappuserconfig
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: BrokerAppUserConfig
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
      - bauc
  #preserveUnknownFields: false
  validation:
    openAPIV3Schema:
      type: object
      properties:
        spec:
          type: object
          properties:
            appName:
              type: string
            user:
              type: string
            imageRepo:
              type: string
            imageTag:
              type: string
            nodeTier:
              type: string
            params:
              type: object
