diff options
author | Harmen Stoppels <me@harmenstoppels.nl> | 2024-09-19 16:06:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-19 16:06:44 +0200 |
commit | 1d18f571ae18cce1d3a5555513c5baef24008e2d (patch) | |
tree | 9027ebe6e54027acacf1e35a21a6e337d91bb8ab /lib | |
parent | 586360a8fe191585339a8dd69cc4eff400f6bb0b (diff) | |
download | spack-1d18f571ae18cce1d3a5555513c5baef24008e2d.tar.gz spack-1d18f571ae18cce1d3a5555513c5baef24008e2d.tar.bz2 spack-1d18f571ae18cce1d3a5555513c5baef24008e2d.tar.xz spack-1d18f571ae18cce1d3a5555513c5baef24008e2d.zip |
url join: fix oci scheme (#46483)
* url.py: also special case oci scheme in join
* avoid fetching keys from oci mirror
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/binary_distribution.py | 3 | ||||
-rw-r--r-- | lib/spack/spack/test/util/util_url.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/util/url.py | 6 |
3 files changed, 7 insertions, 4 deletions
diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py index ad236ff056..baa04f9df6 100644 --- a/lib/spack/spack/binary_distribution.py +++ b/lib/spack/spack/binary_distribution.py @@ -2698,6 +2698,9 @@ def get_keys(install=False, trust=False, force=False, mirrors=None): for mirror in mirror_collection.values(): fetch_url = mirror.fetch_url + # TODO: oci:// does not support signing. + if fetch_url.startswith("oci://"): + continue keys_url = url_util.join( fetch_url, BUILD_CACHE_RELATIVE_PATH, BUILD_CACHE_KEYS_RELATIVE_PATH ) diff --git a/lib/spack/spack/test/util/util_url.py b/lib/spack/spack/test/util/util_url.py index 0666d7a28f..ed34a79152 100644 --- a/lib/spack/spack/test/util/util_url.py +++ b/lib/spack/spack/test/util/util_url.py @@ -48,7 +48,7 @@ def test_relative_path_to_file_url(tmpdir): @pytest.mark.parametrize("resolve_href", [True, False]) -@pytest.mark.parametrize("scheme", ["http", "s3", "gs", "file"]) +@pytest.mark.parametrize("scheme", ["http", "s3", "gs", "file", "oci"]) def test_url_join_absolute(scheme, resolve_href): """Test that joining a URL with an absolute path works the same for schemes we care about, and whether we work in web browser mode or not.""" diff --git a/lib/spack/spack/util/url.py b/lib/spack/spack/util/url.py index 982e192a4c..9054c7ad3f 100644 --- a/lib/spack/spack/util/url.py +++ b/lib/spack/spack/util/url.py @@ -73,7 +73,7 @@ def join(base: str, *components: str, resolve_href: bool = False, **kwargs) -> s 1. By default resolve_href=False, which makes the function like os.path.join: for example https://example.com/a/b + c/d = https://example.com/a/b/c/d. If resolve_href=True, the behavior is how a browser would resolve the URL: https://example.com/a/c/d. - 2. s3:// and gs:// URLs are joined like http:// URLs. + 2. s3://, gs://, oci:// URLs are joined like http:// URLs. 3. It accepts multiple components for convenience. Note that components[1:] are treated as literal path components and appended to components[0] separated by slashes.""" # Ensure a trailing slash in the path component of the base URL to get os.path.join-like @@ -87,8 +87,8 @@ def join(base: str, *components: str, resolve_href: bool = False, **kwargs) -> s try: # NOTE: we temporarily modify urllib internals so s3 and gs schemes are treated like http. # This is non-portable, and may be forward incompatible with future cpython versions. - urllib.parse.uses_netloc = [*uses_netloc, "s3", "gs"] - urllib.parse.uses_relative = [*uses_relative, "s3", "gs"] + urllib.parse.uses_netloc = [*uses_netloc, "s3", "gs", "oci"] + urllib.parse.uses_relative = [*uses_relative, "s3", "gs", "oci"] return urllib.parse.urljoin(base, "/".join(components), **kwargs) finally: urllib.parse.uses_netloc = uses_netloc |