Skip to content

Commit

Permalink
Fixes #36844 - Fail early when syncing non-library repos
Browse files Browse the repository at this point in the history
  • Loading branch information
sjha4 committed Oct 25, 2023
1 parent ed38597 commit b08c85d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/katello/api/v2/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ def show
param :skip_metadata_check, :bool, :desc => N_("Force sync even if no upstream changes are detected. Only used with yum or deb repositories."), :required => false
param :validate_contents, :bool, :desc => N_("Force a sync and validate the checksums of all content. Only used with yum repositories."), :required => false
def sync
fail HttpErrors::BadRequest, _("attempted to sync a non-library repository.") unless @repository.library_instance?
sync_options = {
:skip_metadata_check => ::Foreman::Cast.to_bool(params[:skip_metadata_check]),
:validate_contents => ::Foreman::Cast.to_bool(params[:validate_contents]),
Expand Down
1 change: 1 addition & 0 deletions app/lib/actions/katello/repository/sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def humanized_name
def validate_repo!(repo:, source_url:, skip_metadata_check:, skip_candlepin_check:)
fail ::Katello::Errors::InvalidActionOptionError, _("Unable to sync repo. This repository does not have a feed url.") if repo.url.blank? && source_url.blank?
fail ::Katello::Errors::InvalidActionOptionError, _("Cannot skip metadata check on non-yum/deb repositories.") if skip_metadata_check && !repo.yum? && !repo.deb?
fail ::Katello::Errors::InvalidActionOptionError, _("Unable to sync repo. This repository is not a library instance repository.") unless repo.library_instance?
::Katello::Util::CandlepinRepositoryChecker.check_repository_for_sync!(repo) if repo.yum? && !skip_candlepin_check
end

Expand Down

0 comments on commit b08c85d

Please sign in to comment.