Skip to content

Commit

Permalink
add plan task and handle 304 response
Browse files Browse the repository at this point in the history
  • Loading branch information
eliezer-zup committed Nov 28, 2024
1 parent 6a5987d commit acce068
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 11 additions & 6 deletions runtime-manager-action/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,18 @@ def runtime_manager_run_self_hosted_deploy(request_data: dict, manifest: dict):
url=url, body=request_data, headers=HEADERS, timeout=TIMEOUT
)

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

# Save the response to the output log
save_output(response_data)
if response.status_code == 201:
try:
# Parse the response and extract relevant data
response_data = response.json()
print(f"> Deploy successfully started:\n{json.dumps(response_data, indent=4)}")

# Save the response to the output log
save_output(response_data)
except json.JSONDecodeError:
print("> Error: Failed to parse JSON response.")
exit(1)
else:
print(
f"> Error: Failed to start self-hosted deploy run. Status: {response.status_code}"
Expand Down
6 changes: 4 additions & 2 deletions script.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def rollback_deploy_run(run_action: RunAction):
run_action("runtime-rollback-action")
run_tasks("rollback-output.log", run_action)


def run_tasks(file_tasks: str, run_action: RunAction):
with open(file_tasks, "r") as file:
data = json.loads(file.read().replace("'", '"'))
Expand All @@ -53,6 +52,7 @@ def run_tasks(file_tasks: str, run_action: RunAction):
IAC_SELF_HOSTED=lambda **i: run_action("runtime-iac-action", **i),
DEPLOY_SELF_HOSTED=lambda **i: run_action("runtime-deploy-action", **i),
DESTROY_SELF_HOSTED=lambda **i: run_action("runtime-destroy-action", **i),
PLAN=lambda **i: run_action("runtime-unified-action", **i),
UNIFIED_IAC=lambda **i: run_action("runtime-unified-action", **i),
UNIFIED_DEPLOY=lambda **i: run_action("runtime-unified-action", **i),
UNIFIED_DESTROY=lambda **i: run_action("runtime-unified-action", **i),
Expand All @@ -63,8 +63,10 @@ def run_tasks(file_tasks: str, run_action: RunAction):
runner = task_runners.get(task_type)
if "UNIFIED" in task_type:
runner and runner(run_id=data.get("runId"))
elif "PLAN" == task_type:
runner and runner(run_id=data.get("runId"))
else:
runner and runner(run_task_id=t["runTaskId"])
runner and runner(run_task_id=t["runTaskId"])


def run(metadata):
Expand Down

0 comments on commit acce068

Please sign in to comment.