Skip to content

Commit

Permalink
Eliminate Workaround for Sensitive Data
Browse files Browse the repository at this point in the history
"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 4287df8
  • Loading branch information
cocker-cc committed Jun 13, 2024
1 parent fcc331f commit 014bce0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
4 changes: 1 addition & 3 deletions manifests/userlist.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -64,6 +62,6 @@
concat::fragment { "${instance_name}-${section_name}_userlist_block":
order => "12-${section_name}-00",
target => $_config_file,
content => $_content,
content => $content,
}
}
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/userlist_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions templates/haproxy_userlist_block.epp
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<%-
}
}
Expand Down

0 comments on commit 014bce0

Please sign in to comment.