Skip to content

Commit

Permalink
Auto create repos and distributions for the container push
Browse files Browse the repository at this point in the history
  • Loading branch information
ipanova committed Jun 2, 2020
1 parent 47809ce commit 6a33376
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES/6878.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Auto create repos and distributions for the container push.
14 changes: 9 additions & 5 deletions pulp_container/app/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,15 @@ def create(self, request, path):
"""
This methods handles the creation of an upload.
"""
distribution = get_object_or_404(models.ContainerDistribution, base_path=path)
if distribution.repository:
repository = distribution.repository
else:
raise Http404("Repository {} does not exist.".format(path))
# TODO add repo push type to distinguish from sync repo type
distribution, _ = models.ContainerDistribution.objects.get_or_create(
name=path, base_path=path)
repository = distribution.repository
if not repository:
repository, _ = models.ContainerRepository.objects.get_or_create(name=path)
distribution.repository = repository
distribution.save()

upload = models.Upload(repository=repository)
upload.file.save(name='', content=ContentFile(''), save=False)
upload.save()
Expand Down

0 comments on commit 6a33376

Please sign in to comment.