Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
Fix GetAtt shorthand not accepting array parameters (#165)
Browse files Browse the repository at this point in the history
* "Fn::GetAtt" argument has two forms, one as string and the other as array.

* Fixed code style issue.

* Add shorthand getatt test for parser

* Add changelog
  • Loading branch information
RazzM13 authored and martysweet committed May 8, 2018
1 parent 09402a1 commit 8036ea7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic
Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Merge PR #165, fixing GetAtt shorthand not accepting array parameters

## [1.7.0] - 2018-05-06
### Fixed
Expand Down
6 changes: 6 additions & 0 deletions src/test/parserTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ describe('parser', () =>{
expect(result).to.not.equal(null);
});

it('valid yaml !GetAtt as array should return valid javascript object', () => {
let result = parser.openFile("./testData/valid/yaml/issue_164_getatt_shorthand_parsing.yaml");
expect(result).to.not.equal(undefined);
expect(result).to.not.equal(null);
});

it('invalid yaml should throw an Error', () => {
let fn = function(){ parser.openFile("./testData/invalid/yaml/invalid_yaml.yaml"); };
expect(fn).to.throw(/Could not determine file type. Check your template is not malformed./);
Expand Down
2 changes: 1 addition & 1 deletion src/yamlSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function buildYamlType(fnName: string, kind: YamlKind) {
const tag = `!${tagName}`;

const constructFn = (fnName === 'Fn::GetAtt')
? (data: any) => ({'Fn::GetAtt': data.split('.')})
? (data: any) => ({'Fn::GetAtt': Array.isArray(data) ? data : data.split('.')})
: (data: any) => ({[fnName]: data});

return new yaml.Type(tag, {
Expand Down
9 changes: 9 additions & 0 deletions testData/valid/yaml/issue_164_getatt_shorthand_parsing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Resources:
Bucket:
Type: AWS::S3::Bucket

Outputs:
output1:
Value: !GetAtt
- Bucket
- Arn

0 comments on commit 8036ea7

Please sign in to comment.