-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Detect and correct "incorrect" use of new FnJoin
#516
Conversation
A common developer error is to pass an array as the second argument of `new FnJoin`, but that argument is variadic. This causes invalid CloudFormation templates to be generated. This change detects this usage pattern (vararg contains a single element that is an array) and fixes it up transparently. Related to #512
@@ -88,6 +88,18 @@ export class FnJoin extends Fn { | |||
* @param listOfValues The list of values you want combined. | |||
*/ | |||
constructor(delimiter: string, ...listOfValues: any[]) { |
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 think I rather we align the signature here to CloudFormation instead of be "smart" about it. FnConcat
is a nice sugar on top that has a variadic signature.
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.
Also missing test
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.
Okay. Can do that then.
|
||
export = nodeunit.testCase({ | ||
'Fn::Join': { | ||
'rejects empty list of arguments to join'(test: nodeunit.Test) { |
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.
Are you sure there aren’t already tests for these?
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.
Reasonably:
- Nothing showed up in
/test/
when I grep'd forFnJoin(
. - There was no
test.fn.ts
and that's where I expect those unit tests to be
I'm tracking down places where the "old" syntax was used and fixing those (they are what causes the CodeBuild to fail). |
A common developer error is to pass an array as the second argument of
new FnJoin
, but that argument is variadic. This causes invalidCloudFormation templates to be generated. This change corrects the
API to match the
Fn::Join
syntax where the second argument is anarray.
Related to #512