From c74c3a898df4a75de4e7839afd952d1e0861d8ce Mon Sep 17 00:00:00 2001 From: Markus Bucher Date: Tue, 31 Jan 2023 16:21:09 +0100 Subject: [PATCH] Add param for unsave advisory conflict resolution --- manifests/plugin/rpm.pp | 12 ++++++++++-- spec/classes/plugin_rpm_spec.rb | 12 +++++++++++- templates/settings-rpm.py.epp | 9 +++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 templates/settings-rpm.py.epp diff --git a/manifests/plugin/rpm.pp b/manifests/plugin/rpm.pp index 9dd8e260..603c1218 100644 --- a/manifests/plugin/rpm.pp +++ b/manifests/plugin/rpm.pp @@ -6,9 +6,14 @@ # Pulpcore's KEEP_CHANGELOG_LIMIT setting. Uses Pulpcore's default when # undefined. Increasing this limit will cause pulpcore workers to use more # memory when more changelogs are available in the repo metadata. +# +# @param allow_automatic_unsafe_advisory_conflict_resolution +# Allow resolving of conflicts due to duplicate advisory ids with different creation dates +# https://docs.pulpproject.org/pulp_rpm/settings.html#allow-automatic-unsafe-advisory-conflict-resolution class pulpcore::plugin::rpm ( Boolean $use_pulp2_content_route = false, Optional[Integer[0]] $keep_changelog_limit = undef, + Boolean $allow_automatic_unsafe_advisory_conflict_resolution = false, ) { if $use_pulp2_content_route { $context = { @@ -34,8 +39,11 @@ $content = undef } - if $keep_changelog_limit { - $rpm_plugin_config = "KEEP_CHANGELOG_LIMIT = ${keep_changelog_limit}" + if $keep_changelog_limit or $allow_automatic_unsafe_advisory_conflict_resolution { + $rpm_plugin_config = epp('pulpcore/settings-rpm.py.epp', { + 'allow_auacr' => $allow_automatic_unsafe_advisory_conflict_resolution, + 'keep_changelog_limit' => $keep_changelog_limit, + }) } else { $rpm_plugin_config = undef } diff --git a/spec/classes/plugin_rpm_spec.rb b/spec/classes/plugin_rpm_spec.rb index 62ae7738..2ecfd86e 100644 --- a/spec/classes/plugin_rpm_spec.rb +++ b/spec/classes/plugin_rpm_spec.rb @@ -22,13 +22,23 @@ is_expected.not_to contain_concat__fragment('plugin-rpm') end + context 'with allow_unsafe_advisory_conflict_resolution' do + let(:params) { { allow_automatic_unsafe_advisory_conflict_resolution: true } } + + it 'configures pulpcore with ALLOW_AUTOMATIC_UNSAFE_ADVISORY_CONFLICT_RESOLUTION' do + is_expected.to compile.with_all_deps + is_expected.to contain_concat__fragment('plugin-rpm') + .with_content("\n# rpm plugin settings\nALLOW_AUTOMATIC_UNSAFE_ADVISORY_CONFLICT_RESOLUTION = True\n") + end + end + context 'with keep_changelog_limit' do let(:params) { { keep_changelog_limit: 20 } } it 'configures pulpcore with KEEP_CHANGELOG_LIMIT' do is_expected.to compile.with_all_deps is_expected.to contain_concat__fragment('plugin-rpm') - .with_content("\n# rpm plugin settings\nKEEP_CHANGELOG_LIMIT = 20") + .with_content("\n# rpm plugin settings\nKEEP_CHANGELOG_LIMIT = 20\n") end end diff --git a/templates/settings-rpm.py.epp b/templates/settings-rpm.py.epp new file mode 100644 index 00000000..d8fc10b7 --- /dev/null +++ b/templates/settings-rpm.py.epp @@ -0,0 +1,9 @@ +<%- | Boolean $allow_auacr, + Optional[Integer[0]] $keep_changelog_limit +| -%> +<%- if $keep_changelog_limit { -%> +KEEP_CHANGELOG_LIMIT = <%= $keep_changelog_limit %> +<%- } -%> +<%- if $allow_auacr { -%> +ALLOW_AUTOMATIC_UNSAFE_ADVISORY_CONFLICT_RESOLUTION = True +<%- } -%>