Repository: pulp/pulpcore

Issue:
Update CI files for branch 3.43



Discussion:

Resolving patch:
diff --git a/pulpcore/app/serializers/repository.py b/pulpcore/app/serializers/repository.py
--- a/pulpcore/app/serializers/repository.py
+++ b/pulpcore/app/serializers/repository.py
@@ -246,12 +246,17 @@ class Meta:
 
 class RepositoryVersionCreateSerializer(ModelSerializer, NestedHyperlinkedModelSerializer):
     add_content_units = serializers.ListField(
-        help_text=_('A list of content units to add to a new repository version'),
-        write_only=True
+        help_text=_('A list of content units to add to a new repository version. This content is '
+                    'added after remove_content_units are removed.'),
+        write_only=True,
+        required=False
     )
     remove_content_units = serializers.ListField(
-        help_text=_('A list of content units to remove from the latest repository version'),
-        write_only=True
+        help_text=_("A list of content units to remove from the latest repository version. "
+                    "You may also specify '*' as an entry to remove all content. This content is "
+                    "removed before add_content_units are added."),
+        write_only=True,
+        required=False
     )
     base_version = NestedRelatedField(
         required=False,
@@ -263,6 +268,11 @@ class RepositoryVersionCreateSerializer(ModelSerializer, NestedHyperlinkedModelS
         parent_lookup_kwargs={'repository_pk': 'repository__pk'},
     )
 
+    def validate_remove_content_units(self, value):
+        if len(value) > 1 and '*' in value:
+            raise serializers.ValidationError("Cannot supply content units and '*'.")
+        return value
+
     class Meta:
         model = models.RepositoryVersion
         fields = ['add_content_units', 'remove_content_units', 'base_version']
diff --git a/pulpcore/app/tasks/repository.py b/pulpcore/app/tasks/repository.py
--- a/pulpcore/app/tasks/repository.py
+++ b/pulpcore/app/tasks/repository.py
@@ -88,6 +88,10 @@ def add_and_remove(repository_pk, add_content_units, remove_content_units, base_
     else:
         base_version = None
 
+    if '*' in remove_content_units:
+        latest = models.RepositoryVersion.latest(repository)
+        remove_content_units = latest.content.values_list('pk', flat=True)
+
     with models.RepositoryVersion.create(repository, base_version=base_version) as new_version:
-        new_version.add_content(models.Content.objects.filter(pk__in=add_content_units))
         new_version.remove_content(models.Content.objects.filter(pk__in=remove_content_units))
+        new_version.add_content(models.Content.objects.filter(pk__in=add_content_units))
diff --git a/pulpcore/app/viewsets/repository.py b/pulpcore/app/viewsets/repository.py
--- a/pulpcore/app/viewsets/repository.py
+++ b/pulpcore/app/viewsets/repository.py
@@ -225,6 +225,8 @@ def create(self, request, repository_pk):
         add_content_units = []
         remove_content_units = []
         repository = self.get_parent_object()
+        serializer = self.get_serializer(data=request.data)
+        serializer.is_valid(raise_exception=True)
 
         if 'base_version' in request.data:
             base_version_pk = self.get_resource(request.data['base_version'], RepositoryVersion).pk
@@ -238,8 +240,11 @@ def create(self, request, repository_pk):
 
         if 'remove_content_units' in request.data:
             for url in request.data['remove_content_units']:
-                content = self.get_resource(url, Content)
-                remove_content_units.append(content.pk)
+                if url == '*':
+                    remove_content_units.append(url)
+                else:
+                    content = self.get_resource(url, Content)
+                    remove_content_units.append(content.pk)
 
         result = enqueue_with_reservation(
             tasks.repository.add_and_remove, [repository],


Test patch: