Skip to content

Commit cedc1a3

Browse files
Merge pull request #533 from puppetlabs/CONT-588-deferred-function-support
(CONT-588) - allow deferred function for change
2 parents 056b904 + e567dbc commit cedc1a3

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
# This function exists for usage of a returning the input params that is a deferred function
4+
# Will be used for deferring the values at agent level
5+
Puppet::Functions.create_function(:'tomcat::change') do
6+
dispatch :change do
7+
param 'Any', :arg
8+
return_type 'Any'
9+
end
10+
11+
def change(arg)
12+
arg
13+
end
14+
end

manifests/config/server/tomcat_users.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
augeas { "${catalina_base}-tomcat_users-${element}-${_element_name}-${name}":
104104
lens => 'Xml.lns',
105105
incl => $_file,
106-
changes => $changes,
106+
changes => Deferred('tomcat::change', [$changes]),
107107
show_diff => $show_diff,
108108
}
109109
}

spec/functions/change_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'tomcat::change' do
6+
it { is_expected.to run.with_params(nil).and_return(nil) }
7+
it { is_expected.to run.with_params(2).and_return(2) }
8+
it { is_expected.to run.with_params('').and_return('') }
9+
it { is_expected.to run.with_params('string').and_return('string') }
10+
it { is_expected.to run.with_params(['abc', 2]).and_return(['abc', 2]) }
11+
end

0 commit comments

Comments
 (0)