summaryrefslogtreecommitdiff
path: root/lib/puppet_x/puppetlabs
diff options
context:
space:
mode:
authorDavid Schmitt <david.schmitt@puppet.com>2016-10-03 15:33:00 +0100
committerGitHub <noreply@github.com>2016-10-03 15:33:00 +0100
commit7228160175a17fb3d7f5b464553ef6c7791cf140 (patch)
tree4b5c00e27043d10a0cd9ad3722266462c6b6bc85 /lib/puppet_x/puppetlabs
parent96af506f244f37626dc314907817665bfa6b4320 (diff)
parent8a8ebc4850abe4996056a2700a6a50ac7666a922 (diff)
Merge pull request #659 from HelenCampbell/omglob
Ensure validate functions use Puppet 4 deprecation
Diffstat (limited to 'lib/puppet_x/puppetlabs')
-rw-r--r--lib/puppet_x/puppetlabs/stdlib/deprecation_gen.rb19
1 files changed, 19 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..0d8908d
--- /dev/null
+++ b/lib/puppet_x/puppetlabs/stdlib/deprecation_gen.rb
@@ -0,0 +1,19 @@
+# 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
+ dispatch :deprecation_gen do
+ scope_param
+ optional_repeated_param 'Any', :args
+ end
+ define_method 'deprecation_gen' do |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