Skip to content

Commit

Permalink
platforms results in tekton results is dict now
Browse files Browse the repository at this point in the history
* STONEBLD-1228

Signed-off-by: Robert Cerven <[email protected]>
  • Loading branch information
rcerven committed May 9, 2023
1 parent d44dc2d commit b4bbbdc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
11 changes: 2 additions & 9 deletions osbs/tekton.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,15 +600,8 @@ def get_final_platforms(self):
return None

if 'platforms_result' in task_results['binary-container-prebuild']:
raw_result = task_results['binary-container-prebuild']['platforms_result']

try:
value = json.loads(raw_result)
# TypeError is returned when value is list
except (json.JSONDecodeError, TypeError):
value = raw_result

return value
platforms = json.loads(task_results['binary-container-prebuild']['platforms_result'])
return platforms['platforms']

return None

Expand Down
3 changes: 1 addition & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,8 +1056,7 @@ def test_get_build_error_message(self, osbs_binary):
assert error_msg == osbs_binary.get_build_error_message('run_name')

@pytest.mark.parametrize('platforms_result', [
'["x86_64", "ppc64le"]',
["x86_64", "ppc64le"],
'{"platforms": ["x86_64", "ppc64le"]}',
])
def test_get_final_platforms(self, osbs_binary, platforms_result):
taskruns = {'task1': {'status': {'conditions': [{'reason': 'Succeeded'}],
Expand Down
5 changes: 3 additions & 2 deletions tests/test_tekton.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ def test_get_error_message(self, pipeline_run, get_json, error_lines):
'status': {'startTime': '2022-04-26T15:58:42Z',
'conditions': [{'reason': 'Succeeded'}],
'taskResults': [{'name': 'platforms_result',
'value': []}]},
'value': '{"platforms": []}'}]},
}
}}},
[]),
Expand All @@ -907,7 +907,8 @@ def test_get_error_message(self, pipeline_run, get_json, error_lines):
'status': {'startTime': '2022-04-26T15:58:42Z',
'conditions': [{'reason': 'Succeeded'}],
'taskResults': [{'name': 'platforms_result',
'value': ["x86_64", "ppc64le"]}]},
'value': '{"platforms": '
'["x86_64", "ppc64le"]}'}]},
}
}}},
["x86_64", "ppc64le"]),
Expand Down

0 comments on commit b4bbbdc

Please sign in to comment.