apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: workshops.training.eduk8s.io
spec:
  scope: Cluster
  group: training.eduk8s.io
  names:
    plural: workshops
    singular: workshop
    kind: Workshop
    categories:
    - eduk8s
    - eduk8s-training
  versions:
    - name: v1alpha1
      served: false
      storage: false
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              required:
              - title
              - description
              properties:
                title:
                  type: string
                description:
                  type: string
                vendor:
                  type: string
                authors:
                  type: array
                  items:
                    type: string
                difficulty:
                  type: string
                  pattern: '^(beginner|intermediate|advanced|extreme)$'
                duration:
                  type: string
                  pattern: '^\d+(s|m|h)$'
                tags:
                  type: array
                  items:
                    type: string
                logo:
                  type: string
                url:
                  type: string
                image:
                  type: string
                content:
                  type: string
                workshop:
                  type: object
                  properties:
                    objects:
                      type: array
                      items:
                        type: object
                        x-kubernetes-preserve-unknown-fields: true
                session:
                  type: object
                  properties:
                    role:
                      type: string
                    budget:
                      type: string
                    env:
                      type: array
                      items:
                        type: object
                        required:
                        - name
                        properties:
                          name:
                            type: string
                          value:
                            type: string
                    applications:
                      type: object
                      properties:
                        terminal:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                            layout:
                              type: string
                        editor:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                        console:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                            vendor:
                              type: string
                            openshift:
                              type: object
                              properties:
                                version:
                                  type: string
                                image:
                                  type: string
                        slides:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                        webdav:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                        docker:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                            memory:
                              type: string
                            storage:
                              type: string
                        registry:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                            memory:
                              type: string
                            storage:
                              type: string
                    dashboards:
                      type: array
                      items:
                        type: object
                        required:
                        - name
                        - url
                        properties:
                          name:
                            type: string
                          url:
                            type: string
                    ingresses:
                      type: array
                      items:
                        type: object
                        required:
                        - name
                        - port
                        properties:
                          name:
                            type: string
                          port:
                            type: integer
                    patches:
                      type: object
                      x-kubernetes-preserve-unknown-fields: true
                    objects:
                      type: array
                      items:
                        type: object
                        x-kubernetes-preserve-unknown-fields: true
            status:
              type: object
              x-kubernetes-preserve-unknown-fields: true
      additionalPrinterColumns:
      - name: Image
        type: string
        priority: 0
        description: The location of the image for the workshop.
        jsonPath: .spec.image
      - name: URL
        type: string
        priority: 0
        description: URL for further information on the workshop.
        jsonPath: .spec.url
    - name: v1alpha2
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              required:
              - title
              - description
              properties:
                title:
                  type: string
                description:
                  type: string
                vendor:
                  type: string
                authors:
                  type: array
                  items:
                    type: string
                difficulty:
                  type: string
                  pattern: '^(beginner|intermediate|advanced|extreme)$'
                duration:
                  type: string
                  pattern: '^\d+(s|m|h)$'
                tags:
                  type: array
                  items:
                    type: string
                logo:
                  type: string
                url:
                  type: string
                content:
                  type: object
                  properties:
                    image:
                      type: string
                    files:
                      type: string
                environment:
                  type: object
                  properties:
                    objects:
                      type: array
                      items:
                        type: object
                        x-kubernetes-preserve-unknown-fields: true
                session:
                  type: object
                  properties:
                    role:
                      type: string
                    budget:
                      type: string
                    namespaces:
                      type: object
                      properties:
                        role:
                          type: string
                        budget:
                          type: string
                        limits:
                          type: object
                          properties:
                            min:
                              type: object
                              properties:
                                cpu:
                                  type: string
                                memory:
                                  type: string
                            max:
                              type: object
                              properties:
                                cpu:
                                  type: string
                                memory:
                                  type: string
                            defaultRequest:
                              type: object
                              properties:
                                cpu:
                                  type: string
                                memory:
                                  type: string
                            default:
                              type: object
                              properties:
                                cpu:
                                  type: string
                                memory:
                                  type: string
                        security:
                          type: object
                          properties:
                            policy:
                              type: string
                              enum:
                              - nonroot
                              - anyuid
                              default: nonroot
                        secondary:
                          type: array
                          items:
                            type: object
                            required:
                            - name
                            properties:
                              name:
                                type: string
                              role:
                                type: string
                              budget:
                                type: string
                              limits:
                                type: object
                                properties:
                                  min:
                                    type: object
                                    properties:
                                      cpu:
                                        type: string
                                      memory:
                                        type: string
                                  max:
                                    type: object
                                    properties:
                                      cpu:
                                        type: string
                                      memory:
                                        type: string
                                  defaultRequest:
                                    type: object
                                    properties:
                                      cpu:
                                        type: string
                                      memory:
                                        type: string
                                  default:
                                    type: object
                                    properties:
                                      cpu:
                                        type: string
                                      memory:
                                        type: string
                              security:
                                type: object
                                properties:
                                  policy:
                                    type: string
                                    enum:
                                    - nonroot
                                    - anyuid
                                    default: nonroot
                    security:
                      type: object
                      properties:
                        policy:
                          type: string
                          enum:
                          - nonroot
                          - anyuid
                          - custom
                          default: nonroot
                    resources:
                      type: object
                      properties:
                        memory:
                          type: string
                        storage:
                          type: string
                    env:
                      type: array
                      items:
                        type: object
                        required:
                        - name
                        properties:
                          name:
                            type: string
                          value:
                            type: string
                    applications:
                      type: object
                      properties:
                        workshop:
                          type: object
                          properties:
                            enabled:
                              type: boolean
                            url:
                              type: string
                        terminal:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                            layout:
                              type: string
                        editor:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                        console:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                            vendor:
                              type: string
                            openshift:
                              type: object
                              properties:
                                version:
                                  type: string
                                image:
                                  type: string
                        slides:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                        webdav:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                        docker:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                            memory:
                              type: string
                            storage:
                              type: string
                        registry:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                            memory:
                              type: string
                            storage:
                              type: string
                        examiner:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                        files:
                          type: object
                          required:
                          - enabled
                          properties:
                            enabled:
                              type: boolean
                            directory:
                              type: string
                    dashboards:
                      type: array
                      items:
                        type: object
                        required:
                        - name
                        - url
                        properties:
                          name:
                            type: string
                          url:
                            type: string
                    ingresses:
                      type: array
                      items:
                        type: object
                        required:
                        - name
                        properties:
                          name:
                            type: string
                          protocol:
                            type: string
                          host:
                            type: string
                          port:
                            type: integer
                          headers:
                            type: array
                            items:
                              type: object
                              required:
                              - name
                              properties:
                                name:
                                  type: string
                                value:
                                  type: string
                    patches:
                      type: object
                      x-kubernetes-preserve-unknown-fields: true
                    objects:
                      type: array
                      items:
                        type: object
                        x-kubernetes-preserve-unknown-fields: true
            status:
              type: object
              x-kubernetes-preserve-unknown-fields: true
      additionalPrinterColumns:
      - name: Image
        type: string
        priority: 0
        description: The location of the image for the workshop.
        jsonPath: .spec.content.image
      - name: Files
        type: string
        priority: 0
        description: The location of the files for the workshop.
        jsonPath: .spec.content.files
      - name: URL
        type: string
        priority: 0
        description: URL for further information on the workshop.
        jsonPath: .spec.url
