Skip to content

Commit acce068

Browse files
committed
add plan task and handle 304 response
1 parent 6a5987d commit acce068

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

runtime-manager-action/script.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,18 @@ def runtime_manager_run_self_hosted_deploy(request_data: dict, manifest: dict):
136136
url=url, body=request_data, headers=HEADERS, timeout=TIMEOUT
137137
)
138138

139-
if response.ok:
140-
# Parse the response and extract relevant data
141-
response_data = response.json()
142-
print(f"> Deploy successfully started:\n{json.dumps(response_data, indent=4)}")
143139

144-
# Save the response to the output log
145-
save_output(response_data)
140+
if response.status_code == 201:
141+
try:
142+
# Parse the response and extract relevant data
143+
response_data = response.json()
144+
print(f"> Deploy successfully started:\n{json.dumps(response_data, indent=4)}")
145+
146+
# Save the response to the output log
147+
save_output(response_data)
148+
except json.JSONDecodeError:
149+
print("> Error: Failed to parse JSON response.")
150+
exit(1)
146151
else:
147152
print(
148153
f"> Error: Failed to start self-hosted deploy run. Status: {response.status_code}"

script.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def rollback_deploy_run(run_action: RunAction):
4444
run_action("runtime-rollback-action")
4545
run_tasks("rollback-output.log", run_action)
4646

47-
4847
def run_tasks(file_tasks: str, run_action: RunAction):
4948
with open(file_tasks, "r") as file:
5049
data = json.loads(file.read().replace("'", '"'))
@@ -53,6 +52,7 @@ def run_tasks(file_tasks: str, run_action: RunAction):
5352
IAC_SELF_HOSTED=lambda **i: run_action("runtime-iac-action", **i),
5453
DEPLOY_SELF_HOSTED=lambda **i: run_action("runtime-deploy-action", **i),
5554
DESTROY_SELF_HOSTED=lambda **i: run_action("runtime-destroy-action", **i),
55+
PLAN=lambda **i: run_action("runtime-unified-action", **i),
5656
UNIFIED_IAC=lambda **i: run_action("runtime-unified-action", **i),
5757
UNIFIED_DEPLOY=lambda **i: run_action("runtime-unified-action", **i),
5858
UNIFIED_DESTROY=lambda **i: run_action("runtime-unified-action", **i),
@@ -63,8 +63,10 @@ def run_tasks(file_tasks: str, run_action: RunAction):
6363
runner = task_runners.get(task_type)
6464
if "UNIFIED" in task_type:
6565
runner and runner(run_id=data.get("runId"))
66+
elif "PLAN" == task_type:
67+
runner and runner(run_id=data.get("runId"))
6668
else:
67-
runner and runner(run_task_id=t["runTaskId"])
69+
runner and runner(run_task_id=t["runTaskId"])
6870

6971

7072
def run(metadata):

0 commit comments

Comments
 (0)