deploy.py: 409 Conflict Handling (POST -> PATCH bei existierenden ENVs)
This commit is contained in:
+10
-1
@@ -329,13 +329,22 @@ def deploy_worker(client: CoolifyClient, skip_build: bool = False) -> StepResult
|
|||||||
# Step 3: Set ENV variables via Coolify API (Coolify auto-generates .env)
|
# Step 3: Set ENV variables via Coolify API (Coolify auto-generates .env)
|
||||||
print(" Setting ENV variables via Coolify API...")
|
print(" Setting ENV variables via Coolify API...")
|
||||||
for env in WORKER_ENVS:
|
for env in WORKER_ENVS:
|
||||||
# POST creates or updates the ENV variable
|
# POST creates the ENV variable; if it already exists (409),
|
||||||
|
# PATCH updates it
|
||||||
resp = httpx.post(
|
resp = httpx.post(
|
||||||
f"{client.base_url}/api/v1/services/{WORKER_UUID}/envs",
|
f"{client.base_url}/api/v1/services/{WORKER_UUID}/envs",
|
||||||
headers=client.headers,
|
headers=client.headers,
|
||||||
json=env,
|
json=env,
|
||||||
timeout=30,
|
timeout=30,
|
||||||
)
|
)
|
||||||
|
if resp.status_code == 409:
|
||||||
|
# Already exists — update via PATCH
|
||||||
|
resp = httpx.patch(
|
||||||
|
f"{client.base_url}/api/v1/services/{WORKER_UUID}/envs",
|
||||||
|
headers=client.headers,
|
||||||
|
json=env,
|
||||||
|
timeout=30,
|
||||||
|
)
|
||||||
if resp.status_code not in (200, 201):
|
if resp.status_code not in (200, 201):
|
||||||
print(f" Warning: could not set ENV {env['key']} ({resp.status_code})")
|
print(f" Warning: could not set ENV {env['key']} ({resp.status_code})")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user