Jira (PUP-3404) helper functions in custom function

2014-10-21 Thread James Shubin (JIRA)
Title: Message Title










 

 James Shubin commented on an issue


















  Re: helper functions in custom function 










If you'll allow me a small rant:
This feature (allowing helper functions) somehow dissapeared, as it used to work just fine. I consider this a huge regression, and taking it out without notice, is no way to convince users that puppetlabs is able to maintain stable releases, if the upstream does this. It's also a very useful feature, so seeing this go is sad.
/rant
In reply to Andy Parker:
 Please use PuppetX::ModuleOwnerName::ModuleName. This pattern will avoid collisions with other modules.  For example at puppetlabs for the foo module we would put extra helpers in PuppetX::Puppetlabs::Foo.
DON'T do this. It will guarantee that your module is unforkable. binford2k agrees, and instead suggests: 13:48 @binford2k Maybe PuppetX::Modulename::Helpers  then
Cheers, James












   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...















 This message was sent by Atlassian JIRA 

Jira (PUP-3404) helper functions in custom function

2014-10-21 Thread Charlie Sharpsteen (JIRA)
Title: Message Title










 

 Charlie Sharpsteen commented on an issue


















  Re: helper functions in custom function 










James Shubin: I dug into this a bit more and couldn't reproduce a working function using historical versions of Puppet. The error is present in 3.0.0, 2.7.26 – all the way back to 2.6.18. Then I tried on a system running under Ruby 1.8.7 and everything works fine. So, this break was induced by some sort of scoping change in Ruby 1.9 and not by any change to the Puppet codebase.
The reason we didn't notice this is that neither the core Puppet Functions or any functions in Puppet Labs modules like stdlib contain these sort of helper methods — so there were no tests exercising this functionality. We try very hard to be intentional about breaking backwards compatibility and to do so appropriately using major versions and by documenting backwards incompatibilities. Unfortunately, this change was not the result of an intentional, or even unintentional, action on our part and so 












   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)


 

Jira (PUP-3404) helper functions in custom function

2014-10-21 Thread Henrik Lindberg (JIRA)
Title: Message Title










 

 Henrik Lindberg commented on an issue


















  Re: helper functions in custom function 










Going forward we have a new API for functions (simply called 4x function API) that will be released in Puppet 4.0 (it can be used since 3.6 with the --parser future option). In the new API you can place helper methods inside the body of code that implements the function, you can have multiple dispatch (different type signatures) and get automatic type checking of arguments. The new functions API also solves a number of other problems.












   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from this group and stop receiving emails from it, send 

Jira (PUP-3404) helper functions in custom function

2014-10-21 Thread James Shubin (JIRA)
Title: Message Title










 

 James Shubin commented on an issue


















  Re: helper functions in custom function 










RE: Charlie,
Interesting, I did not consider the ruby version differences, but I was fairly sure this was working with Ruby 2.0.0 at some point. In any case, this should work IMO, because the amount of boilerplate required to add a function is terrible. I also don't like the forced splitting up of different functions that should really be the same. The lambda approach works great, which is what I was using this as. Thanks for looking into this.












   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from 

Jira (PUP-3404) helper functions in custom function

2014-10-21 Thread James Shubin (JIRA)
Title: Message Title










 

 James Shubin commented on an issue


















  Re: helper functions in custom function 










RE: Henrik,
Sounds like an improvement! Is there any documentation on this that I can look at?
Thanks, James












   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-bugs@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/d/optout.


Jira (PUP-3404) helper functions in custom function

2014-10-21 Thread Henrik Lindberg (JIRA)
Title: Message Title










 

 Henrik Lindberg commented on an issue


















  Re: helper functions in custom function 










https://github.com/puppetlabs/puppet-specifications/blob/master/language/func-api.md
Since 3.7 the iterative functions (each, map, filter, reduce, slice) are implemented with this API, so you can see some examples of some more complex functions using the API.












   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-bugs@googlegroups.com.
Visit this 

