Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cachi2: fix pkg_managers opts #2124

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion atomic_reactor/utils/cachi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def remote_source_to_cachi2(remote_source: Dict[str, Any]) -> Dict[str, Any]:
* git-submodule

"""
pkg_managers_map = {
"rubygems": "bundler" # renamed in cachi2
}

removed_flags = {"include-git-dir", "remove-unsafe-symlinks"}
removed_pkg_managers = {"git-submodule"}

Expand All @@ -36,10 +40,18 @@ 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

# if pkg manager has different name in cachi2 update it
pkg_manager = pkg_managers_map.get(pkg_manager, pkg_manager)

packages = remote_source.get("packages", {}).get(pkg_manager, [])
packages = packages or [{"path": "."}]
for pkg in packages:
Expand Down
10 changes: 10 additions & 0 deletions tests/utils/test_cachi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
{"flags": [], "packages": [{"path": ".", "type": "gomod"}]},
id="pkg_manager_plain",
),
pytest.param(
{"pkg_managers": ["rubygems"]},
{"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