Skip to content

Commit

Permalink
Changes to support associating Remotes with Repositories
Browse files Browse the repository at this point in the history
fixes #7135
  • Loading branch information
David Davis authored and daviddavis committed Jul 27, 2020
1 parent e28625d commit cc2bc72
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES/7135.feature
@@ -0,0 +1 @@
Added ability for users to add Remote to Repository and automatically use it when syncing.
23 changes: 12 additions & 11 deletions pulp_file/app/models.py
Expand Up @@ -40,13 +40,25 @@ class Meta:
unique_together = ("relative_path", "digest")


class FileRemote(Remote):
"""
Remote for "file" content.
"""

TYPE = "file"

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"


class FileRepository(Repository):
"""
The "file" repository type.
"""

TYPE = "file"
CONTENT_TYPES = [FileContent]
REMOTE_TYPES = [FileRemote]

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
Expand All @@ -67,17 +79,6 @@ def finalize_new_version(self, new_version):
validate_repo_version(new_version)


class FileRemote(Remote):
"""
Remote for "file" content.
"""

TYPE = "file"

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"


class FilePublication(Publication):
"""
Publication for 'file' content.
Expand Down
6 changes: 4 additions & 2 deletions pulp_file/app/viewsets.py
Expand Up @@ -89,11 +89,13 @@ def sync(self, request, pk):
The ``repository`` field has to be provided.
"""
serializer = RepositorySyncURLSerializer(data=request.data, context={"request": request})
serializer = RepositorySyncURLSerializer(
data=request.data, context={"request": request, "repository_pk": pk}
)
serializer.is_valid(raise_exception=True)

repository = self.get_object()
remote = serializer.validated_data.get("remote")
remote = serializer.validated_data.get("remote", repository.remote)

mirror = serializer.validated_data.get("mirror", False)
result = enqueue_with_reservation(
Expand Down

0 comments on commit cc2bc72

Please sign in to comment.