Jira (PUP-3404) helper functions in custom function

2014-10-21 Thread James Shubin (JIRA)
Title: Message Title










 

 James Shubin commented on an issue


















  Re: helper functions in custom function 










RE: Henrik,
Cool... So to confirm, would this be a valid function:
code Puppet::Functions.create_function(:foo) do def foo(bar, baz) def inner_foo(inner_bar, inner_baz) return inner_bar+inner_baz end return 42+inner_foo(bar, baz) end end /code ?
Thanks, James












   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from this group and stop receiving emails from it, send an email to 

Jira (PUP-3404) helper functions in custom function

2014-10-21 Thread Henrik Lindberg (JIRA)
Title: Message Title










 

 Henrik Lindberg commented on an issue


















  Re: helper functions in custom function 










No, but this would:






Puppet::Functions.create_function(:foo) do




def foo(bar, baz)




return 42+inner_foo(bar, baz)




end









def inner_foo(inner_bar, inner_baz)




  return inner_bar+inner_baz




end




end







The inner_foo method will never be called by puppet. if you like you can add:






private :inner_foo

 

Jira (PUP-3404) helper functions in custom function

2014-10-09 Thread Philipp (JIRA)
Title: Message Title










 

 Philipp commented on an issue


















  Re: helper functions in custom function 










Charlie Sharpsteen With this function structure change i have no problems. But is this solution the right way?












   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-bugs@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/d/optout.


Jira (PUP-3404) helper functions in custom function

2014-10-09 Thread Henrik Lindberg (JIRA)
Title: Message Title










 

 Henrik Lindberg commented on an issue


















  Re: helper functions in custom function 










Philipp See my earlier comment. You should not define helper methods inside the function body.












   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-bugs@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/d/optout.


Jira (PUP-3404) helper functions in custom function

2014-10-09 Thread Philipp (JIRA)
Title: Message Title










 

 Philipp commented on an issue


















  Re: helper functions in custom function 










Henrik Lindberg How and where i define an auxiliary class?












   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-bugs@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/d/optout.


Jira (PUP-3404) helper functions in custom function

2014-10-09 Thread Henrik Lindberg (JIRA)
Title: Message Title










 

 Henrik Lindberg commented on an issue


















  Re: helper functions in custom function 










IIRC, you can place it in the PuppetX namespace and include it in your module.






# module_root/lib/puppetx/mymodule/myclass.rb




module PuppetX::Mymodule




  class Myclass 




def self.helper_method(x)




  # ... impl of method here




end




  end




end







And then use it in the function like this






Puppet::Parser::Function.newfunction(...) do | args|




  

Jira (PUP-3404) helper functions in custom function

2014-10-09 Thread Andy Parker (JIRA)
Title: Message Title










 

 Andy Parker commented on an issue


















  Re: helper functions in custom function 










Please use PuppetX::ModuleOwnerName::ModuleName. This pattern will avoid collisions with other modules. For example at puppetlabs for the foo module we would put extra helpers in PuppetX::Puppetlabs::Foo.












   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-bugs@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit 

Jira (PUP-3404) helper functions in custom function

2014-10-08 Thread Philipp (JIRA)
Title: Message Title










 

 Philipp created an issue


















 Puppet /  PUP-3404



  helper functions in custom function 










Issue Type:

  Bug




Affects Versions:


 PUP 3.7.1




Assignee:


 Unassigned




Created:


 08/Oct/14 7:03 AM




Priority:

  Normal




Reporter:

 Philipp










Hi, I have a problem with helper functions in custom function
My puppet-Version: v3.7.1 If you need more information, let me know. My custom function in very short from, but with the same error.
module Puppet::Parser::Functions newfunction(:httpd_modules, :type = :rvalue) do |args| def helper_function(value) value end
 result = 1 + helper_function(3) result end end
