Hi,
Ruby DSL and templates (via e.g. inline_template) would have the same
problem, unless this was handled properly on the function's side.
KW
On Friday, 22 June 2012 18:53:55 UTC+1, ad wrote:
>
> Josh,
>
> I appreciate the help. Using function_foo(['bar']) rather than
> function_foo('bar') works as expected. I'm sure this will also solve the
> same issue I was having calling a custom function from a Ruby DSL defined
> type.
>
> Cheers,
>
> Adam
>
> On Friday, June 22, 2012 12:01:24 PM UTC-5, Josh Cooper wrote:
>>
>>
>>
>> On Fri, Jun 22, 2012 at 9:13 AM, ad <[email protected]> wrote:
>>
>>> I just tested this on CentOS/Puppet 2.7.12 with the same result.
>>>
>>> - Adam
>>>
>>>
>>> On Friday, June 22, 2012 10:20:52 AM UTC-5, ad wrote:
>>>>
>>>> This is on Windows running 2.7.16. I haven't tested on Linux or other
>>>> versions. I'm still relatively new to Puppet and haven't used custom
>>>> functions before, so wanted to run this by the list before filing a bug.
>>>>
>>>> When calling custom functions from functions, arguments are being
>>>> converted to decimal arrays. That is, passing the argument 'bar' from a
>>>> custom function to another function results in
>>>>
>>>> arg[0]: 98
>>>> arg[1]: 97
>>>> arg[2]: 114
>>>>
>>>> Here's a full example in case I'm doing something wrong here.
>>>>
>>>> Function 1:
>>>>
>>>> module Puppet::Parser::Functions
>>>> newfunction(:foo) do |args|
>>>> puts 'args[0]:' + args[0].to_s
>>>> puts 'args.size:' + args.size.to_s
>>>> end
>>>> end
>>>>
>>>> Function 2:
>>>>
>>>> module Puppet::Parser::Functions
>>>> newfunction(:foo2) do |args|
>>>> Puppet::Parser::Functions.**autoloader.loadall
>>>> function_foo('from_function')
>>>>
>>>
>> Since you are calling foo with a single argument, I believe the args in
>> function foo is a string, not an array. If you instead say
>> `function_foo(['from_function'])`, it should do what function foo expects.
>>
>> end
>>>> end
>>>>
>>>> A manifest:
>>>>
>>>> foo('from_manifest')
>>>> foo2()
>>>>
>>>> Puppet Agent run Result:
>>>>
>>>> args[0]:from_manifest
>>>> args.size:1
>>>> args[0]:102
>>>> args.size:13
>>>>
>>>> 13 is the string length of 'from_function', and 102 is the decimal
>>>> representation of 'f'.
>>>>
>>>> - Adam
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Puppet Users" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/puppet-users/-/-eqfuh4NRI0J.
>>>
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/puppet-users?hl=en.
>>>
>>
>> --
>> Josh Cooper
>> Developer, Puppet Labs
>>
>>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/UAzUIA3jQWkJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.