Skip to content

Commit e278c53

Browse files
committed
Store ocp version into file
The previous solution used a script stdout to parse json output. Unfortunately log messages produced by the script added new lines into output and output was no longer valid json. This commit stores the ocp version json into separate file and read metadata from the file instead of from script stdout/stderr. JIRA: ISV-2820
1 parent 74667bd commit e278c53

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

ansible/roles/operator-pipeline/templates/openshift/tasks/get-supported-versions.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ spec:
3232
set -xe
3333
3434
ORGANIZATION=$(cat config.yaml | yq -r '.organization')
35-
VERSION_INFO=$(ocp-version-info $(params.bundle_path) $ORGANIZATION)
35+
OCP_VERSIONS_OUTPUT_FILE="./ocp_versions.json"
36+
ocp-version-info \
37+
--output-file $OCP_VERSIONS_OUTPUT_FILE \
38+
$(params.bundle_path) \
39+
$ORGANIZATION
40+
41+
VERSION_INFO=$(cat $OCP_VERSIONS_OUTPUT_FILE)
3642
echo $VERSION_INFO | jq
3743
3844
echo $VERSION_INFO \

operator-pipeline-images/operatorcert/entrypoints/ocp_version_info.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def setup_argparser() -> argparse.ArgumentParser: # pragma: no cover
2525
default="https://catalog.redhat.com/api/containers/",
2626
help="Base URL for Pyxis container metadata API",
2727
)
28+
parser.add_argument(
29+
"--output-file",
30+
help="Path to a json file where ocp version will be stored",
31+
)
2832
parser.add_argument("--verbose", action="store_true", help="Verbose output")
2933

3034
return parser
@@ -39,8 +43,13 @@ def main() -> None:
3943

4044
bundle_path = pathlib.Path(args.bundle_path)
4145
version_info = ocp_version_info(bundle_path, args.pyxis_url, args.organization)
46+
4247
LOGGER.info(json.dumps(version_info))
4348

49+
if args.output_file:
50+
with open(args.output_file, "w") as output_file:
51+
json.dump(version_info, output_file)
52+
4453

4554
if __name__ == "__main__": # pragma: no cover
4655
main()

0 commit comments

Comments
 (0)