一键导入
coder-template-push
Upload a Coder template via API — pack tar, upload file, create version with variable overrides, publish or create workspace
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Upload a Coder template via API — pack tar, upload file, create version with variable overrides, publish or create workspace
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Add or remove movies/shows from a named Plex collection — search library by title, resolve ratingKey, PUT into collection by name
Find a good torrent for a specific movie and add it to Radarr — search releases, evaluate seeds/quality, confirm with user, grab
Find a good torrent for a specific TV series/season and add it to Sonarr — search Prowlarr, evaluate seeds/quality, confirm with user, enable monitoring, grab
Debug why Sonarr/Radarr can't find sources — check indexer backoffs, search results, Prowlarr health
Debug a failing Coder workspace build — check HelmRelease, pod state, and build logs via API
Add a new Helm-based application to prod-gen2 (or non-prod-gen2) via Flux — namespace, HelmRepository, HelmRelease, HTTPRoute, kustomization overlay
| name | coder-template-push |
| description | Upload a Coder template via API — pack tar, upload file, create version with variable overrides, publish or create workspace |
Use when editing Coder template Terraform files and needing to publish without the Coder CLI.
ORG_ID=8aa3e329-80eb-4a8c-a674-2125c4788dc2
BASE=https://coder.local.abbottland.io
TOKEN=$(grep CODER_TOKEN /workspaces/home-kubernetes/.env | cut -d= -f2)
Known template IDs:
kubernetes-devcontainer: 9ee07212-25ee-4288-a1f3-1171bc89ff75kubernetes-ubuntu: 06e4058e-58f5-4534-894a-9181c7b9d945tar -cf /tmp/template.tar -C /tmp/my-template main.tf
# Include README.md if present
FILE_ID=$(curl -s -X POST \
-H "Coder-Session-Token: $TOKEN" \
-H "Content-Type: application/x-tar" \
--data-binary @/tmp/template.tar \
"$BASE/api/v2/files?content_type=application/x-tar" | python3 -c "import sys,json; print(json.load(sys.stdin)['hash'])")
echo "File: $FILE_ID"
For an existing template (new version):
VERSION=$(curl -s -X POST \
-H "Coder-Session-Token: $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"storage_method\": \"file\",
\"file_id\": \"$FILE_ID\",
\"provisioner\": \"terraform\",
\"template_id\": \"<template_id>\",
\"message\": \"<change description>\",
\"user_variable_values\": [
{\"name\": \"namespace\", \"value\": \"coder-workspaces\"},
{\"name\": \"use_kubeconfig\", \"value\": \"false\"}
]
}" \
"$BASE/api/v2/organizations/$ORG_ID/templateversions") && \
echo "$VERSION" | python3 -c "import sys,json; v=json.load(sys.stdin); print('Version:', v['id'], '| Status:', v['job']['status'])"
For a new template (no template_id): omit the template_id field, then create the template separately (Step 5).
VERSION_ID=<from step 3>
until curl -s -H "Coder-Session-Token: $TOKEN" \
"$BASE/api/v2/templateversions/$VERSION_ID" | \
python3 -c "import sys,json; v=json.load(sys.stdin); s=v['job']['status']; print(s); exit(0 if s in ('succeeded','failed') else 1)"; do sleep 3; done
Verify variables resolved correctly:
curl -s -H "Coder-Session-Token: $TOKEN" \
"$BASE/api/v2/templateversions/$VERSION_ID/variables" | \
python3 -c "import sys,json; [print(v['name'], '->', v['value']) for v in json.load(sys.stdin)]"
curl -s -X POST \
-H "Coder-Session-Token: $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"name\": \"kubernetes-ubuntu\",
\"display_name\": \"Kubernetes (Ubuntu)\",
\"description\": \"Ubuntu workspace in Kubernetes.\",
\"icon\": \"/icon/k8s.png\",
\"template_version_id\": \"$VERSION_ID\"
}" \
"$BASE/api/v2/organizations/$ORG_ID/templates" | \
python3 -c "import sys,json; v=json.load(sys.stdin); print('Template:', v.get('id'), v.get('name'))"
curl -s -X PATCH \
-H "Coder-Session-Token: $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"id\": \"$VERSION_ID\"}" \
"$BASE/api/v2/templates/<template_id>/versions" | python3 -c "import sys,json; print(json.load(sys.stdin)['message'])"
Note:
PATCH /templates/:idwithactive_version_idbody does NOT work. UsePATCH /templates/:id/versionswith{"id": "..."}instead.
curl -s -X POST \
-H "Coder-Session-Token: $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"name\": \"<workspace-name>\",
\"template_version_id\": \"$VERSION_ID\",
\"rich_parameter_values\": [
{\"name\": \"repo\", \"value\": \"owner/repo\"}
]
}" \
"$BASE/api/v2/organizations/$ORG_ID/members/me/workspaces" | \
python3 -c "import sys,json; v=json.load(sys.stdin); b=v.get('latest_build',{}); print('Workspace:', v.get('id')); print('Build:', b.get('id'))"
user_variable_values must be set at version creation — cannot be patched after. If wrong, create a new version.PATCH /templates/:id with active_version_id silently ignores the change if the version was created without user_variable_values set correctly.file_id returned from upload is a UUID hash — reuse it for multiple version attempts.