Skip to content
Merged
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
14 changes: 14 additions & 0 deletions lib/puppet/functions/tomcat/change.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

# This function exists for usage of a returning the input params that is a deferred function
# Will be used for deferring the values at agent level
Puppet::Functions.create_function(:'tomcat::change') do
dispatch :change do
param 'Any', :arg
return_type 'Any'
end

def change(arg)
arg
end
end
2 changes: 1 addition & 1 deletion manifests/config/server/tomcat_users.pp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
augeas { "${catalina_base}-tomcat_users-${element}-${_element_name}-${name}":
lens => 'Xml.lns',
incl => $_file,
changes => $changes,
changes => Deferred('tomcat::change', [$changes]),
show_diff => $show_diff,
}
}
11 changes: 11 additions & 0 deletions spec/functions/change_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'tomcat::change' do
it { is_expected.to run.with_params(nil).and_return(nil) }
it { is_expected.to run.with_params(2).and_return(2) }
it { is_expected.to run.with_params('').and_return('') }
it { is_expected.to run.with_params('string').and_return('string') }
it { is_expected.to run.with_params(['abc', 2]).and_return(['abc', 2]) }
end