From 511e6d1d12e7e72b92d98f092d66138616b22428 Mon Sep 17 00:00:00 2001 From: Thorben Denzer Date: Wed, 23 Oct 2024 09:33:32 +0200 Subject: [PATCH] Fixes #37958 - Add "Sync Dependencies" option to Ansible collection repositories --- .../katello/api/v2/repositories_controller.rb | 4 +- .../pulp3/repository/ansible_collection.rb | 3 +- .../api/v2/repositories/show.json.rabl | 1 + ...706_add_sync_deps_to_ansible_collection.rb | 5 + .../details/views/repository-info.html | 7 + .../new/new-repository.controller.js | 2 +- .../new/views/new-repository.html | 13 + .../pulp3/ansible_collection_sync/sync.yml | 483 +++--- .../sync_mirror_false.yml | 1355 +++++++++-------- .../sync_mirror_true.yml | 1191 +++++++-------- 10 files changed, 1549 insertions(+), 1515 deletions(-) create mode 100644 db/migrate/20241022121706_add_sync_deps_to_ansible_collection.rb diff --git a/app/controllers/katello/api/v2/repositories_controller.rb b/app/controllers/katello/api/v2/repositories_controller.rb index 34344377c68..a691062d9cb 100644 --- a/app/controllers/katello/api/v2/repositories_controller.rb +++ b/app/controllers/katello/api/v2/repositories_controller.rb @@ -580,7 +580,7 @@ def repository_params keys = [:download_policy, :mirroring_policy, :sync_policy, :arch, :verify_ssl_on_sync, :upstream_password, :upstream_username, :download_concurrency, :metadata_expire, {:os_versions => []}, :deb_releases, :deb_components, :deb_architectures, :description, - :http_proxy_policy, :http_proxy_id, :retain_package_versions_count, {:ignorable_content => []} + :http_proxy_policy, :http_proxy_id, :retain_package_versions_count, {:ignorable_content => []}, :sync_dependencies ] keys += [{:include_tags => []}, {:exclude_tags => []}, :docker_upstream_name] if params[:action] == 'create' || @repository&.docker? keys += [:upstream_authentication_token] if params[:action] == 'create' || @repository&.yum? @@ -620,7 +620,7 @@ def construct_repo_from_params(repo_params) # rubocop:disable Metrics/AbcSize root = @product.add_repo(repo_params.slice(:label, :name, :description, :url, :content_type, :arch, :unprotected, :gpg_key, :ssl_ca_cert, :ssl_client_cert, :ssl_client_key, :checksum_type, :download_policy, :http_proxy_policy, - :metadata_expire).to_h.with_indifferent_access) + :metadata_expire, :sync_dependencies).to_h.with_indifferent_access) root.verify_ssl_on_sync = ::Foreman::Cast.to_bool(repo_params[:verify_ssl_on_sync]) if repo_params.key?(:verify_ssl_on_sync) root.mirroring_policy = repo_params[:mirroring_policy] || Katello::RootRepository::MIRRORING_POLICY_CONTENT root.upstream_username = repo_params[:upstream_username] if repo_params.key?(:upstream_username) diff --git a/app/services/katello/pulp3/repository/ansible_collection.rb b/app/services/katello/pulp3/repository/ansible_collection.rb index 2f18534cfb2..409b33dc1d2 100644 --- a/app/services/katello/pulp3/repository/ansible_collection.rb +++ b/app/services/katello/pulp3/repository/ansible_collection.rb @@ -13,7 +13,8 @@ def remote_options requirements_file: root.ansible_collection_requirements.blank? ? nil : root.ansible_collection_requirements, auth_url: root.ansible_collection_auth_url, token: root.ansible_collection_auth_token, - tls_validation: root.verify_ssl_on_sync) + tls_validation: root.verify_ssl_on_sync, + sync_dependencies: root.sync_dependencies) end def distribution_options(path) diff --git a/app/views/katello/api/v2/repositories/show.json.rabl b/app/views/katello/api/v2/repositories/show.json.rabl index 4d7ac98e0d4..39c8bb13ce0 100644 --- a/app/views/katello/api/v2/repositories/show.json.rabl +++ b/app/views/katello/api/v2/repositories/show.json.rabl @@ -19,6 +19,7 @@ glue(@resource.root) do attributes :ssl_ca_cert_id attributes :ssl_client_cert_id attributes :ssl_client_key_id + attributes :sync_dependencies attributes :product_type attributes :upstream_username diff --git a/db/migrate/20241022121706_add_sync_deps_to_ansible_collection.rb b/db/migrate/20241022121706_add_sync_deps_to_ansible_collection.rb new file mode 100644 index 00000000000..6ba04a26653 --- /dev/null +++ b/db/migrate/20241022121706_add_sync_deps_to_ansible_collection.rb @@ -0,0 +1,5 @@ +class AddSyncDepsToAnsibleCollection < ActiveRecord::Migration[6.1] + def change + add_column :katello_root_repositories, :sync_dependencies, :boolean, :default => true + end +end diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html index 939bbe71561..34e3f8087bb 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html @@ -144,6 +144,13 @@

Sync Settings

edit-trigger="uploadedFile"> +
Sync Dependencies
+
+
+
Ansible Collection Authorization
Sync Settings

+
+
+ + +

+ Include dependencies of Ansible collections in the repository. +

+
+
+