-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MODULES-444-Add concat multiple #374
MODULES-444-Add concat multiple #374
Conversation
| # | ||
|
|
||
| module Puppet::Parser::Functions | ||
| newfunction(:concat_multiple, :type => :rvalue, :doc => <<-EOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not extend the existing function, or would that conflict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went for a soflty approach at first, because I wasn't sure how PL was dealing with backwards compatibility on new features on functions.
If it's cool to change so concat could take > 2 arguments I can definitely refactor this PR to be on the original function and DRY up the code a bit 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored back onto the original function 💃
`concat` can now take multiple arguments
`concat` should be able to concat arrays and primitives
Acceptance test to take multiple arrays for concatenation
Also add extra test for just 1 argument
This is the core change, we now go through the array and add it to the first element, instead of just two arguments.
|
w00t! will review in a second! |
|
look good to me! |
|
|
||
| a = arguments[0] | ||
| b = arguments[1] | ||
|
|
||
| # Check that the first parameter is an array | ||
| unless a.is_a?(Array) | ||
| raise(Puppet::ParseError, 'concat(): Requires array to work with') | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we even do this check? We can just cast everything to an array... so it's silly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
MODULES-444-Add concat multiple
| pp = <<-EOS | ||
| $output = concat(['1','2','3'],['4','5','6'],['7','8','9']) | ||
| validate_array($output) | ||
| if size($output) != 6 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, this should be != 9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petems yep, just found that, about to PR :)
|
see #389 |
There was a request to enable concat to take multiple arguments.
https://tickets.puppetlabs.com/browse/MODULES-444