Skip to content

Commit

Permalink
feat: remove storage account name if present from azure path
Browse files Browse the repository at this point in the history
  • Loading branch information
endre-seqera committed Jan 26, 2024
1 parent 74c66ba commit aee2c56
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class AzPathFactory extends FileSystemPathFactory {
if( uri.startsWith('az:///') )
throw new IllegalArgumentException("Invalid Azure path URI - make sure the schema prefix does not container more than two slash characters - offending value: $uri")

final storageAccountName = AzConfig.getConfig().storage().accountName
if (uri.contains(storageAccountName)){
uri = uri.replace("${storageAccountName}.","")
}

final storageConfigEnv = AzConfig.getConfig().storage().getEnv()

final activeDirectoryConfigEnv = AzConfig.getConfig().activeDirectory().getEnv()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,40 @@ class AzPathFactoryTest extends Specification {

cleanup:
Global.session = null

where:
AZ_URI | CONTAINER | BLOB
'az://my-data/foo/bar' | 'my-data' | 'foo/bar'
'az://my-data/data/*{1,2}.fq.gz'| 'my-data' | 'data/*{1,2}.fq.gz'
}


def 'should create az azure path and remove storage account name if present' () {
given:
def CONFIG = [azure: [
storage: [
accountKey: System.getenv('AZURE_STORAGE_ACCOUNT_KEY'),
accountName: System.getenv('AZURE_STORAGE_ACCOUNT_NAME'),
]
]]
Global.session = Mock(Session) { getConfig() >> CONFIG }
and:

when:
def path = AzPathFactory.parse(AZ_URI)
then:
path instanceof AzPath
(path as AzPath).containerName == CONTAINER
(path as AzPath).blobName() == BLOB

cleanup:
Global.session = null

where:
storageAccount | AZ_URI | CONTAINER | BLOB
System.getenv('AZURE_STORAGE_ACCOUNT_NAME') | "az://${storageAccount}.my-data/foo/bar" | 'my-data' | 'foo/bar'
System.getenv('AZURE_STORAGE_ACCOUNT_NAME') | "az://${storageAccount}.my-data/data/*{1,2}.fq.gz"| 'my-data' | 'data/*{1,2}.fq.gz'
}

def 'should throw illegal path' () {
given:
Expand Down

0 comments on commit aee2c56

Please sign in to comment.