Hi Thomas, On 01 Sep 2015, at 09:59, Thomas Hallgren <[email protected]> wrote:
> Hi Martin, > > The function API has evolved slightly since the blog entry that you're > referring to was written. The arg_count was removed since it was redundant > and confusing after we introduced the 'optional_param' and 'repeated_param'. > You can find the documentation for Puppet 4.2 functions here: > > https://docs.puppetlabs.com/references/4.2.latest/developer/Puppet/Functions.html Many thanks for pointing to the new updated documentation. My idea is to create a functions which has 3 use cases: - no parameter: return hostname of puppet master - ip as parameter: return DNS resolved name - hostname/fqdn as parameter: return IP address from DNS How to check for explizit “no parameter”? Should I check for a dummy parameter set to type Undef? best, Martin > > Regards, > Thomas > > > On 2015-08-31 17:57, Martin Alfke wrote: >> Hi, >> >> I am playing with Puppet 4 functions. >> According to Henriks blog[1] one can provide information on number of >> arguments for a function using arg_count inside the dispatch. >> >> The following code will throw an error: >> >> # modules/utils/lib/puppet/functions/resolver.rb >> require 'socket' >> Puppet::Functions.create_function(:resolver) do >> dispatch :hostname do >> arg_count 0, 0 >> end >> def hostname() >> Socket.gethostname >> end >> end >> >> Error: Evaluation Error: Error while evaluating a Function Call, undefined >> method `arg_count' for >> #<Puppet::Functions::DispatcherBuilder:0x00000004cbd280> at >> /etc/puppetlabs/code/environments/production/modules/functions/manifests/init.pp:2:15 >> on node puppetmaster.example.net >> >> I had aloof on the functions.rb file in PC1 >> (/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/functions.rb). >> No arg_count function is available. >> >> Is arg_count a feature which will be available with an upcoming version? >> >> Any other way to provide information regarding amount of arguments? >> >> Best, >> Martin >> >> [1] >> http://puppet-on-the-edge.blogspot.de/2015/01/the-puppet-4x-function-api.html >> > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-dev/55E55AEF.7080008%40puppetlabs.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/A24A95D0-AB1D-48D3-8F64-B9ED0EBF7590%40gmail.com. For more options, visit https://groups.google.com/d/optout.
