Skip to content

Commit

Permalink
Added to the distribution config_repo specifying whether Pulp should …
Browse files Browse the repository at this point in the history
…generate *.repo files

closes #2985
  • Loading branch information
ipanova committed Sep 6, 2023
1 parent 748b3dd commit 3b32b7e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES/2985.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added to the distribution config_repo specifying whether Pulp should generate ``*.repo`` files.
18 changes: 18 additions & 0 deletions pulp_rpm/app/migrations/0053_rpmdistribution_config_repo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.4 on 2023-09-06 14:04

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("rpm", "0051_alter_distributiontree_unique_together_and_more"),
]

operations = [
migrations.AddField(
model_name="rpmdistribution",
name="config_repo",
field=models.BooleanField(default=True),
),
]
6 changes: 4 additions & 2 deletions pulp_rpm/app/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,11 @@ class RpmDistribution(Distribution, AutoAddObjPermsMixin):
repository_config_file_name = "config.repo"
INVALID_REPO_ID_CHARS = r"[^\w\-_.:]"

config_repo = models.BooleanField(default=True)

def content_handler(self, path):
"""Serve config.repo and repomd.xml.key."""
if path == self.repository_config_file_name:
if self.config_repo and path == self.repository_config_file_name:
repository, publication = self.get_repository_and_publication()
if not publication:
return
Expand Down Expand Up @@ -504,7 +506,7 @@ def content_headers_for(self, path):
def content_handler_list_directory(self, rel_path):
"""Return the extra dir entries."""
retval = set()
if rel_path == "":
if self.config_repo and rel_path == "":
retval.add(self.repository_config_file_name)
return retval

Expand Down
7 changes: 6 additions & 1 deletion pulp_rpm/app/serializers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,14 @@ class RpmDistributionSerializer(DistributionSerializer):
queryset=Publication.objects.exclude(complete=False),
allow_null=True,
)
config_repo = serializers.BooleanField(
default=True,
required=False,
help_text=_("An option specifying whether Pulp should generate *.repo files."),
)

class Meta:
fields = DistributionSerializer.Meta.fields + ("publication",)
fields = DistributionSerializer.Meta.fields + ("publication", "config_repo")
model = RpmDistribution


Expand Down

0 comments on commit 3b32b7e

Please sign in to comment.