Skip to content

Commit fcd676f

Browse files
committed
feat: remove storage account name if present from azure path
Signed-off-by: endre-seqera <endre.sukosd@seqera.io>
1 parent 74c66ba commit fcd676f

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

plugins/nf-azure/src/main/nextflow/cloud/azure/file/AzPathFactory.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ class AzPathFactory extends FileSystemPathFactory {
4848
if( uri.startsWith('az:///') )
4949
throw new IllegalArgumentException("Invalid Azure path URI - make sure the schema prefix does not container more than two slash characters - offending value: $uri")
5050

51+
final storageAccountName = AzConfig.getConfig().storage().accountName
52+
if (uri.contains(storageAccountName)){
53+
uri = uri.replace("${storageAccountName}.","")
54+
}
55+
5156
final storageConfigEnv = AzConfig.getConfig().storage().getEnv()
5257

5358
final activeDirectoryConfigEnv = AzConfig.getConfig().activeDirectory().getEnv()

plugins/nf-azure/src/test/nextflow/cloud/azure/file/AzPathFactoryTest.groovy

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,40 @@ class AzPathFactoryTest extends Specification {
3838

3939
cleanup:
4040
Global.session = null
41-
41+
4242
where:
4343
AZ_URI | CONTAINER | BLOB
4444
'az://my-data/foo/bar' | 'my-data' | 'foo/bar'
4545
'az://my-data/data/*{1,2}.fq.gz'| 'my-data' | 'data/*{1,2}.fq.gz'
4646
}
4747

4848

49+
def 'should create az azure path and remove storage account name if present' () {
50+
given:
51+
def CONFIG = [azure: [
52+
storage: [
53+
accountKey: System.getenv('AZURE_STORAGE_ACCOUNT_KEY'),
54+
accountName: System.getenv('AZURE_STORAGE_ACCOUNT_NAME'),
55+
]
56+
]]
57+
Global.session = Mock(Session) { getConfig() >> CONFIG }
58+
and:
59+
60+
when:
61+
def path = AzPathFactory.parse(AZ_URI)
62+
then:
63+
path instanceof AzPath
64+
(path as AzPath).containerName == CONTAINER
65+
(path as AzPath).blobName() == BLOB
66+
67+
cleanup:
68+
Global.session = null
69+
70+
where:
71+
storageAccount | AZ_URI | CONTAINER | BLOB
72+
System.getenv('AZURE_STORAGE_ACCOUNT_NAME') | "az://${storageAccount}.my-data/foo/bar" | 'my-data' | 'foo/bar'
73+
System.getenv('AZURE_STORAGE_ACCOUNT_NAME') | "az://${storageAccount}.my-data/data/*{1,2}.fq.gz"| 'my-data' | 'data/*{1,2}.fq.gz'
74+
}
4975

5076
def 'should throw illegal path' () {
5177
given:

0 commit comments

Comments
 (0)