Skip to content

Commit

Permalink
Added skip_if_unavailable option to the config.repo file.
Browse files Browse the repository at this point in the history
closes #2902
  • Loading branch information
ipanova committed Sep 7, 2023
1 parent 1940bb0 commit fe50009
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/2902.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added ``skip_if_unavailable`` option to the ``config.repo`` file.
6 changes: 6 additions & 0 deletions pulp_rpm/app/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class RpmRepository(Repository, AutoAddObjPermsMixin):
1 or 0 corresponding to whether repo_gpgcheck should be enabled in the generated
.repo file.
sqlite_metadata (Boolean): Whether to generate sqlite metadata files on publish.
skip_if_unavailable (Boolean): Whether repo should be skipped by the client in the generated
.repo file.
"""

TYPE = "rpm"
Expand Down Expand Up @@ -236,6 +238,7 @@ class RpmRepository(Repository, AutoAddObjPermsMixin):
gpgcheck = models.IntegerField(default=0, choices=GPGCHECK_CHOICES)
repo_gpgcheck = models.IntegerField(default=0, choices=GPGCHECK_CHOICES)
sqlite_metadata = models.BooleanField(default=False)
skip_if_unavailable = models.BooleanField(default=False)

def on_new_version(self, version):
"""
Expand Down Expand Up @@ -265,6 +268,7 @@ def on_new_version(self, version):
"package": self.package_checksum_type,
},
sqlite_metadata=self.sqlite_metadata,
skip_if_unavailable=self.skip_if_unavailable,
)

@staticmethod
Expand Down Expand Up @@ -431,6 +435,7 @@ class RpmPublication(Publication, AutoAddObjPermsMixin):
gpgcheck = models.IntegerField(default=0, choices=GPGCHECK_CHOICES)
repo_gpgcheck = models.IntegerField(default=0, choices=GPGCHECK_CHOICES)
sqlite_metadata = models.BooleanField(default=False)
skip_if_unavailable = models.BooleanField(default=False)

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
Expand Down Expand Up @@ -480,6 +485,7 @@ def content_handler(self, path):
baseurl={base_url}
gpgcheck={publication.gpgcheck}
repo_gpgcheck={publication.repo_gpgcheck}
skip_if_unavailable={publication.skip_if_unavailable}
"""
)

Expand Down
18 changes: 18 additions & 0 deletions pulp_rpm/app/serializers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ class RpmRepositorySerializer(RepositorySerializer):
"DEPRECATED: An option specifying whether Pulp should generate SQLite metadata."
),
)
skip_if_unavailable = serializers.BooleanField(
default=False,
required=False,
help_text=_(
"An option specifying whether client will continue running and disable the repository "
"that couldn’t be synchronized for any reason."
),
)

def validate(self, data):
"""Validate data."""
Expand All @@ -130,6 +138,7 @@ class Meta:
"gpgcheck",
"repo_gpgcheck",
"sqlite_metadata",
"skip_if_unavailable",
)
model = RpmRepository

Expand Down Expand Up @@ -244,6 +253,14 @@ class RpmPublicationSerializer(PublicationSerializer):
"DEPRECATED: An option specifying whether Pulp should generate SQLite metadata."
),
)
skip_if_unavailable = serializers.BooleanField(
default=False,
required=False,
help_text=_(
"An option specifying whether client will continue running and disable the repository "
"that couldn’t be synchronized for any reason."
),
)

def validate(self, data):
"""Validate data."""
Expand All @@ -265,6 +282,7 @@ class Meta:
"gpgcheck",
"repo_gpgcheck",
"sqlite_metadata",
"skip_if_unavailable",
)
model = RpmPublication

Expand Down
4 changes: 4 additions & 0 deletions pulp_rpm/app/viewsets/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,9 @@ def create(self, request):
"Support for sqlite metadata generation will be removed from a future release "
"of pulp_rpm. See https://tinyurl.com/sqlite-removal for more details"
)
skip_if_unavailable = serializer.validated_data.get(
"skip_if_unavailable", repository.skip_if_unavailable
)

if repository.metadata_signing_service:
signing_service_pk = repository.metadata_signing_service.pk
Expand All @@ -574,6 +577,7 @@ def create(self, request):
"checksum_types": checksum_types,
"gpgcheck_options": gpgcheck_options,
"sqlite_metadata": sqlite_metadata,
"skip_if_unavailable": skip_if_unavailable,
},
)
return OperationPostponedResponse(result, request)
Expand Down

0 comments on commit fe50009

Please sign in to comment.