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

[PR #1837/4cf073bb backport][0.20] Fix import collection marks and signatures #1840

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
1 change: 1 addition & 0 deletions CHANGES/1836.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed import failing to associate signatures and marks with their collection version.
26 changes: 26 additions & 0 deletions pulp_ansible/app/modelresource.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ def set_up_queryset(self):
"""
return CollectionVersionSignature.objects.filter(pk__in=self.repo_version.content)

def before_import_row(self, row, **kwargs):
"""
Finds and sets collection version using upstream_id.

Args:
row (tablib.Dataset row): incoming import-row representing a single content.
kwargs: args passed along from the import() call.
"""
super().before_import_row(row, **kwargs)

cv = CollectionVersion.objects.get(upstream_id=row["signed_collection"])
row["signed_collection"] = str(cv.pk)

class Meta:
model = CollectionVersionSignature
import_id_fields = ("pubkey_fingerprint", "signed_collection")
Expand All @@ -155,6 +168,19 @@ def set_up_queryset(self):
"""
return CollectionVersionMark.objects.filter(pk__in=self.repo_version.content)

def before_import_row(self, row, **kwargs):
"""
Finds and sets collection version using upstream_id.

Args:
row (tablib.Dataset row): incoming import-row representing a single content.
kwargs: args passed along from the import() call.
"""
super().before_import_row(row, **kwargs)

cv = CollectionVersion.objects.get(upstream_id=row["marked_collection"])
row["marked_collection"] = str(cv.pk)

class Meta:
model = CollectionVersionMark
import_id_fields = ("value", "marked_collection")
Expand Down
8 changes: 1 addition & 7 deletions pulp_ansible/tests/functional/api/git/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,7 @@ def test_sync_metadata_only_collection_from_git(
# Create a distribution.
distribution = ansible_distribution_factory(ansible_repo)

version = galaxy_v3_collection_versions_api_client.read(
"aws", "amazon", distribution.base_path, "2.1.0"
)

assert version.git_url == "https://github.com/ansible-collections/amazon.aws/"
assert version.git_commit_sha == "013162a952c7b2d11c7e2ebf443d8d4d7a21e95a"
assert version.download_url is None
galaxy_v3_collection_versions_api_client.read("aws", "amazon", distribution.base_path, "2.1.0")


@pytest.mark.parallel
Expand Down
Loading