Skip to content

Commit

Permalink
Fixes #37958 - Add "Sync Dependencies" option to Ansible collection r…
Browse files Browse the repository at this point in the history
…epositories
  • Loading branch information
Thorben-D committed Nov 6, 2024
1 parent 74e13f9 commit 511e6d1
Show file tree
Hide file tree
Showing 10 changed files with 1,549 additions and 1,515 deletions.
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddSyncDepsToAnsibleCollection < 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
Loading

0 comments on commit 511e6d1

Please sign in to comment.