Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37958 - Add "Sync Dependencies" option to Ansible collection repositories #11195

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/katello/api/v2/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion app/services/katello/pulp3/repository/ansible_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions app/views/katello/api/v2/repositories/show.json.rabl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20241022121706_add_sync_dependencies_option.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddSyncDependenciesOption < ActiveRecord::Migration[6.1]
def change
add_column :katello_root_repositories, :sync_dependencies, :boolean, :default => true
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ <h4 translate>Sync Settings</h4>
edit-trigger="uploadedFile">
</dd>

<dt translate>Sync Dependencies</dt>
<dd bst-edit-checkbox="repository.sync_dependencies"
formatter="booleanToYesNo"
on-save="save(repository)"
readonly="denied('edit_products', product) || !repository.allow_updates || repository.is_container_push">
</dd>

<dt translate>Ansible Collection Authorization</dt>
<dd bst-edit-custom="repository.ansible_collection_auth_exists"
readonly="denied('edit_products', product) || !repository.allow_updates || repository.is_container_push"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ angular.module('Bastion.repositories').controller('NewRepositoryController',
});

$scope.save = function (repository) {
var fields = ['upstream_password', 'upstream_username', 'ansible_collection_auth_token', 'ansible_collection_auth_url', 'ansible_collection_requirements'];
var fields = ['upstream_password', 'upstream_username', 'ansible_collection_auth_token', 'ansible_collection_auth_url', 'ansible_collection_requirements', 'sync_repositories'];
if (repository.content_type === 'yum') {
repository.os_versions = $scope.osVersionsParam();
repository.ignorable_content = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ <h4 translate> Sync Settings </h4>
</a></p>
</div>

<div ng-show="repository.content_type === 'ansible_collection'">
<div class="checkbox">
<label>
<input id="sync_dependencies" name="sync_dependencies" ng-model="repository.sync_dependencies" ng-init="repository.sync_dependencies=true" type="checkbox"/>
<span translate>Sync Dependencies</span>
</label>

<p class="help-block" translate>
Include dependencies of Ansible collections in the repository.
</p>
</div>
</div>

<div ng-show="repository.content_type === 'ansible_collection'" bst-form-group label="{{ 'Auth URL' | translate }}">
<input id="ansible_collection_auth_url"
name="ansible_collection_auth_url"
Expand Down
11 changes: 11 additions & 0 deletions test/actions/pulp3/orchestration/ansible_collection_sync_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ def test_sync
assert_equal repository_reference.repository_href + "versions/1/", @repo.version_href
end

def test_sync_wo_dependencies
@repo.root.update(:sync_dependencies => false)
sync_args = {:smart_proxy_id => @primary.id, :repo_id => @repo.id}
ForemanTasks.sync_task(::Actions::Pulp3::Orchestration::Repository::Sync, @repo, @primary, sync_args)
@repo.reload
refute_equal @repo.version_href, @repo_version_href

pulp_remote = @repo.backend_service(@primary).get_remote
assert_equal pulp_remote.sync_dependencies, false
end

def test_sync_mirror_false
sync_args = {:smart_proxy_id => @primary.id, :repo_id => @repo.id}
ForemanTasks.sync_task(::Actions::Pulp3::Orchestration::Repository::Sync, @repo, @primary, sync_args)
Expand Down
Loading