From defeaf5aff09a4fb2465f02ce79e4e200e2bd0bb Mon Sep 17 00:00:00 2001 From: Mateusz Leonowicz Date: Wed, 11 Sep 2024 14:18:35 +0200 Subject: [PATCH] CI: Remove obsolete script for docker version extraction Signed-off-by: Mateusz Leonowicz --- .github/scripts/extract_docker_revision.py | 65 ---------------------- 1 file changed, 65 deletions(-) delete mode 100644 .github/scripts/extract_docker_revision.py diff --git a/.github/scripts/extract_docker_revision.py b/.github/scripts/extract_docker_revision.py deleted file mode 100644 index 603587f..0000000 --- a/.github/scripts/extract_docker_revision.py +++ /dev/null @@ -1,65 +0,0 @@ -import json -from pathlib import Path -import sys -from typing import Optional - - -def find_docker_orfs(data: dict) -> Optional[dict]: - """ - Recursively search for the 'docker_orfs' configuration in - the provided JSON data. - - Parameters - ---------- - data : dict - The JSON data to search for the 'docker_orfs' configuration. - - Returns - ------- - Optional[dict] - The 'docker_orfs' configuration if found, otherwise None. - """ - if isinstance(data, dict): - if 'docker_orfs' in data: - return data['docker_orfs'] - for key, value in data.items(): - result = find_docker_orfs(value) - if result: - return result - elif isinstance(data, list): - for item in data: - result = find_docker_orfs(item) - if result: - return result - return None - - -if __name__ == "__main__": - if len(sys.argv) < 2 or not Path(sys.argv[1]).exists(): - print(f"Usage: {sys.argv[0]} ") - exit(1) - - with open(sys.argv[1], 'r') as file: - try: - data = json.load(file) - except json.JSONDecodeError: - print(f"Unable to parse JSON data from {sys.argv[1]}") - exit(1) - - docker_orfs = find_docker_orfs(data) - if docker_orfs is None or docker_orfs.get('attributes', None) is None: - print("Unable to find 'docker_orfs' configuration in the provided file") # noqa: E501 - exit(1) - - docker_tag = docker_orfs.get('attributes').get('image', None) - docker_sha256 = docker_orfs.get('attributes').get('sha256', None) - - if docker_tag is None or docker_sha256 is None: - print("Unable to find Docker tag or SHA256 in the provided file.") - exit(1) - - print(json.dumps({ - 'image': f"{docker_tag}@sha256:{docker_sha256}", - 'tag': docker_tag, - 'sha256': docker_sha256 - }))