groups:
  - name: Zerotier Configuration
    description: Configure Zerotier
  - name: Network Configuration
    description: Configure Network for Zerotier
  - name: Resources Configuration
    description: Configure Resources for Zerotier

questions:
  - variable: zerotierConfig
    label: ""
    group: Zerotier Configuration
    schema:
      type: dict
      attrs:
        - variable: networks
          label: Networks
          description: The network(s) to join
          schema:
            type: list
            empty: false
            required: true
            min: 1
            default: []
            items:
              - variable: networkEntry
                label: Network
                schema:
                  type: string
                  required: true
        - variable: authToken
          label: Auth Token (API Key)
          description: |
            (Optional) The auth token for Zerotier.</br>
            Same as authtoken.secret.
          schema:
            type: string
            default: ""
            private: true
        - variable: identitySecret
          label: Identity Secret
          description: |
            (Optional) The identity secret for Zerotier.</br>
            Same as identity.secret.
          schema:
            type: string
            default: ""
            private: true
        - variable: identityPublic
          label: Identity Public
          description: |
            (Optional) The identity public for Zerotier.</br>
            Same as identity.public.
          schema:
            type: string
            default: ""
            private: true

        - variable: additionalEnvs
          label: Additional Environment Variables
          description: Configure additional environment variables for Zerotier.
          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: zerotierNetwork
    label: ""
    group: Network Configuration
    schema:
      type: dict
      attrs:
        - 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: resources
    group: Resources Configuration
    label: ""
    schema:
      type: dict
      attrs:
        - variable: limits
          label: Limits
          schema:
            type: dict
            attrs:
              - variable: cpu
                label: CPU
                description: CPU limit for Zerotier.
                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 Zerotier.
                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
