Skip to content
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

feat: remove storage account name if present from azure path #4692

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)){
endre-seqera marked this conversation as resolved.
Show resolved Hide resolved
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