-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #35959 - Add structured APT content mode
Co-authored-by: Bernhard Suttner <[email protected]>
- Loading branch information
Showing
7 changed files
with
83 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace :katello do | ||
desc "Enable or disable the use of structured content for APT clients." | ||
task :enable_structured_content_for_deb, ['deb_use_structured_content'] => ['environment', 'dynflow:client', "check_ping"] do |t, args| | ||
unless ['true', 'false'].include?(args[:deb_use_structured_content]) | ||
puts "You must specify if structured content should be enabled or disabled, your options are:" | ||
puts " foreman-rake katello:enable_structured_content_for_deb[true]" | ||
puts " foreman-rake katello:enable_structured_content_for_deb[false]" | ||
puts "Note that use of structured content is currently set to '#{Setting['deb_use_structured_content']}'!" | ||
exit 1 | ||
end | ||
|
||
User.current = User.anonymous_api_admin | ||
deb_use_structured_content = ActiveModel::Type::Boolean.new.cast(args[:deb_use_structured_content]) | ||
|
||
# Force deb_use_simple_publish to true, since we are not yet ready to drop simple publishing! | ||
Setting['deb_use_simple_publish'] = true | ||
|
||
# Update deb_use_structured_content to the value requested by the user: | ||
Setting['deb_use_structured_content'] = deb_use_structured_content | ||
|
||
# Ignore repositories where url is not set, since those are presumably empty or used for uploads! | ||
roots = Katello::RootRepository.deb_type.where.not(url: nil) | ||
roots.each do |root| | ||
# Note that we are assuming root.deb_releases must necessarily be set already if url is also set. | ||
components = root.deb_components | ||
if components.blank? and deb_use_structured_content | ||
repo = root.library_instance | ||
repo_backend_service = repo.backend_service(SmartProxy.pulp_primary) | ||
pulp_components = repo_backend_service.api.content_release_components_api.list(repository_version: repo.version_href) | ||
components = pulp_components.results.map(&:component).join(' ') | ||
end | ||
# We call a repository update action on every deb type root repository with an upstream url: | ||
ForemanTasks.sync_task(::Actions::Katello::Repository::Update, root, deb_components: components) | ||
end | ||
end | ||
end |