apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: kubedirectorapps.kubedirector.hpe.com
spec:
  group: kubedirector.hpe.com
  names:
    kind: KubeDirectorApp
    listKind: KubeDirectorAppList
    plural: kubedirectorapps
    singular: kubedirectorapp
    shortNames:
      - kdapp
  scope: Namespaced
  versions:
    - name: v1beta1
      served: true
      storage: true
      additionalPrinterColumns:
      - name: App Name
        type: string
        description: Human-readable app name
        jsonPath: .spec.label.name
      - name: Distro ID
        type: string
        description: Unique identifier of a series of kdapp versions
        jsonPath: .spec.distroID
      - name: Version
        type: string
        description: A specific release of a kdapp distro ID
        jsonPath: .spec.version
      schema:
        openAPIV3Schema:
          type: object
          required: [apiVersion, kind, metadata, spec]
          properties:
            apiVersion:
              type: string
            kind:
              type: string
            metadata:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 63
            spec:
              type: object
              required: [label, distroID, version, roles, config, configSchemaVersion]
              properties:
                label:
                  type: object
                  required: [name]
                  properties:
                    name:
                      type: string
                      minLength: 1
                    description:
                      type: string
                distroID:
                  type: string
                  minLength: 1
                version:
                  type: string
                  minLength: 1
                configSchemaVersion:
                  type: integer
                  minimum: 7
                defaultImageRepoTag:
                  type: string
                  minLength: 1
                defaultConfigPackage:
                  type: object
                  nullable: true
                  required: [packageURL]
                  properties:
                    packageURL:
                      type: string
                      pattern: '^(file|https?)://.+\.tgz$'
                    useNewSetupLayout:
                      type: boolean
                defaultMaxLogSizeDump:
                  type: integer
                  minimum: 0
                services:
                  type: array
                  items:
                    type: object
                    required: [id]
                    properties:
                      id:
                        type: string
                        minLength: 1
                        maxLength: 15
                        pattern: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$'
                      label:
                        type: object
                        nullable: true
                        required: [name]
                        properties:
                          name:
                            type: string
                            minLength: 1
                          description:
                            type: string
                      endpoint:
                        type: object
                        nullable: true
                        required: [port]
                        properties:
                          port:
                            type: integer
                            minimum: 1
                            maximum: 65535
                          urlScheme:
                            type: string
                            minLength: 1
                            maxLength: 15
                            pattern: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$'
                          path:
                            type: string
                          isDashboard:
                            type: boolean
                          hasAuthToken:
                            type: boolean
                roles:
                  type: array
                  items:
                    type: object
                    required: [id, cardinality]
                    properties:
                      id:
                        type: string
                        minLength: 1
                        maxLength: 63
                        pattern: '^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$'
                      cardinality:
                        type: string
                        pattern: '^\d+\+?$'
                      imageRepoTag:
                        type: string
                        minLength: 1
                      configPackage:
                        type: object
                        nullable: true
                        required: [packageURL]
                        properties:
                          packageURL:
                            type: string
                            pattern: '^(file|https?)://.+\.tgz$'
                          useNewSetupLayout:
                            type: boolean
                      persistDirs:
                        type: array
                        items:
                          type: string
                          pattern: '^/.*[^/]$'
                      eventList:
                        type: array
                        items:
                          type: string
                          pattern: '^configure$|^addnodes$|^delnodes$'
                      containerSpec:
                        type: object
                        nullable: true
                        properties:
                          stdin:
                            type: boolean
                          tty:
                            type: boolean
                      minResources:
                        x-kubernetes-preserve-unknown-fields: true
                        type: object
                        nullable: true
                        properties:
                          memory:
                            type: string
                            pattern: '^([0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'
                          cpu:
                            type: string
                            pattern: '^([0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'
                          ephemeral-storage:
                            type: string
                            pattern: '^([0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'
                          nvidia.com/gpu:
                            type: string
                            pattern: '^([0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'
                          amd.com/gpu:
                            type: string
                            pattern: '^([0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'
                      minStorage:
                        type: object
                        nullable: true
                        required: [size]
                        properties:
                          size:
                            type: string
                            pattern: '^([0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'
                          ephemeralModeSupported:
                            type: boolean
                      maxLogSizeDump:
                        type: integer
                        minimum: 0
                config:
                  type: object
                  required: [selectedRoles, roleServices]
                  properties:
                    configMeta:
                      type: object
                      nullable: true
                      additionalProperties:
                        type: string
                    selectedRoles:
                      type: array
                      items:
                        type: string
                        minLength: 1
                    roleServices:
                      type: array
                      items:
                        type: object
                        required: [roleID, serviceIDs]
                        properties:
                          roleID:
                            type: string
                            minLength: 1
                            maxLength: 63
                            pattern: '^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$'
                          serviceIDs:
                            type: array
                            items:
                              type: string
                              minLength: 1
                              maxLength: 15
                              pattern: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$'
                defaultPersistDirs:
                  type: array
                  items:
                    type: string
                    pattern: '^/.*[^/]$'
                defaultEventList:
                  type: array
                  items:
                    type: string
                    pattern: '^configure$|^addnodes$|^delnodes$'
                capabilities:
                  type: array
                  items:
                    type: string
                    minLength: 1
                systemdRequired:
                  type: boolean
                logoURL:
                  type: string
                  minLength: 1
                  pattern: '^(file|https|http?)://.+\.(jpeg|png)$'