Skip to content

Commit 80c1239

Browse files
committed
fix: fetch final_platfrom from multiple tasks
With Hemeto introduction to OSBS, flatforms are provided by binary-container-init task Signed-off-by: Martin Basti <mbasti@redhat.com>
1 parent b9809c5 commit 80c1239

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

osbs/tekton.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,15 @@ def get_final_platforms(self):
570570

571571
task_results = self.get_task_results()
572572

573-
if 'binary-container-prebuild' not in task_results:
574-
return None
575-
576-
if 'platforms_result' in task_results['binary-container-prebuild']:
577-
platforms = json.loads(task_results['binary-container-prebuild']['platforms_result'])
578-
return platforms['platforms']
573+
if 'binary-container-prebuild' in task_results:
574+
if 'platforms_result' in task_results['binary-container-prebuild']:
575+
platforms = json.loads(task_results['binary-container-prebuild']['platforms_result'])
576+
return platforms['platforms']
577+
578+
if 'binary-container-init' in task_results:
579+
if 'platforms_result' in task_results['binary-container-init']:
580+
platforms = json.loads(task_results['binary-container-init']['platforms_result'])
581+
return platforms['platforms']
579582

580583
return None
581584

tests/test_api.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,15 +1066,19 @@ def test_get_build_error_message(self, osbs_binary):
10661066
@pytest.mark.parametrize('platforms_result', [
10671067
'{"platforms": ["x86_64", "ppc64le"]}',
10681068
])
1069-
def test_get_final_platforms(self, osbs_binary, platforms_result):
1069+
@pytest.mark.parmetrize('task', [
1070+
'binary-container-prebuild',
1071+
'binary-container-init',
1072+
])
1073+
def test_get_final_platforms(self, osbs_binary, task, platforms_result):
10701074
taskstatus = {'conditions': [{'reason': 'Succeeded'}],
10711075
'taskResults': [{'name': 'platforms_result',
10721076
'value': platforms_result}],
10731077
'startTime': '2022-04-26T15:58:42Z'}
10741078
childrefs = [{'name': 'task_run_name', 'kind': 'TaskRun'}]
10751079

10761080
resp1 = {'metadata': {'name': 'run_name'}, 'status': {'childReferences': childrefs}}
1077-
resp2 = {'metadata': {'labels': {'tekton.dev/pipelineTask': 'binary-container-prebuild'}},
1081+
resp2 = {'metadata': {'labels': {'tekton.dev/pipelineTask': task}},
10781082
'status': taskstatus}
10791083

10801084
flexmock(PipelineRun).should_receive('get_info').and_return(resp1)

0 commit comments

Comments
 (0)