forked from pulp/pulp_container
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add includes/excludes fields to filter remotes
This commit adds a feature to refine (include only and/or remove unwanted) remote repositories pulled during pull-through caching. closes: pulp#459
- Loading branch information
Showing
11 changed files
with
255 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Added support for filtering remote repositories in pull-through caching using `includes` and | ||
`excludes` fields. These fields can be set on pull-through caching remote objects. |
24 changes: 24 additions & 0 deletions
24
pulp_container/app/migrations/0040_add_remote_repo_filter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 4.2.13 on 2024-06-28 10:34 | ||
|
||
import django.contrib.postgres.fields | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('container', '0039_manifest_data'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='containerpullthroughremote', | ||
name='excludes', | ||
field=django.contrib.postgres.fields.ArrayField(base_field=models.TextField(null=True), null=True, size=None), | ||
), | ||
migrations.AddField( | ||
model_name='containerpullthroughremote', | ||
name='includes', | ||
field=django.contrib.postgres.fields.ArrayField(base_field=models.TextField(null=True), null=True, size=None), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
pulp_container/tests/functional/api/test_remote_filter_pull_through.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import pytest | ||
import subprocess | ||
|
||
from pulp_container.tests.functional.constants import ( | ||
REGISTRY_V2, | ||
PULP_HELLO_WORLD_REPO, | ||
PULP_FIXTURE_1, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def pull_and_verify( | ||
capfd, | ||
local_registry, | ||
registry_client, | ||
): | ||
def _pull_and_verify(images, pull_through_distribution, includes, excludes, expected): | ||
distr = pull_through_distribution(includes, excludes) | ||
for image_path in images: | ||
remote_image_path = f"{REGISTRY_V2}/{image_path}" | ||
local_image_path = f"{distr.base_path}/{image_path}" | ||
|
||
if image_path not in expected: | ||
with pytest.raises(subprocess.CalledProcessError): | ||
local_registry.pull(local_image_path) | ||
assert "Repository not found" in capfd.readouterr().err | ||
else: | ||
local_registry.pull(local_image_path) | ||
local_image = local_registry.inspect(local_image_path) | ||
registry_client.pull(remote_image_path) | ||
remote_image = registry_client.inspect(remote_image_path) | ||
assert local_image[0]["Id"] == remote_image[0]["Id"] | ||
|
||
return _pull_and_verify | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"images, includes, excludes, expected", | ||
[ | ||
( | ||
[f"{PULP_FIXTURE_1}:manifest_a", f"{PULP_FIXTURE_1}:manifest_b"], | ||
None, | ||
[], | ||
[f"{PULP_FIXTURE_1}:manifest_a", f"{PULP_FIXTURE_1}:manifest_b"], | ||
), | ||
([f"{PULP_FIXTURE_1}:manifest_a", f"{PULP_FIXTURE_1}:manifest_b"], [], ["pulp*"], []), | ||
( | ||
[f"{PULP_FIXTURE_1}:manifest_a", f"{PULP_FIXTURE_1}:manifest_b"], | ||
[], | ||
["pulp/test-fixture-1"], | ||
[], | ||
), | ||
( | ||
[ | ||
f"{PULP_FIXTURE_1}:manifest_a", | ||
f"{PULP_FIXTURE_1}:manifest_b", | ||
f"{PULP_HELLO_WORLD_REPO}:linux", | ||
], | ||
["*hello*"], | ||
["*fixture*"], | ||
[f"{PULP_HELLO_WORLD_REPO}:linux"], | ||
), | ||
( | ||
["custom_namespace/custom_repo:latest"], | ||
["*pulp*"], | ||
None, | ||
[], | ||
), | ||
], | ||
) | ||
def test_includes_excludes_filter( | ||
images, | ||
includes, | ||
excludes, | ||
expected, | ||
pull_through_distribution, | ||
pull_and_verify, | ||
delete_orphans_pre, | ||
): | ||
pull_and_verify(images, pull_through_distribution, includes, excludes, expected) |
Oops, something went wrong.