groups:
  - name: "Collabora Configuration"
    description: "Configure Collabora"
  - name: "Collabora Environment Variables"
    description: "Set the environment that will be visible to the container"
  - name: "Networking"
    description: "Configure Networking for Collabora"
  - name: "Storage"
    description: "Configure Storage for Collabora"
  - name: "Resource Limits"
    description: "Set CPU/memory limits for Kubernetes Pod"

portals:
  web_portal:
    protocols:
      - "https"
    host:
      - "$variable-config.server_name"
    ports:
      - "$variable-nodePort"
    path: "/browser/dist/admin/admin.html"

questions:
  - variable: config
    label: "Container Configuration"
    group: "Collabora Configuration"
    schema:
      type: dict
      attrs:
        - variable: timezone
          label: "Timezone"
          group: "Collabora Configuration"
          schema:
            type: string
            $ref:
              - "definitions/timezone"
        - variable: enableWebUI
          label: "Enable WebUI"
          description: |
            Enable WebUI for Collabora
            If you enable this, you will need to set a username and password</br>
          schema:
            type: boolean
            default: true
        - variable: username
          label: "Username for WebUI"
          show_if: [[enableWebUI, "=", true]]
          schema:
            type: string
            default: "admin"
            required: true
        - variable: password
          label: "Password for WebUI"
          schema:
            type: string
            private: true
            default: "changeme"
            show_if: [[enableWebUI, "=", true]]
            valid_chars: "[a-zA-Z0-9!@#%^&*?]{8,}"
            valid_chars_error: |
              Password must be at least 8 characters long</br>
              Can contain at numbers, letters, and the following characters: !@#%^&*?
            required: true
        - variable: aliasgroup1
          label: "Alias Group 1"
          description: |
            List of domains that will be allowed to access the Collabora server
            Type one domain per line
          schema:
            type: list
            items:
              - variable: alias
                label: "Alias"
                schema:
                  type: string
        - variable: dictionaries
          label: "Dictionaries to use, leave empty to use all"
          schema:
            type: string
            default: "de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru"
        - variable: extra_params
          label: "Extra Parameters to add"
          description: 'e.g. "--o:welcome.enable=false", See more on /etc/loolwsd/loowsd.xml. Separate params with space'
          schema:
            type: string
            default: "--o:welcome.enable=false --o:user_interface.mode=notebookbar --o:ssl.termination=true --o:ssl.enable=false --o:net.proto=IPv4"
        - variable: server_name
          label: "Server Name"
          description: |
            When this environment variable is set (is not “”), then its value will be used as server name in /etc/loolwsd/loolwsd.xml.
            Without this, CODE is not delivering a correct host for the websocket connection in case of a proxy in front of it.</br>
            If a port is not specified, the below configured Node Port will be used.
          schema:
            type: string
            $ref:
              - "definitions/nodeIP"

  - variable: certificate
    description: |
      Collabora Certificate</br>
      If you do not choose a certificate and do not configure an external reverse proxy</br>
      you might have to adjust the extra_params.
    label: "Certificate"
    group: "Collabora Configuration"
    schema:
      type: int
      $ref:
        - "definitions/certificate"
      "null": true

  - variable: extraAppVolumeMounts
    label: "Collabora Extra Host Path Volumes"
    group: "Storage"
    schema:
      type: list
      items:
        - variable: extraAppVolume
          label: "Collabora Host Path Volume"
          description: "Add an extra host path volume for Collabora application"
          schema:
            type: dict
            attrs:
              - variable: mountPath
                label: "Mount Path in Pod"
                description: "Path where the volume will be mounted inside the pod"
                schema:
                  type: path
                  required: true
              - variable: hostPath
                label: "Host Path"
                description: "Host path"
                schema:
                  type: hostpath
                  required: true

  - variable: environmentVariables
    label: "Environment Variables"
    group: "Collabora Environment Variables"
    schema:
      type: list
      default: []
      items:
        - variable: environmentVariable
          label: "Environment Variable"
          schema:
            type: dict
            attrs:
              - variable: name
                label: "Name"
                schema:
                  type: string
              - variable: value
                label: "Value"
                schema:
                  type: string

  - variable: nodePort
    label: "Node Port to use for Collabora"
    group: "Networking"
    schema:
      type: int
      default: 9980
      min: 9000
      max: 65535

  - variable: enableResourceLimits
    label: "Enable Pod resource limits"
    group: "Resource Limits"
    schema:
      type: boolean
      default: false
  - variable: cpuLimit
    label: "CPU Limit"
    description: "CPU resource limit allow  plain integer values with suffix m(milli) e.g 1000m, 100."
    group: "Resource Limits"
    schema:
      type: string
      show_if: [["enableResourceLimits", "=", true]]
      valid_chars: "^\\d+(?:\\.\\d+(?!.*m$)|m?$)"
      default: "4000m"
  - variable: memLimit
    label: "Memory Limit"
    group: "Resource Limits"
    description: "Memory limits is specified by number of bytes. Followed by quantity suffix like E,P,T,G,M,k and Ei,Pi,Ti,Mi,Gi,Ki can also be used. e.g 129e6, 129M,  128974848000m, 123Mi"
    schema:
      type: string
      show_if: [["enableResourceLimits", "=", true]]
      valid_chars: "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$"
      default: "8Gi"
