From 970852dd317fbb2699b406dd25aeddef496a7c92 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Mon, 3 Oct 2016 14:10:50 +0100 Subject: Addition of Puppet 4 functions --- lib/puppet_x/puppetlabs/stdlib/deprecation_gen.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/puppet_x/puppetlabs/stdlib/deprecation_gen.rb (limited to 'lib/puppet_x/puppetlabs') 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 -- cgit v1.2.3