groups:
  - name: Vaultwarden Configuration
    description: Configure Vaultwarden
  - name: User and Group Configuration
    description: Configure User and Group for Vaultwarden
  - name: Network Configuration
    description: Configure Network for Vaultwarden
  - name: Storage Configuration
    description: Configure Storage for Vaultwarden
  - name: Resources Configuration
    description: Configure Resources for Vaultwarden

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"
  admin_portal:
    protocols:
      - "$kubernetes-resource_configmap_portal_protocol"
    host:
      - "$kubernetes-resource_configmap_portal_host"
    ports:
      - "$kubernetes-resource_configmap_portal_port"
    path: "$kubernetes-resource_configmap_portal_admin_path"

questions:
  - variable: vaultwardenConfig
    label: ""
    group: Vaultwarden Configuration
    schema:
      type: dict
      attrs:
        - variable: adminToken
          label: Admin Token
          description: Setting this, will enable the admin portal
          schema:
            type: string
            private: true
            default: ""
        - variable: additionalEnvs
          label: Additional Environment Variables
          description: Configure additional environment variables for Vaultwarden.
          schema:
            type: list
            default: []
            items:
              - variable: env
                label: Environment Variable
                schema:
                  type: dict
                  attrs:
                    - variable: name
                      label: Name
                      schema:
                        type: string
                        required: true
                    - variable: value
                      label: Value
                      schema:
                        type: string
                        required: true

  - variable: vaultwardenRunAs
    label: ""
    group: User and Group Configuration
    schema:
      type: dict
      attrs:
        - variable: user
          label: User ID
          description: The user id that Vaultwarden will run as.
          schema:
            type: int
            min: 568
            default: 568
            required: true
        - variable: group
          label: Group ID
          description: The group id that Vaultwarden will run as.
          schema:
            type: int
            min: 568
            default: 568
            required: true

  - variable: vaultwardenNetwork
    label: ""
    group: Network Configuration
    schema:
      type: dict
      attrs:
        - variable: webPort
          label: Web Port
          description: The port for the Vaultwarden Web UI.
          schema:
            type: int
            default: 30032
            min: 9000
            max: 65535
            required: true
        - variable: wsEnabled
          label: Enable Websocket
          schema:
            type: boolean
            default: true
        - variable: wsPort
          label: Websocket Port
          description: The port for the Vaultwarden Websocket.
          schema:
            type: int
            show_if: [["wsEnabled", "=", true]]
            default: 30033
            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: false
        - variable: domain
          label: Domain
          description: |
            The domain to use for Vaultwarden </br>
            Format is: https://sub.domain.tld:port
          schema:
            type: string
            default: ""
        - variable: certificateID
          label: Certificate
          description: |
            The certificate to use for Vaultwarden </br>
            Using the Rocket method for TLS setup is NOT recommended </br>
            Prefer a reverse proxy with a valid certificate </br>
          schema:
            type: int
            "null": true
            $ref:
              - "definitions/certificate"

  - variable: vaultwardenStorage
    label: ""
    group: Storage Configuration
    schema:
      type: dict
      attrs:
        - variable: data
          label: Vaultwarden Data Storage
          description: The path to store Vaultwarden attachments, icons, etc.
          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
                  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: datasetName
                label: Dataset Name
                schema:
                  type: string
                  show_if: [["type", "=", "ixVolume"]]
                  required: true
                  hidden: true
                  immutable: true
                  default: data
                  $ref:
                    - "normalize/ixVolume"
              - variable: hostPath
                label: Host Path
                schema:
                  type: hostpath
                  show_if: [["type", "=", "hostPath"]]
                  immutable: true
                  required: true
        - variable: pgData
          label: Vaultwarden Postgres Data Storage
          description: The path to store Vaultwarden Postgres Data.
          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
                  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: datasetName
                label: Dataset Name
                schema:
                  type: string
                  show_if: [["type", "=", "ixVolume"]]
                  required: true
                  hidden: true
                  immutable: true
                  default: pgData
                  $ref:
                    - "normalize/ixVolume"
              - variable: hostPath
                label: Host Path
                schema:
                  type: hostpath
                  show_if: [["type", "=", "hostPath"]]
                  immutable: true
                  required: true
        - variable: pgBackup
          label: Vaultwarden Postgres Backup Storage
          description: The path to store Vaultwarden Postgres Backup.
          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
                  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: datasetName
                label: Dataset Name
                schema:
                  type: string
                  show_if: [["type", "=", "ixVolume"]]
                  required: true
                  hidden: true
                  immutable: true
                  default: pgBackup
                  $ref:
                    - "normalize/ixVolume"
              - variable: hostPath
                label: Host Path
                schema:
                  type: hostpath
                  show_if: [["type", "=", "hostPath"]]
                  immutable: true
                  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 Vaultwarden.
                schema:
                  type: string
                  default: 4000m
                  required: true
              - variable: memory
                label: Memory
                description: Memory limit for Vaultwarden.
                schema:
                  type: string
                  default: 8Gi
                  required: true