Puppet-Trace: Error: Could not retrieve catalog from remote server: Error 400 on SERVER: undefined method `helper_function' for #Puppet::Parser::Scope:0x007fac297fbd68 at /www/data/puppet-environment/production/modules/httpd/manifests/webserver.pp:193 on node rpm-repo.pixelpark.com /usr/lib/ruby/site_ruby/1.8/puppet/indirector/rest.rb:207:in `is_http_200?' /usr/lib/ruby/site_ruby/1.8/puppet/indirector/rest.rb:100:in `find' /usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:201:in `find' /usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:256:in `retrieve_new_catalog' /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:327:in `thinmark' /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:326:in `thinmark' /usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:255:in `retrieve_new_catalog' /usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:60:in `retrieve_catalog' /usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:103:in `prepare_and_retrieve_catalog' 

Jira (PUP-3404) helper functions in custom function

2014-10-08 Thread Philipp (JIRA)
Title: Message Title










 

 Philipp updated an issue


















 Puppet /  PUP-3404



  helper functions in custom function 










Change By:

 Philipp









 Hi,IhaveaproblemwithhelperfunctionsincustomfunctionMypuppet-Version:v3.7.1Ifyouneedmoreinformation,letmeknow.Mycustomfunctioninveryshortfrom,butwiththesameerror. {noformat} modulePuppet::Parser::Functionsnewfunction(:httpd_modules,:type=:rvalue)do|args|defhelper_function(value)valueendresult=1+helper_function(3)resultendend {noformat} Puppet-Trace:Error:Couldnotretrievecatalogfromremoteserver:Error400onSERVER:undefinedmethod`helper_function'for#Puppet::Parser::Scope:0x007fac297fbd68at/www/data/puppet-environment/production/modules/httpd/manifests/webserver.pp:193onnoderpm-repo.pixelpark.com/usr/lib/ruby/site_ruby/1.8/puppet/indirector/rest.rb:207:in`is_http_200?'/usr/lib/ruby/site_ruby/1.8/puppet/indirector/rest.rb:100:in`find'/usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:201:in`find'/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:256:in`retrieve_new_catalog'/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:327:in`thinmark'/usr/lib/ruby/1.8/benchmark.rb:308:in`realtime'/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:326:in`thinmark'/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:255:in`retrieve_new_catalog'/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:60:in`retrieve_catalog'/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:103:in`prepare_and_retrieve_catalog'/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:170:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:47:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/agent/locker.rb:20:in`lock'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:47:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:117:in`with_client'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:44:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:82:in`run_in_fork'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:43:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:179:in`call'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:179:in`controlled_run'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:41:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/application/agent.rb:355:in`onetime'/usr/lib/ruby/site_ruby/1.8/puppet/application/agent.rb:321:in`run_command'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:371:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:477:in`plugin_hook'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:371:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:479:in`exit_on_fail'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:371:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:137:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:91:in`execute'/usr/bin/puppet:8ThanksforyourhelpPhilipp












   

 Add Comment

  

Jira (PUP-3404) helper functions in custom function

2014-10-08 Thread Charlie Sharpsteen (JIRA)
Title: Message Title










 

 Charlie Sharpsteen updated an issue


















 Puppet /  PUP-3404



  helper functions in custom function 










Change By:

 Charlie Sharpsteen









 Hi,IhaveaproblemwithhelperfunctionsincustomfunctionMypuppet-Version:v3.7.1Ifyouneedmoreinformation,letmeknow.Mycustomfunctioninveryshortfrom,butwiththesameerror.{noformat}modulePuppet::Parser::Functionsnewfunction(:httpd_modules,:type=:rvalue)do|args|defhelper_function(value)valueendresult=1+helper_function(3)resultendend{noformat}Puppet-Trace: {noformat} Error:Couldnotretrievecatalogfromremoteserver:Error400onSERVER:undefinedmethod`helper_function'for#Puppet::Parser::Scope:0x007fac297fbd68at/www/data/puppet-environment/production/modules/httpd/manifests/webserver.pp:193onnoderpm-repo.pixelpark.com/usr/lib/ruby/site_ruby/1.8/puppet/indirector/rest.rb:207:in`is_http_200?'/usr/lib/ruby/site_ruby/1.8/puppet/indirector/rest.rb:100:in`find'/usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:201:in`find'/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:256:in`retrieve_new_catalog'/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:327:in`thinmark'/usr/lib/ruby/1.8/benchmark.rb:308:in`realtime'/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:326:in`thinmark'/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:255:in`retrieve_new_catalog'/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:60:in`retrieve_catalog'/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:103:in`prepare_and_retrieve_catalog'/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:170:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:47:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/agent/locker.rb:20:in`lock'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:47:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:117:in`with_client'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:44:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:82:in`run_in_fork'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:43:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:179:in`call'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:179:in`controlled_run'/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:41:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/application/agent.rb:355:in`onetime'/usr/lib/ruby/site_ruby/1.8/puppet/application/agent.rb:321:in`run_command'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:371:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:477:in`plugin_hook'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:371:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:479:in`exit_on_fail'/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:371:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:137:in`run'/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:91:in`execute'/usr/bin/puppet:8 {noformat} ThanksforyourhelpPhilipp












   

 Add Comment
 

