From 014bce04a9f2044a6c5341efdcdd96ecc2fc542a Mon Sep 17 00:00:00 2001 From: cocker-cc Date: Fri, 10 May 2024 13:31:53 +0200 Subject: [PATCH] Eliminate Workaround for Sensitive Data "concat" handles sensitive Data since 7.4.0. "empty" in Puppet-Core handles sensitive Data since Puppet 7.9.0. So the Workarounds for Sensitive Data can be elminiated. fixes 4287df8549421baf15716ddc7ea7540fe9e1bd93 --- manifests/userlist.pp | 4 +--- metadata.json | 4 ++-- spec/defines/userlist_spec.rb | 2 +- templates/haproxy_userlist_block.epp | 7 ++----- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/manifests/userlist.pp b/manifests/userlist.pp index 7c40696e..ac758b8a 100644 --- a/manifests/userlist.pp +++ b/manifests/userlist.pp @@ -50,8 +50,6 @@ epp_section_name => $section_name, }, ) - # we have to unwrap here, as "concat" cannot handle Sensitive Data - $_content = if $content =~ Sensitive { $content.unwrap } else { $content } if $instance == 'haproxy' { $instance_name = 'haproxy' @@ -64,6 +62,6 @@ concat::fragment { "${instance_name}-${section_name}_userlist_block": order => "12-${section_name}-00", target => $_config_file, - content => $_content, + content => $content, } } diff --git a/metadata.json b/metadata.json index f8f5b6e5..33e6213c 100644 --- a/metadata.json +++ b/metadata.json @@ -14,7 +14,7 @@ }, { "name": "puppetlabs/concat", - "version_requirement": ">= 1.2.3 < 10.0.0" + "version_requirement": ">= 7.4.0 < 10.0.0" } ], "operatingsystem_support": [ @@ -76,7 +76,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 7.0.0 < 9.0.0" + "version_requirement": ">= 7.9.0 < 9.0.0" } ], "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", diff --git a/spec/defines/userlist_spec.rb b/spec/defines/userlist_spec.rb index 0c06c45b..8e1233f3 100644 --- a/spec/defines/userlist_spec.rb +++ b/spec/defines/userlist_spec.rb @@ -36,7 +36,7 @@ is_expected.to contain_concat__fragment('haproxy-admins_userlist_block').with( 'order' => '12-admins-00', 'target' => '/etc/haproxy/haproxy.cfg', - 'content' => "\nuserlist admins\n group superadmins users kitchen scott\n group megaadmins users kitchen\n user scott insecure-password elgato\n user kitchen insecure-password foobar\n", + 'content' => sensitive("\nuserlist admins\n group superadmins users kitchen scott\n group megaadmins users kitchen\n user scott insecure-password elgato\n user kitchen insecure-password foobar\n"), # rubocop:disable Layout/LineLength ) } end diff --git a/templates/haproxy_userlist_block.epp b/templates/haproxy_userlist_block.epp index a4a202e5..786bbd12 100644 --- a/templates/haproxy_userlist_block.epp +++ b/templates/haproxy_userlist_block.epp @@ -14,12 +14,9 @@ userlist <%= $epp_section_name %> } } $epp_users.each |Variant[String, Sensitive[String]] $user| { - # TODO: remove this Workaround, as soon as Function empty() can handle - # Sensitive (Pullrequest pending) - $user_unsensitive = if $user =~ Sensitive { $user.unwrap } else { $user } - unless $user_unsensitive.empty { + unless $user.empty { -%> - user <%= $user_unsensitive %> + user <%= $user %> <%- } }