Skip to content

Commit

Permalink
cachi2: support empty pkg_manager
Browse files Browse the repository at this point in the history
Empty package manager (not defined) should deafult to gomod, to keep
compatibility in behavior with Cachito

STONEBLD-2921

Signed-off-by: Martin Basti <mbasti@redhat.com>
  • Loading branch information
MartinBasti committed Oct 31, 2024
1 parent 030e69a commit f95ba9b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion atomic_reactor/utils/cachi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def remote_source_to_cachi2(remote_source: Dict[str, Any]) -> Dict[str, Any]:
)
cachi2_packages = []

for pkg_manager in remote_source["pkg_managers"]:
pkg_managers = remote_source.get("pkg_managers")
if pkg_managers is None:
# Cachito behavior, missing pkg_managers means to use gomod
pkg_managers = ["gomod"]

for pkg_manager in pkg_managers:
if pkg_manager in removed_pkg_managers:
continue

Expand Down
5 changes: 5 additions & 0 deletions tests/utils/test_cachi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
{"flags": [], "packages": [{"path": ".", "type": "bundler"}]},
id="pkg_rubygems_to_bundler",
),
pytest.param(
{},
{"flags": [], "packages": [{"path": ".", "type": "gomod"}]},
id="pkg_manager_missing",
),
pytest.param(
{"pkg_managers": ["gomod"], "packages": {"gomod": [{"path": "operator"}]}},
{"flags": [], "packages": [{"path": "operator", "type": "gomod"}]},
Expand Down

0 comments on commit f95ba9b

Please sign in to comment.