Enable GCS urls as valid (#29592)

* Add tests to ensure google cloud storage urls work as mirrors

This commit adds two tests to track that GCS buckets can work as
mirrors, and can be parsed as valid URLs.

Currently, gs:// format URLs are not correctly parsed.

* Fix URL parsing for GCS buckets

This commit adds GCS bucket URLs as valid URLs.
This commit is contained in:
Doug Jacobsen 2022-03-20 02:13:00 -06:00 committed by GitHub
parent 26552533be
commit 9b0d5cbabf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -210,6 +210,13 @@ def test_mirror_crud(tmp_scope, capsys):
output = mirror('list', '--scope', tmp_scope)
assert 'No mirrors configured' in output
# Test GCS Mirror
mirror('add', '--scope', tmp_scope,
'mirror', 'gs://spack-test')
output = mirror('remove', '--scope', tmp_scope, 'mirror')
assert 'Removed mirror' in output
def test_mirror_nonexisting(tmp_scope):
with pytest.raises(SpackCommandError):

View File

@ -59,6 +59,11 @@ def test_url_parse():
assert(parsed.netloc == 'path')
assert(parsed.path == '/to/resource')
parsed = url_util.parse('gs://path/to/resource')
assert(parsed.scheme == 'gs')
assert(parsed.netloc == 'path')
assert(parsed.path == '/to/resource')
spack_root = spack.paths.spack_root
parsed = url_util.parse('file://$spack')
assert(parsed.scheme == 'file')

View File

@ -343,7 +343,7 @@ def parse_git_url(url):
def require_url_format(url):
ut = re.search(r'^(file://|http://|https://|ftp://|s3://|/)', url)
ut = re.search(r'^(file://|http://|https://|ftp://|s3://|gs://|/)', url)
assert ut is not None