{{- if and .Values.runners.enabled .Values.runners.launcherConfig.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "n8n.fullname" . }}-runners-config
  labels:
    {{- include "n8n.labels" . | nindent 4 }}
    app.kubernetes.io/component: runners
data:
  n8n-task-runners.json: |
    {
      "task-runners": [
        {
          "runner-type": "javascript",
          "workdir": "/home/runner",
          "command": "/usr/local/bin/node",
          "args": [
            "--disallow-code-generation-from-strings",
            "--disable-proto=delete",
            "/opt/runners/task-runner-javascript/dist/start.js"
          ],
          "health-check-server-port": "5681",
          "allowed-env": {{ toJson .Values.runners.launcherConfig.jsAllowedEnv }},
          "env-overrides": {
            "NODE_FUNCTION_ALLOW_BUILTIN": "crypto",
            "NODE_FUNCTION_ALLOW_EXTERNAL": "moment",
            "N8N_RUNNERS_HEALTH_CHECK_SERVER_HOST": "0.0.0.0"
          }
        },
        {
          "runner-type": "python",
          "workdir": "/home/runner",
          "command": "/opt/runners/task-runner-python/.venv/bin/python",
          "args": ["-I", "-B", "-X", "disable_remote_debug", "-m", "src.main"],
          "health-check-server-port": "5682",
          "allowed-env": {{ toJson .Values.runners.launcherConfig.pythonAllowedEnv }},
          "env-overrides": {
            "N8N_RUNNERS_STDLIB_ALLOW": "",
            "N8N_RUNNERS_EXTERNAL_ALLOW": ""
          }
        }
      ]
    }
{{- end }}
