Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(aws): apply code review suggestions
- Loading branch information
Showing
6 changed files
with
112 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
lib/plugins/aws/package/compile/events/msk/getMskClusterNameToken.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
const getMskClusterNameToken = eventSourceArn => { | ||
if (eventSourceArn['Fn::ImportValue']) { | ||
return eventSourceArn['Fn::ImportValue']; | ||
} else if (eventSourceArn.Ref) { | ||
return eventSourceArn.Ref; | ||
} | ||
|
||
return eventSourceArn.split('/')[1]; | ||
}; | ||
|
||
module.exports = getMskClusterNameToken; |
27 changes: 27 additions & 0 deletions
27
lib/plugins/aws/package/compile/events/msk/getMskClusterNameToken.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
const chai = require('chai'); | ||
const getMskClusterNameToken = require('./getMskClusterNameToken'); | ||
|
||
const { expect } = chai; | ||
|
||
describe('getMskClusterNameToken', () => { | ||
it('with ARN', () => { | ||
const eventSourceArn = | ||
'arn:aws:kafka:us-east-1:111111111111:cluster/ClusterName/a1a1a1a1a1a1a1a1a'; | ||
const result = getMskClusterNameToken(eventSourceArn); | ||
expect(result).to.equal('ClusterName'); | ||
}); | ||
|
||
it('with Fn::ImportValue', () => { | ||
const eventSourceArn = { 'Fn::ImportValue': 'importvalue' }; | ||
const result = getMskClusterNameToken(eventSourceArn); | ||
expect(result).to.equal('importvalue'); | ||
}); | ||
|
||
it('with Ref', () => { | ||
const eventSourceArn = { Ref: 'ReferencedResource' }; | ||
const result = getMskClusterNameToken(eventSourceArn); | ||
expect(result).to.equal('ReferencedResource'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.