-
Notifications
You must be signed in to change notification settings - Fork 45
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
closes: #459
- Loading branch information
Showing
11 changed files
with
227 additions
and
44 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. |
23 changes: 23 additions & 0 deletions
23
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,23 @@ | ||
# Generated by Django 4.2.13 on 2024-06-26 11:51 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('container', '0039_manifest_data'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='containerpullthroughremote', | ||
name='excludes', | ||
field=models.JSONField(null=True), | ||
), | ||
migrations.AddField( | ||
model_name='containerpullthroughremote', | ||
name='includes', | ||
field=models.JSONField(null=True), | ||
), | ||
] |
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
77 changes: 77 additions & 0 deletions
77
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,77 @@ | ||
import subprocess | ||
import pytest | ||
import re | ||
|
||
from uuid import uuid4 | ||
|
||
from pulp_container.tests.functional.constants import ( | ||
REGISTRY_V2, | ||
REGISTRY_V2_FEED_URL, | ||
PULP_HELLO_WORLD_REPO, | ||
PULP_FIXTURE_1, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def pull_and_verify( | ||
capfd, | ||
delete_orphans_pre, | ||
local_registry, | ||
registry_client, | ||
): | ||
def _pull_and_verify(images, pull_through_distribution, includes, excludes): | ||
distr = pull_through_distribution(includes, excludes) | ||
for _, image_path in enumerate(images, start=1): | ||
remote_image_path = f"{REGISTRY_V2}/{image_path}" | ||
local_image_path = f"{distr.base_path}/{image_path}" | ||
|
||
if excludes and re.match(".*fixture.*", image_path): | ||
with pytest.raises(subprocess.CalledProcessError): | ||
local_registry.pull(local_image_path) | ||
assert ( | ||
re.search( | ||
".*Repository not found.*", | ||
capfd.readouterr().err, | ||
) | ||
is not None | ||
) | ||
continue | ||
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 | ||
|
||
|
||
def test_no_filter(pull_through_distribution, pull_and_verify): | ||
images = [f"{PULP_FIXTURE_1}:manifest_a", f"{PULP_FIXTURE_1}:manifest_b"] | ||
includes = None | ||
excludes = [] | ||
pull_and_verify(images, pull_through_distribution, includes, excludes) | ||
|
||
|
||
def test_filter_exclude_with_regex(pull_through_distribution, pull_and_verify): | ||
images = [f"{PULP_FIXTURE_1}:manifest_a", f"{PULP_FIXTURE_1}:manifest_b"] | ||
includes = [] | ||
excludes = ["pulp*"] | ||
pull_and_verify(images, pull_through_distribution, includes, excludes) | ||
|
||
|
||
def test_filter_exclude(pull_through_distribution, pull_and_verify): | ||
images = [f"{PULP_FIXTURE_1}:manifest_a", f"{PULP_FIXTURE_1}:manifest_b"] | ||
includes = [] | ||
excludes = ["pulp/test-fixture-1"] | ||
pull_and_verify(images, pull_through_distribution, includes, excludes) | ||
|
||
|
||
def test_filter_include_and_exclude(pull_through_distribution, pull_and_verify): | ||
images = [ | ||
f"{PULP_FIXTURE_1}:manifest_a", | ||
f"{PULP_FIXTURE_1}:manifest_b", | ||
f"{PULP_HELLO_WORLD_REPO}:linux", | ||
] | ||
includes = ["*hello*"] | ||
excludes = ["*fixture*"] | ||
pull_and_verify(images, pull_through_distribution, includes, excludes) |
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