Skip to content

Allow any sensitive type so that Sensitive(Deferred(...)) values can be passed to concat::fragment #824

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions manifests/fragment.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
# Specifies the destination file of the fragment. Valid options: a string containing the path or title of the parent concat resource.
#
define concat::fragment (
String $target,
Optional[Variant[Sensitive[String], String, Deferred]] $content = undef,
Optional[Variant[String, Array]] $source = undef,
Variant[String, Integer] $order = '10',
String $target,
Optional[Variant[Sensitive, String, Deferred]] $content = undef,
Optional[Variant[String, Array]] $source = undef,
Variant[String, Integer] $order = '10',
) {
$resource = 'Concat::Fragment'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@basedir = setup_test_directory
end

describe 'file' do
describe 'deferred file' do
let(:pp) do
<<-MANIFEST
concat { '#{basedir}/deferred_file': }
Expand All @@ -30,4 +30,24 @@
expect(file("#{basedir}/deferred_file").content).to match Digest::MD5.hexdigest('test')
end
end

describe 'sensitive deferred file' do
let(:pp) do
<<-MANIFEST
concat { '#{basedir}/sensitive_deferred_file': }

concat::fragment { '1':
target => '#{basedir}/sensitive_deferred_file',
content => Sensitive(Deferred('md5', ['test'])),
}
MANIFEST
end

it 'idempotent, file matches' do
idempotent_apply(pp)
expect(file("#{basedir}/sensitive_deferred_file")).to be_file
expect(file("#{basedir}/sensitive_deferred_file").content).to match Digest::MD5.hexdigest('test')
end
end

end