apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: trainingportals.training.eduk8s.io
spec:
  scope: Cluster
  group: training.eduk8s.io
  names:
    plural: trainingportals
    singular: trainingportal
    kind: TrainingPortal
    categories:
    - eduk8s
    - eduk8s-training
  versions:
    - name: v1alpha1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                system:
                  type: object
                  properties:
                    profile:
                      type: string
                portal:
                  type: object
                  properties:
                    image:
                      type: string
                    title:
                      type: string
                    logo:
                      type: string
                    password:
                      type: string
                    index:
                      type: string
                    sessions:
                      type: object
                      properties:
                        maximum:
                          type: integer
                        registered:
                          type: integer
                        anonymous:
                          type: integer
                    capacity:
                      type: integer
                    initial:
                      type: integer
                    reserved:
                      type: integer
                    expires:
                      type: string
                      pattern: '^\d+(s|m|h)$'
                    orphaned:
                      type: string
                      pattern: '^\d+(s|m|h)$'
                    theme:
                      type: object
                      properties:
                        frame:
                          type: object
                          properties:
                            ancestors:
                              type: array
                              items:
                                type: string
                    ingress:
                      type: object
                      properties:
                        hostname:
                          type: string
                        domain:
                          type: string
                        protocol:
                          type: string
                        secret:
                          type: string
                        class:
                          type: string
                    registration:
                        type: object
                        properties:
                          type:
                            type: string
                            pattern: '^(one-step|anonymous)$'
                          enabled:
                            type: boolean
                    catalog:
                      type: object
                      properties:
                        visibility:
                          type: string
                          pattern: '^(public|private)$'
                    credentials:
                      type: object
                      properties:
                        admin:
                          type: object
                          properties:
                            username:
                              type: string
                            password:
                              type: string
                        robot:
                          type: object
                          properties:
                            username:
                              type: string
                            password:
                              type: string
                    clients:
                      type: object
                      properties:
                        robot:
                          type: object
                          properties:
                            id:
                              type: string
                            secret:
                              type: string
                analytics:
                  type: object
                  properties:
                    google:
                      type: object
                      properties:
                        trackingId:
                          type: string
                workshops:
                  type: array
                  items:
                    type: object
                    required:
                    - name
                    properties:
                      name:
                        type: string
                      capacity:
                        type: integer
                      initial:
                        type: integer
                      reserved:
                        type: integer
                      expires:
                        type: string
                        pattern: '^\d+(s|m|h)$'
                      orphaned:
                        type: string
                        pattern: '^\d+(s|m|h)$'
                      env:
                        type: array
                        items:
                          type: object
                          required:
                          - name
                          properties:
                            name:
                              type: string
                            value:
                              type: string
            status:
              type: object
              properties:
                kopf:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true
                eduk8s:
                  type: object
                  required:
                  - url
                  - credentials
                  - clients
                  - workshops
                  - environments
                  properties:
                    url:
                      type: string
                    credentials:
                      type: object
                      required:
                      - admin
                      - robot
                      properties:
                        admin:
                          type: object
                          required:
                          - username
                          - password
                          properties:
                            username:
                              type: string
                            password:
                              type: string
                        robot:
                          type: object
                          required:
                          - username
                          - password
                          properties:
                            username:
                              type: string
                            password:
                              type: string
                    clients:
                      type: object
                      required:
                      - robot
                      properties:
                        robot:
                          type: object
                          required:
                          - id
                          - secret
                          properties:
                            id:
                              type: string
                            secret:
                              type: string
                    workshops:
                      type: array
                      items:
                        type: object
                        required:
                        - name
                        - title
                        - description
                        properties:
                          name:
                            type: string
                          title:
                            type: string
                          description:
                            type: string
                          vendor:
                            type: string
                          authors:
                            type: array
                            items:
                              type: string
                          difficulty:
                            type: string
                          duration:
                            type: string
                          tags:
                            type: array
                            items:
                              type: string
                          logo:
                            type: string
                          url:
                            type: string
                          content:
                            type: object
                            properties:
                              image:
                                type: string
                              files:
                                type: string
                    environments:
                      type: array
                      items:
                        type: object
                        required:
                        - name
                        - workshop
                        properties:
                          name:
                            type: string
                          workshop:
                            type: object
                            required:
                            - name
                            properties:
                              name:
                                type: string
                          capacity:
                            type: integer
                          initial:
                            type: integer
                          reserved:
                            type: integer
                          expires:
                            type: string
                            pattern: '^\d+(s|m|h)$'
                          orphaned:
                            type: string
                            pattern: '^\d+(s|m|h)$'
      additionalPrinterColumns:
      - name: URL
        type: string
        priority: 0
        description: The URL for accessing the portal.
        jsonPath: .status.eduk8s.url
      - name: AdminUsername
        type: string
        priority: 0
        description: The username for accessing admin pages.
        jsonPath: .status.eduk8s.credentials.admin.username
      - name: AdminPassword
        type: string
        priority: 0
        description: The password for accessing admin pages.
        jsonPath: .status.eduk8s.credentials.admin.password
