-
Notifications
You must be signed in to change notification settings - Fork 69
Fix for functionnames where functionname A startwith functionname B #162
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
Conversation
.find would find wrong versionname and aliasname
…function name B - test stack updated with case that covers the issue
I've added commit with:
|
@HyperBrain pls review |
lib/stackops/apiGateway.js
Outdated
const versionName = _.find(_.keys(versions), version => _.startsWith(version, functionName)); | ||
const aliasName = _.find(_.keys(aliases), alias => _.startsWith(alias, functionName)); | ||
const isExternalRef = isExternalRefAuthorizerPredicate(permission.Properties.FunctionName); | ||
const versionName = _.find(_.keys(versions), version => _.startsWith(version, `${functionName}LambdaVersion`)); |
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.
this will work, but you essentially not checking for _.startsWith
anymore but for string equality. Shouldn't then a simple ===
suffice?
May be to be more robust this should be _startsWith(version
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.
getFunctionVersionName
and getAliasVersionName
functions added to utils
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.
the way to retrieve the version name and the alias name is repeated multiple times. Maybe this could be move to utility functions and defined only once. e.g.
function getVersionName(versions, functionName) {
return _.find(_.keys(versions), version => _.startsWith(version, `${functionName}LambdaVersion`));
}
similar for aliasName
- getFunctionVersionName and getAliasVersionName function added to utils
…or-naming-issue Fix for functionnames where functionname A startwith functionname B
.find would find wrong versionname and aliasname
Example:
Function A: GetAccount
Function B: GetAccountByName
For function GetAccountByName the versionname and aliasname would be from the GetAccount function