From 090243645f04a16d62e6330a169c5c0ca9c2c0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Thu, 23 Mar 2023 09:28:36 +0100 Subject: [PATCH] More strict dpkg file found check --- c2cciutils/lib/docker.py | 9 ++++++--- c2cciutils/scripts/docker_versions_gen.py | 2 +- c2cciutils/scripts/publish.py | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/c2cciutils/lib/docker.py b/c2cciutils/lib/docker.py index edb24fa5a..e20c1e291 100644 --- a/c2cciutils/lib/docker.py +++ b/c2cciutils/lib/docker.py @@ -95,14 +95,17 @@ def get_dpkg_packages_versions( return True, {f"{prefix}{k}": v for k, v in package_version.items()} -def get_versions_config() -> Dict[str, Dict[str, str]]: +def get_versions_config() -> Tuple[Dict[str, Dict[str, str]], bool]: """ Get the versions from the config file. """ if os.path.exists("ci/dpkg-versions.yaml"): with open("ci/dpkg-versions.yaml", "r", encoding="utf-8") as versions_file: - return cast(Dict[str, Dict[str, str]], yaml.load(versions_file.read(), Loader=yaml.SafeLoader)) - return {} + return ( + cast(Dict[str, Dict[str, str]], yaml.load(versions_file.read(), Loader=yaml.SafeLoader)), + True, + ) + return {}, False def check_versions( diff --git a/c2cciutils/scripts/docker_versions_gen.py b/c2cciutils/scripts/docker_versions_gen.py index 13b47774c..a41f3356c 100644 --- a/c2cciutils/scripts/docker_versions_gen.py +++ b/c2cciutils/scripts/docker_versions_gen.py @@ -16,7 +16,7 @@ def main() -> None: argparser.add_argument("images", help="The image to check", nargs="+") args = argparser.parse_args() - versions_config = c2cciutils.lib.docker.get_versions_config() + versions_config, _ = c2cciutils.lib.docker.get_versions_config() for image in args.images: _, versions_image = c2cciutils.lib.docker.get_dpkg_packages_versions( diff --git a/c2cciutils/scripts/publish.py b/c2cciutils/scripts/publish.py index 85263ef52..0afc62650 100644 --- a/c2cciutils/scripts/publish.py +++ b/c2cciutils/scripts/publish.py @@ -347,9 +347,9 @@ def main() -> None: print("::endgroup::") print("::error::With error") - versions_config = c2cciutils.lib.docker.get_versions_config() + versions_config, dpkg_config_found = c2cciutils.lib.docker.get_versions_config() dpkg_success = True - for image in images_src and versions_config: + for image in images_src: dpkg_success &= c2cciutils.lib.docker.check_versions(versions_config.get(image, {}), image) if not dpkg_success: @@ -361,7 +361,7 @@ def main() -> None: print("Current versions of the Debian packages in Docker images:") print(yaml.dump(current_versions_in_images, Dumper=yaml.SafeDumper, default_flow_style=False)) - if versions_config: + if dpkg_config_found: success = False helm_config = cast(