From 1d2c4565586db662edb13027981ee26415f17ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 28 Jun 2024 11:39:33 +0200 Subject: [PATCH] Versions: Fix version for Docker --- .../module/versions/__init__.py | 12 ++-- tests/test_module_versions.py | 60 +++++++++++++++++++ 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/github_app_geo_project/module/versions/__init__.py b/github_app_geo_project/module/versions/__init__.py index 7c459915d9b..5a41a9b3b57 100644 --- a/github_app_geo_project/module/versions/__init__.py +++ b/github_app_geo_project/module/versions/__init__.py @@ -728,10 +728,14 @@ def _build_internal_dependencies( continue dependency_package_data = dependency_data.by_package[full_dependency_name] dependency_minor = _canonical_minor_version(datasource_name, dependency_version) - support = dependency_package_data.status_by_version.get( - dependency_minor, - "Unsupported", - ) + if datasource_name == "docker": + assert len(dependency_package_data.status_by_version) == 1 + support = list(dependency_package_data.status_by_version.values())[0] + else: + support = dependency_package_data.status_by_version.get( + dependency_minor, + "Unsupported", + ) clean_dependency_version = _clean_version(dependency_version) dependencies_branch.forward.append( _Dependency( diff --git a/tests/test_module_versions.py b/tests/test_module_versions.py index 3db8062ca3f..353d0dfc9ec 100644 --- a/tests/test_module_versions.py +++ b/tests/test_module_versions.py @@ -289,6 +289,66 @@ def test_get_transversal_dashboard_repo_forward_docker() -> None: ) +def test_get_transversal_dashboard_repo_forward_docker_2() -> None: + versions = Versions() + context = Mock() + context.status = _TransversalStatus( + repositories={ + "camptocamp/test": _TransversalStatusRepo( + versions={ + "1.0": _TransversalStatusVersion( + support="27/06/2027", + dependencies_by_datasource={ + "docker": _TransversalStatusNameInDatasource( + versions_by_names={ + "ghcr.io/osgeo/gdal": _TransversalStatusVersions( + versions=["ubuntu-small-3.8.5"] + ), + } + ) + }, + ) + }, + ), + "camptocamp/other": _TransversalStatusRepo( + versions={ + "2.0": _TransversalStatusVersion( + support="Best effort", + names_by_datasource={ + "docker": _TransversalStatusNameByDatasource( + names=[ + "osgeo/gdal:ubuntu-small-3.8.5", + "ghcr.io/osgeo/gdal:ubuntu-small-3.8.5", + ] + ) + }, + ) + }, + ), + } + ) + context.params = {"repository": "camptocamp/test"} + output = versions.get_transversal_dashboard(context) + assert output.data["dependencies_branches"] == _DependenciesBranches( + by_branch={ + "1.0": _Dependencies( + support="27/06/2027", + forward=[ + _Dependency( + name="ghcr.io/osgeo/gdal", + datasource="docker", + version="ubuntu-small-3.8.5", + support="Best effort", + color="--bs-danger", + repo="camptocamp/other", + ) + ], + reverse=[], + ) + } + ) + + def test_get_transversal_dashboard_repo_forward_docker_double() -> None: versions = Versions() context = Mock()