summaryrefslogtreecommitdiff
path: root/lib/puppet_x
diff options
context:
space:
mode:
authorHelen Campbell <helen@puppetlabs.com>2016-09-15 11:35:38 +0100
committerHelen Campbell <helen@puppetlabs.com>2016-09-21 10:19:16 +0100
commit0ec7ffa5c086c8a1c6e871b086299dd1953fa8ba (patch)
tree6d8db086ef7b3f0ceb269058f25f48ee0d1d340b /lib/puppet_x
parentdce8d7b194e3f6d9bb24e076c6e835aeb671099a (diff)
Ensure validate functions use Puppet 4 deprecation
Diffstat (limited to 'lib/puppet_x')
-rw-r--r--lib/puppet_x/puppetlabs/stdlib/deprecation_gen.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/puppet_x/puppetlabs/stdlib/deprecation_gen.rb b/lib/puppet_x/puppetlabs/stdlib/deprecation_gen.rb
new file mode 100644
index 0000000..a3d830b
--- /dev/null
+++ b/lib/puppet_x/puppetlabs/stdlib/deprecation_gen.rb
@@ -0,0 +1,21 @@
+# Creates a Puppet 4 function for the corresponding puppet 3 validate function, who's name will be passed as an argument, alongside the type for deprecation output purposes.
+module PuppetX
+ module Puppetlabs
+ module Stdlib
+ def self.deprecation_gen(funct, type)
+ Puppet::Functions.create_function(funct, Puppet::Functions::InternalFunction) do
+ @@funct = funct
+ @@type = type
+ dispatch :deprecation_gen do
+ scope_param
+ optional_repeated_param 'Any', :args
+ end
+ def deprecation_gen(scope, *args)
+ call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with #{@@type}. There is further documentation for validate_legacy function in the README.")
+ scope.send("function_#{@@funct}", args)
+ end
+ end
+ end
+ end
+ end
+end