apiVersion: apiextensions.k8s.io/v1
kind: "CustomResourceDefinition"
metadata:
    name: "backupusers.backups.riotkit.org"
spec:
    group: "backups.riotkit.org"
    scope: "Namespaced"
    names:
        plural: "backupusers"
        singular: "backupuser"
        kind: "BackupUser"
        shortNames:
            - "brusers"
            - "bru"
        categories:
            - "backuprepository"
    versions:
        - name: v1alpha1
          served: true
          storage: true

          schema:
              openAPIV3Schema:
                  type: object
                  required: ["spec"]
                  properties:
                      spec:
                          type: object
                          required: ["email", "roles"]
                          properties:
                              email:
                                  type: string
                              deactivated:
                                  type: boolean
                              organization:
                                  type: string
                              about:
                                  type: string
                              password:  # todo: remove
                                  type: string
                              passwordFromRef:
                                  type: object
                                  required: ["name", "entry"]
                                  properties:
                                      name:
                                          type: string
                                      entry:
                                          type: string
                              restrictByIP:
                                  type: array
                                  items:
                                      type: string
                              roles:
                                  type: array
                                  items:
                                      type: string
                                      enum: ["collectionManager", "usersManager", "systemAdmin"]


          additionalPrinterColumns:
            - name: Email
              type: string
              jsonPath: .spec.email

            - name: Organization
              type: string
              jsonPath: .spec.organization

            - name: Is deactivated
              type: boolean
              jsonPath: .spec.deactivated
