groups:
  - name: MinIO Credentials
    description: Configure Credentials for MinIO
  - name: User and Group Configuration
    description: Configure User and Group for MinIO
  - name: Network Configuration
    description: Configure Network for MinIO
  - name: Storage Configuration
    description: Configure Storage for MinIO
  - name: MultiMode Configuration
    description: Configure MultiMode for MinIO
  - name: MinIO Logging
    description: Configure Logging for MinIO
  - name: Resources Configuration
    description: Configure Resources for MinIO

portals:
  web_portal:
    protocols:
      - "$kubernetes-resource_configmap_portal_protocol"
    host:
      - "$kubernetes-resource_configmap_portal_host"
    ports:
      - "$kubernetes-resource_configmap_portal_port"
    path: "$kubernetes-resource_configmap_portal_path"

questions:
  - variable: minioCreds
    label: ""
    group: MinIO Credentials
    schema:
      type: dict
      attrs:
        - variable: rootUser
          label: Root User
          description: The access key for the root user.
          schema:
            type: string
            min_length: 5
            required: true
        - variable: rootPass
          label: Root Password
          description: The secret key for the root user.
          schema:
            type: string
            required: true
            min_length: 8
            private: true

  - variable: minioRunAs
    label: ""
    group: User and Group Configuration
    schema:
      type: dict
      attrs:
        - variable: user
          label: User ID
          description: |
            The user id that MinIO will run as. <br/>
            Can't be changed after initial install.
          schema:
            type: int
            min: 568
            default: 568
            immutable: true
            required: true
        - variable: group
          label: Group ID
          description: |
            The group id that MinIO will run as. <br/>
            Can't be changed after initial install.
          schema:
            type: int
            min: 568
            default: 568
            immutable: true
            required: true

  - variable: minioNetwork
    label: ""
    group: Network Configuration
    schema:
      type: dict
      attrs:
        - variable: apiPort
          label: API Port
          description: The port for the MinIO API.
          schema:
            type: int
            default: 30000
            min: 9000
            max: 65535
            required: true
        - variable: webPort
          label: Web Port
          description: The port for the MinIO Web UI.
          schema:
            type: int
            default: 30001
            min: 9000
            max: 65535
            required: true
        - variable: hostNetwork
          label: Host Network
          description: |
            Bind to the host network. It's recommended to keep this disabled.</br>
          schema:
            type: boolean
            default: true
        - variable: certificateID
          label: Certificate
          description: The certificate to use for MinIO
          schema:
            type: int
            "null": true
            $ref:
              - "definitions/certificate"
        - variable: serverUrl
          label: MinIO Server URL (API)
          description: |
            The URL that console will use to reach API</br>
            For example https://minio1.example.com.</br></br>
          schema:
            type: string
            required: true
        - variable: consoleUrl
          label: MinIO Browser Redirect URL
          description: |
            The URL that console will provide as a redirect URL</br>
            For example https://console.example.com.</br></br>
          schema:
            type: string
            required: true

  - variable: enableMultiMode
    label: Enable Multi Mode (SNMD or MNMD)
    group: MultiMode Configuration
    description: |
      For Single Node Multi Drive (SNMD), the entry will look like this:</br>
      Example Entry - /data{1...4}</br></br>
      For Multi Node Multi Drive (MNMD), the entry will look like this:</br>
      Example Entry - https://minio{1...3}.example.com:30000/data{1...4}</br></br>
      Note that each host must use the same port number and the same number of storage items.</br>
      In both cases /data{1...4} is the directories to be used for MinIO.
      You have to add additional storage for each data entry.
    schema:
      type: boolean
      default: false
      show_subquestions_if: true
      subquestions:
        - variable: minioMultiMode
          label: Multi Mode (SNMD or MNMD)
          group: MultiMode Configuration
          schema:
            type: list
            default: []
            items:
              - variable: item
                label: ""
                schema:
                  type: string
                  required: true

  - variable: minioStorage
    label: ""
    group: Storage Configuration
    schema:
      type: list
      default: [{"type": "ixVolume", "mountPath": "/data1", "datasetName": "data1"}]
      empty: false
      required: true
      items:
        - variable: item
          label: Storage Item
          schema:
            type: dict
            attrs:
              - variable: type
                label: Type
                description: |
                  ixVolume: Is dataset created automatically by the system.</br>
                  Host Path: Is a path that already exists on the system.
                schema:
                  type: string
                  immutable: true
                  required: true
                  default: ixVolume
                  enum:
                    - value: hostPath
                      description: Host Path (Path that already exists on the system)
                    - value: ixVolume
                      description: ixVolume (Dataset created automatically by the system)
              - variable: mountPath
                label: Mount Path
                description: The path inside the container to mount the storage.
                schema:
                  type: path
                  required: true
                  immutable: true
                  default: /data1
              - variable: hostPath
                label: Host Path
                description: The host path to use for storage.
                schema:
                  type: hostpath
                  required: true
                  immutable: true
                  default: ""
                  show_if: [["type", "=", "hostPath"]]
              - variable: datasetName
                label: Dataset Name
                description: The name of the dataset to use for storage.
                schema:
                  type: string
                  show_if: [["type", "=", "ixVolume"]]
                  required: true
                  immutable: true
                  # Can we make this dynamic, so we can hide it?!
                  default: data1
                  $ref:
                    - "normalize/ixVolume"

  - variable: minioLogging
    label: ""
    group: MinIO Logging
    schema:
      type: dict
      attrs:
        - variable: anonymous
          label: Anonymous
          description: Hides sensitive information from logging.
          schema:
            type: boolean
            default: false
        - variable: quiet
          label: Quiet
          description: Disables startup information.
          schema:
            type: boolean
            default: false

        - variable: logsearch
          label: LogSearch Configuration
          schema:
            type: dict
            attrs:
              - variable: enabled
                label: Enable LogSearch
                schema:
                  type: boolean
                  default: false
                  show_subquestions_if: true
                  subquestions:
                    - variable: diskCapacityGB
                      label: Disk Capacity (GB)
                      description: The disk capacity for LogSearch.
                      schema:
                        type: int
                        default: 5
                        required: true
                    - variable: pgData
                      label: Postgres Data Storage
                      description: The path to store Postgres data.
                      schema:
                        type: dict
                        attrs:
                          - variable: type
                            label: Type
                            schema:
                              type: string
                              required: true
                              immutable: true
                              default: ixVolume
                              enum:
                                - value: hostPath
                                  description: Host Path
                                - value: ixVolume
                                  description: ixVolume
                          - variable: datasetName
                            label: Dataset Name
                            schema:
                              type: string
                              show_if: [["type", "=", "ixVolume"]]
                              required: true
                              hidden: true
                              immutable: true
                              default: postgres-data
                              $ref:
                                - "normalize/ixVolume"
                          - variable: hostPath
                            label: Host Path
                            schema:
                              type: hostpath
                              show_if: [["type", "=", "hostPath"]]
                              immutable: true
                              required: true
                    - variable: pgBackup
                      label: Postgres Backup Storage
                      description: The path to store Postgres backups.
                      schema:
                        type: dict
                        attrs:
                          - variable: type
                            label: Type
                            schema:
                              type: string
                              required: true
                              default: ixVolume
                              enum:
                                - value: hostPath
                                  description: Host Path
                                - value: ixVolume
                                  description: ixVolume
                          - variable: datasetName
                            label: Dataset Name
                            schema:
                              type: string
                              show_if: [["type", "=", "ixVolume"]]
                              required: true
                              hidden: true
                              immutable: true
                              default: postgres-backup
                              $ref:
                                - "normalize/ixVolume"
                          - variable: hostPath
                            label: Host Path
                            schema:
                              type: hostpath
                              show_if: [["type", "=", "hostPath"]]
                              required: true

  - variable: resources
    label: ""
    group: Resources Configuration
    schema:
      type: dict
      attrs:
        - variable: limits
          label: Limits
          schema:
            type: dict
            attrs:
              - variable: cpu
                label: CPU
                description: CPU limit for MinIO.
                schema:
                  type: string
                  max_length: 6
                  valid_chars: '^(0\.[1-9]|[1-9][0-9]*)(\.[0-9]|m?)$'
                  valid_chars_error: |
                    Valid CPU limit formats are</br>
                    - Plain Integer - eg. 1</br>
                    - Float - eg. 0.5</br>
                    - Milicpu - eg. 500m
                  default: "4000m"
                  required: true
              - variable: memory
                label: Memory
                description: Memory limit for MinIO.
                schema:
                  type: string
                  max_length: 12
                  valid_chars: '^[1-9][0-9]*([EPTGMK]i?|e[0-9]+)?$'
                  valid_chars_error: |
                    Valid Memory limit formats are</br>
                    - Suffixed with E/P/T/G/M/K - eg. 1G</br>
                    - Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi</br>
                    - Plain Integer in bytes - eg. 1024</br>
                    - Exponent - eg. 134e6
                  default: "8Gi"
                  required: true