Jira (PUP-3404) helper functions in custom function

2014-10-08 Thread Charlie Sharpsteen (JIRA)
Title: Message Title










 

 Charlie Sharpsteen commented on an issue


















  Re: helper functions in custom function 










Does it work if you call the newfunction method directly instead of re-opening the module? I.E. by using:






Puppet::Parser::Functions.newfunction(:httpd_modules, :type = :rvalue) do |args|




  # ...




end



















   

 Add Comment

























 Puppet /  PUP-3404



  helper functions in custom function 







 Hi,  I have a problem with helper functions in custom function   My puppet-Version: v3.7.1  If you need more information, let me know.  My custom function in very short from, but with the same error.  {noformat}  module Puppet::Parser::Functions  newfunction(:httpd_modules, :type = :rvalue) do |args|  def helper_function(value)  value  e...

Jira (PUP-3404) helper functions in custom function

2014-10-08 Thread Charlie Sharpsteen (JIRA)
Title: Message Title










 

 Charlie Sharpsteen updated an issue


















 Puppet /  PUP-3404



  helper functions in custom function 










Change By:

 Charlie Sharpsteen




Assignee:

 Philipp












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-bugs@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/d/optout.


Jira (PUP-3404) helper functions in custom function

2014-10-08 Thread Henrik Lindberg (JIRA)
Title: Message Title










 

 Henrik Lindberg updated an issue


















 Puppet /  PUP-3404



  helper functions in custom function 










Change By:

 Henrik Lindberg




Component/s:

 DOCS












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-bugs@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/d/optout.


Jira (PUP-3404) helper functions in custom function

2014-10-08 Thread Henrik Lindberg (JIRA)
Title: Message Title










 

 Henrik Lindberg updated an issue


















 Puppet /  PUP-3404



  helper functions in custom function 










Change By:

 Henrik Lindberg




Component/s:

 DOCS












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.4#6159-sha1:44eaede)




 














-- 
You received this message because you are subscribed to the Google Groups Puppet Bugs group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-bugs@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/d/optout.


Jira (PUP-3404) helper functions in custom function

2014-10-08 Thread Henrik Lindberg (JIRA)
Title: Message Title










 

 Henrik Lindberg commented on an issue


















  Re: helper functions in custom function 










You should not define helper methods inside a Puppet 3x Function. They end up as method on the scope and they may overwrite each other. They may also end up on a different instance of scope.
The correct way is to define an auxiliary class that has the helper methods and call those from within the function body. As an example, the function hiera_hash does this:






module Puppet::Parser::Functions




  newfunction(:hiera_hash, :type = :rvalue, :arity = -2, :doc =  ...) do |*args|




key, default, override = HieraPuppet.parse_args(args)




HieraPuppet.lookup(key, default, self, override, :hash)




  end




end



















   

 Add Comment