Skip to content

Commit

Permalink
limit allowed pkg_managers
Browse files Browse the repository at this point in the history
CAchito and cachi2 should support the same set of pkg managers.

Cachi2 allows more pkg managers, but those must be tested and
implemented in OSBS as they may interact with existing workflows.

Signed-off-by: Martin Basti <mbasti@redhat.com>
  • Loading branch information
MartinBasti committed Nov 28, 2024
1 parent 5413870 commit b592101
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions osbs/schemas/container.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
"type": ["array", "null"],
"items": {
"type": "string",
"enum": ["gomod", "rubygems", "pip", "yarn", "npm", "git-submodule"],
"examples": [
"gomod"
]
Expand Down
40 changes: 40 additions & 0 deletions tests/utils/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,43 @@ def test_invalid_remote_sources_schema(config, err_message, caplog):
def test_valid_remote_sources_schema(config, expected_data):
data = read_yaml(dedent(config), "schemas/container.json")
assert expected_data == data


@pytest.mark.parametrize("pkg_manager,valid", [
("npm", True),
("pip", True),
("gomod", True),
("git-submodule", True),
("yarn", True),
("rubygems", True),
("generic", False),
("rpm", False),
])
def test_valid_pkg_managers(pkg_manager, valid):
remote_sources = f"""
remote_sources:
- name: valid-name
remote_source:
repo: https://git.example.com/team/repo.git
ref: b55c00f45ec3dfee0c766cea3d395d6e21cc2e5a
pkg_managers:
- {pkg_manager}
"""
if valid:
assert read_yaml(dedent(remote_sources), "schemas/container.json")
else:
with pytest.raises(OsbsValidationException):
read_yaml(dedent(remote_sources), "schemas/container.json")

remote_source = f"""
remote_source:
repo: https://git.example.com/team/repo.git
ref: b55c00f45ec3dfee0c766cea3d395d6e21cc2e5a
pkg_managers:
- {pkg_manager}
"""
if valid:
read_yaml(dedent(remote_source), "schemas/container.json")
else:
with pytest.raises(OsbsValidationException):
read_yaml(dedent(remote_source), "schemas/container.json")

0 comments on commit b592101

Please sign in to comment.