Skip to content

Commit

Permalink
Fix bug where depending on how parameters are supplied not found erro… (
Browse files Browse the repository at this point in the history
#9)

* Fix bug where depending on how parameters are supplied not found erros would occur because a collection of GString's will return false for contains a String even thought toString() on both are the same

* Clean up code
  • Loading branch information
fieldju committed Apr 12, 2017
1 parent cf52feb commit ed3d757
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=com.fieldju
artifactId=gradle-aws-sam-deployer-plugin
version=1.5.1
version=1.5.2
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class MultiRegionPackageAndDeploySamTaskIntegrationTest {
void before() {
testStackName = "MultiRegionPackageAndDeploySamTaskIntegrationTest-${UUID.randomUUID()}"
regionS3BucketMap = [
'us-west-2': EnvUtils.getRequiredEnv('S3_BUCKET', 'The us-west-2 s3 bucket to upload the lambda fat jar'),
'us-east-1': EnvUtils.getRequiredEnv('S3_BUCKET_EAST', 'The us-east-2 s3 bucket to upload the lambda fat jar')
"us-west-2": EnvUtils.getRequiredEnv('S3_BUCKET', 'The us-west-2 s3 bucket to upload the lambda fat jar'),
"us-east-1": EnvUtils.getRequiredEnv('S3_BUCKET_EAST', 'The us-east-2 s3 bucket to upload the lambda fat jar')
]

regions.each { regionString ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class MultiRegionDeploySamTask extends DefaultTask {

@Input
@Optional
def regionTemplatePathMap = [:]
Map<String, String> regionTemplatePathMap = [:]

@Input
def regions = []
List<String> regions = []

@Input
String stackName
Expand All @@ -30,7 +30,14 @@ class MultiRegionDeploySamTask extends DefaultTask {

@TaskAction
void taskAction() {
// Groovy Strings and GStrings don't work together in collections because hashCode() produces different hashes
// So lets make sure that we are dealing with the same types
def regionTemplatePathMap = this.regionTemplatePathMap.collectEntries { String key, String value -> [(key.toString()): value ] }
def regionToParameterOverridesMap = this.regionToParameterOverridesMap.collectEntries { key, value -> [(key.toString()): value ] }
List<String> regions = this.regions*.toString()

PackageAndDeployTaskHelper helper = new PackageAndDeployTaskHelper(logger)
//noinspection GroovyAssignabilityCheck
helper.multiRegionDeploy(templatePath, regionTemplatePathMap, regions,
stackName, regionToParameterOverridesMap, executeChangeSet)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.gradle.api.tasks.TaskAction
class MultiRegionPackageAndDeploySamTask extends DefaultTask {

@Input
def regions = []
List<String> regions = []

@Input
String stackName
Expand Down Expand Up @@ -47,6 +47,13 @@ class MultiRegionPackageAndDeploySamTask extends DefaultTask {

@TaskAction
void taskAction() {
// Groovy Strings and GStrings don't work together in collections because hashCode() produces different hashes
// So lets make sure that we are dealing with the same types
def regionToS3BucketMap = this.regionToS3BucketMap.collectEntries { key, value -> [ (key.toString()) : value ] }
def regionToKmsKeyIdMap = this.regionToKmsKeyIdMap.collectEntries { key, value -> [ (key.toString()) : value ] }
def regionToParameterOverridesMap = this.regionToParameterOverridesMap.collectEntries { key, value -> [ (key.toString()) : value ] }
List<String> regions = this.regions*.toString()

PackageAndDeployTaskHelper helper = new PackageAndDeployTaskHelper(logger)

regions.each { String region ->
Expand Down

0 comments on commit ed3d757

Please sign in to comment.