groups:
  - name: "Container Images"
    description: "Image to be used for container"
  - name: "Container Entrypoint"
    description: "Configuration of the executable that will be run when the container is started"
  - name: "Container Environment Variables"
    description: "Set the environment that will be visible to the container"
  - name: "Networking"
    description: "Configure networking for container"
  - name: "Storage"
    description: "Persist and share data that is separate from the lifecycle of the container"
  - name: "Plex Configuration"
    description: "Configure plex deployment"
  - name: "Workload Details"
    description: "Configure how workload should be deployed"
  - name: "Scaling/Upgrade Policy"
    description: "Configure how pods are replaced when configuration is upgraded"
  - name: "Restart Policy"
    description: "Configure when pod should be restarted in case of failure"
  - name: "Resource Reservation"
    description: "Specify resources to be allocated to workload"
  - name: "Advanced DNS Settings"
    description: "Configure DNS settings"

portals:
  web_portal:
    protocols:
      - "http"
    host:
      - "$node_ip"
    ports:
      - "$variable-plexServiceTCP.port"
    path: "/web"

questions:

  - variable: dnsConfig
    label: "DNS Configuration"
    group: "Advanced DNS Settings"
    schema:
      type: dict
      attrs:
        - variable: options
          label: "DNS Options"
          schema:
            type: list
            items:
              - variable: optionsEntry
                label: "Option Entry Configuration"
                schema:
                  type: dict
                  attrs:
                    - variable: name
                      label: "Option Name"
                      schema:
                        type: string
                        required: true
                    - variable: value
                      label: "Option Value"
                      schema:
                        type: string
                        required: true

  - variable: claimToken
    label: "Plex Claim Token"
    group: "Plex Configuration"
    description: "The claim token for the server to obtain a real server token. If not provided, server is will not be automatically logged in. If server is already logged in, this parameter is ignored. You can obtain a claim token to login your server to your plex account by visiting https://www.plex.tv/claim."
    schema:
      type: string
      default: ""

  - variable: hostNetwork
    label: "Configure Host Network"
    group: "Networking"
    schema:
      type: boolean
      default: false

  - variable: environmentVariables
    label: "Environment Variables for Plex"
    group: "Plex Configuration"
    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: timezone
    label: "Plex container timezone"
    group: "Plex Configuration"
    schema:
      type: string
      default: "Etc/UTC"
      $ref:
        - "definitions/timezone"

  # Update strategy
  - variable: updateStrategy
    description: "Upgrade Policy"
    label: "Update Strategy"
    group: "Scaling/Upgrade Policy"
    schema:
      type: string
      default: "Recreate"
      enum:
        - value: "RollingUpdate"
          description: "Create new pods and then kill old ones"
        - value: "Recreate"
          description: "Kill existing pods before creating new ones"

  # Port configuration
  - variable: plexServiceTCP
    label: "Configure Plex TCP Service"
    group: "Networking"
    schema:
      type: dict
      attrs:
        - variable: port
          label: "Port to expose for Plex UI"
          schema:
            type: int
            min: 9000
            max: 65535
            default: 32400

  # Specify GPU configuration
  - variable: gpuConfiguration
    label: "GPU Configuration"
    group: "Resource Reservation"
    schema:
      type: dict
      $ref:
        - "definitions/gpuConfiguration"
      attrs: []

  - variable: appVolumeMounts
    label: "Plex Storage"
    group: "Storage"
    schema:
      type: dict
      attrs:
        - variable: transcode
          label: "Transcode Volume"
          schema:
            type: dict
            attrs:
              - variable: datasetName
                label: "Plex Transcode Volume Name"
                schema:
                  type: string
                  $ref:
                    - "normalize/ixVolume"
                  show_if: [["hostPathEnabled", "=", false]]
                  default: "ix-plex_transcode"
                  hidden: true
                  editable: false
              - variable: mountPath
                label: "Plex Transcode Mount Path"
                description: "Path where the volume will be mounted inside the pod"
                schema:
                  type: path
                  hidden: true
                  editable: false
                  default: "/transcode"
              - variable: hostPathEnabled
                label: "Enable Host Path for Plex Transcode Volume"
                schema:
                  type: boolean
                  default: false
                  show_subquestions_if: true
                  subquestions:
                    - variable: hostPath
                      label: "Host Path for Plex Transcode Volume"
                      schema:
                        type: hostpath
                        required: true
        - variable: data
          label: "Data Volume"
          schema:
            type: dict
            attrs:
              - variable: datasetName
                label: "Plex Data Volume Name"
                schema:
                  type: string
                  $ref:
                    - "normalize/ixVolume"
                  show_if: [["hostPathEnabled", "=", false]]
                  default: "ix-plex_data"
                  editable: false
                  hidden: true
              - variable: mountPath
                label: "Plex Data Mount Path"
                description: "Path where the volume will be mounted inside the pod"
                schema:
                  type: path
                  hidden: true
                  editable: false
                  default: "/data"
              - variable: hostPathEnabled
                label: "Enable Host Path for Plex Data Volume"
                schema:
                  type: boolean
                  default: false
                  show_subquestions_if: true
                  subquestions:
                    - variable: hostPath
                      label: "Host Path for Plex Data Volume"
                      schema:
                        type: hostpath
                        required: true
        - variable: config
          label: "Config Volume"
          schema:
            type: dict
            attrs:
              - variable: datasetName
                label: "Plex Config Volume Name"
                schema:
                  type: string
                  $ref:
                    - "normalize/ixVolume"
                  show_if: [["hostPathEnabled", "=", false]]
                  default: "ix-plex_config"
                  editable: false
                  hidden: true
              - variable: mountPath
                label: "Plex Config Mount Path"
                description: "Path where the volume will be mounted inside the pod"
                schema:
                  type: path
                  editable: false
                  hidden: true
                  default: "/config"
              - variable: hostPathEnabled
                label: "Enable Host Path for Plex Config Volume"
                schema:
                  type: boolean
                  default: false
                  show_subquestions_if: true
                  subquestions:
                    - variable: hostPath
                      label: "Host Path for Plex Config Volume"
                      schema:
                        type: hostpath
                        required: true
        - variable: shared
          label: "Shared Volume"
          schema:
            type: dict
            hidden: true
            attrs:
              - variable: emptyDir
                label: "Temporary Volume"
                schema:
                  type: boolean
                  default: true
                  editable: false
              - variable: mountPath
                label: "Plex Shared Mount Path"
                description: "Path where the volume will be mounted inside the pod"
                schema:
                  type: path
                  editable: false
                  default: "/shared"
        - variable: shared-logs
          label: "Shared Logs Volume"
          schema:
            type: dict
            hidden: true
            attrs:
              - variable: emptyDir
                label: "Temporary Volume"
                schema:
                  type: boolean
                  default: true
                  editable: false
              - variable: mountPath
                label: "Plex Shared Logs Mount Path"
                description: "Path where the volume will be mounted inside the pod"
                schema:
                  type: path
                  editable: false
                  default: "/config/Library/Application Support/Plex Media Server/Logs"

  - variable: extraAppVolumeMounts
    label: "Plex Extra Host Path Volumes"
    group: "Storage"
    schema:
      type: list
      items:
        - variable: extraAppVolume
          label: "Plex Host Path Volume"
          description: "Add an extra host path volume for plex 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
