-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix support for AWS ACL for Batch #2671
Signed-off-by: Paolo Di Tommaso <[email protected]>
- Loading branch information
1 parent
b362d6f
commit a964491
Showing
7 changed files
with
195 additions
and
4 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
29 changes: 29 additions & 0 deletions
29
plugins/nf-amazon/src/main/nextflow/cloud/aws/util/AwsHelper.groovy
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,29 @@ | ||
/* | ||
* Copyright (c) 2020-2021. Seqera Labs, S.L. | ||
* | ||
* All Rights reserved | ||
* | ||
*/ | ||
|
||
package nextflow.cloud.aws.util | ||
|
||
import com.amazonaws.services.s3.model.CannedAccessControlList | ||
import com.google.common.base.CaseFormat | ||
|
||
/** | ||
* Helper class for AWS | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
class AwsHelper { | ||
|
||
static CannedAccessControlList parseS3Acl(String value) { | ||
if( !value ) | ||
return null | ||
|
||
return value.contains('-') | ||
? CannedAccessControlList.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL,value)) | ||
: CannedAccessControlList.valueOf(value) | ||
} | ||
|
||
} |
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
28 changes: 28 additions & 0 deletions
28
plugins/nf-amazon/src/test/nextflow/cloud/aws/util/AwsHelperTest.groovy
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,28 @@ | ||
/* | ||
* Copyright (c) 2020-2021. Seqera Labs, S.L. | ||
* | ||
* All Rights reserved | ||
* | ||
*/ | ||
|
||
package nextflow.cloud.aws.util | ||
|
||
import com.amazonaws.services.s3.model.CannedAccessControlList | ||
import spock.lang.Specification | ||
/** | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
class AwsHelperTest extends Specification { | ||
|
||
def 'should parse S3 acl' () { | ||
expect: | ||
AwsHelper.parseS3Acl('PublicRead') == CannedAccessControlList.PublicRead | ||
AwsHelper.parseS3Acl('public-read') == CannedAccessControlList.PublicRead | ||
|
||
when: | ||
AwsHelper.parseS3Acl('unknown') | ||
then: | ||
thrown(IllegalArgumentException) | ||
} | ||
} |
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