From ace9df52cc8b2a484ad5525e350b7fdb3be357d6 Mon Sep 17 00:00:00 2001 From: "Philipp Heil (zkdev)" Date: Thu, 19 Dec 2024 16:15:46 +0100 Subject: [PATCH] Lookup job-mapping in multiple sets for WHD PR processing Necessary for cases where a single WHD instance should handle resource triggers on multiple Concourse instances. --- whd/pull_request.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/whd/pull_request.py b/whd/pull_request.py index 77fc4fb9f..e5468795e 100644 --- a/whd/pull_request.py +++ b/whd/pull_request.py @@ -335,10 +335,23 @@ def set_pr_labels( repo = pr_event.repository() repository_path = repo.repository_path() owner, _ = repository_path.split('/') - job_mapping_set: model.concourse.JobMappingSet = cfg_set.job_mapping() - job_mapping = job_mapping_set.job_mapping_for_repo_url( - repo.repository_url(), cfg_set - ) + + for jms in cfg_set._cfg_elements('job_mapping'): + jms: model.concourse.JobMappingSet + + try: + job_mapping = jms.job_mapping_for_repo_url( + repo_url=repo.repository_url(), + cfg_set=cfg_set, + ) + except ValueError: + job_mapping = None + + if job_mapping: + break + + else: + raise ValueError(f'no job-mapping found for {repo.repository_url()}') if pr_event.action() is PullRequestAction.OPENED: if _should_label(