Skip to content

Commit

Permalink
fix: workflow_template job url was incorrect (#577)
Browse files Browse the repository at this point in the history
https://issues.redhat.com/browse/AAP-15939
The job ui url for workflow template was incorrect it was missing
workflow in the path.

e.g. https://<controller_ip>/#/jobs/workflow/3822/details
  • Loading branch information
mkanoor authored Sep 11, 2023
1 parent 97cad8c commit 8a1c812
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions ansible_rulebook/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from functools import partial
from pprint import pprint
from typing import Callable, Dict, List, Optional, Union
from urllib.parse import urljoin

import ansible_runner
import dpath
Expand Down Expand Up @@ -835,7 +836,7 @@ async def run_job_template(
rule_uuid=source_rule_uuid,
status=controller_job["status"],
run_at=controller_job["created"],
url=_controller_job_url(controller_job),
url=_controller_job_url(controller_job, "jobs"),
matching_events=_get_events(variables),
rule_run_at=rule_run_at,
)
Expand Down Expand Up @@ -954,7 +955,7 @@ async def run_workflow_template(
rule_uuid=source_rule_uuid,
status=controller_job["status"],
run_at=controller_job["created"],
url=_controller_job_url(controller_job),
url=_controller_job_url(controller_job, "jobs/workflow"),
matching_events=_get_events(variables),
rule_run_at=rule_run_at,
)
Expand Down Expand Up @@ -1084,9 +1085,10 @@ def _embellish_internal_event(event: Dict, method_name: str) -> Dict:
)


def _controller_job_url(data: dict) -> str:
def _controller_job_url(data: dict, prefix: str) -> str:
if "id" in data:
return f"{job_template_runner.host}/#/jobs/{data['id']}/details"
href_slug = f"/#/{prefix}/{data['id']}/details"
return urljoin(job_template_runner.host, href_slug)
return ""


Expand Down
2 changes: 1 addition & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2303,7 +2303,7 @@ async def test_79_workflow_job_template():
status="successful", id=945, created="dummy", artifacts=dict(a=1)
)
job_template_runner.host = "https://examples.com"
job_url = "https://examples.com/#/jobs/945/details"
job_url = "https://examples.com/#/jobs/workflow/945/details"
with SourceTask(rs.sources[0], "sources", {}, queue):
with patch(
"ansible_rulebook.builtin.job_template_runner."
Expand Down

0 comments on commit 8a1c812

Please sign in to comment.